ngc2359

ngc2359

Ecto migrations on Google Cloud

Hi, I’m relatively new to Elixir and Phoenix but I wanted to deploy a very simple app on Google Cloud App Engine Flexible (works on localhost). The problem is that the deployment pipeline of elixir-runtime does not include any ecto.migrate routine, and once the app is deployed there is no access to any mix utility.

I tried to include this task in the pipeline but then it doesn’t have access to the database, here is my app.yaml:

env: flex

runtime: gs://elixir-runtime/elixir.yaml
runtime_config:
  release_app: my_project
  build:
      - mix phx.digest
      - mix ecto.migrate

env_variables:
  DB_USER: postgres
  DB_PASS: my_password
  DB_NAME: my_project
  DB_HOST: /cloudsql/my_project:europe-west1:my_project-sql

beta_settings:
  cloud_sql_instances: my_project:europe-west1:my_project-sql 

As I was not able to find any clue on the Internet, you are my last hope! :sunny:

EDIT: Allowing any IP address to connect to the database (as bad as it is) doesn’t work either as the builder container does not seem to have access to that network.

First Post!

dokuzbir

dokuzbir

As i see there is no elixir in machines. You can try install to machines to elixir. But i think wont persist.

https://github.com/kokolegorille/app/blob/master/DEPLOYMENT.md#user-content-production-server

@kokolegorille told production machines dont need elixir, erlang, phoenix. I dont know why but he can explain better than me.

Most Liked

kokolegorille

kokolegorille

Because when You produce a release everything is included inside. You don’t need to install anything but the binary :slight_smile: … and the database, if hosted on the server, … and maybe a reverse proxy, like nginx.

kokolegorille

kokolegorille

For the question, I may hardly answer because I never used Google Cloud, but to me the release Repo should be configured with the config/prod_secret.exs file.

This should grant access to the database…

There should be an equivalent inside this config/prod_secret.exs of

env_variables:
DB_USER: postgres
DB_PASS: my_password
DB_NAME: my_project
DB_HOST: /cloudsql/my_project:europe-west1:my_project-sql

Then the migration is a separate task. As I mentionned in the repo I did the migration by hand using pg_dump and psql to restore database on the production server.

I have no idea about how to configure Google Cloud, but I would look if I can initialize it with a simple sql dump file.

This part, once You get it right, can be automate by edeliver.

But their are great change coming in the deployment system…

kokolegorille

kokolegorille

I had a look at

I don’t know if it is the service used… but it seems You can send sql to psql client in the cloud shell. I would dump the database from dev, and use this to restore db on production.

Unless there is something I am missing.

Did You look at edeliver?

Last Post!

BrightEyesDavid

BrightEyesDavid

I’ve updated my reply above with a link to the Distillery migrations documentation page.

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement