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:
As I was not able to find any clue on the Internet, you are my last hope!
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.
Because when You produce a release everything is included inside. You don’t need to install anything but the binary … and the database, if hosted on the server, … and maybe a reverse proxy, like nginx.
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
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…
As you mentioned if everything is packed into deployment binaries, installing elixir on the final container and migrating wouldn’t help. I wish there was a way to migrate during the deployment pipeline.
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.
The Distillery docs have a page on migrations in case that’s any help. It’s possible to have a migration task run on every (re)start of the app when using Distillery releases, which is what I’ve been doing, but I’m not using Google. @bitwalker may be able to advise.
There are other approaches that may make more sense for your use case, for example, automatically running migrations by defining a pre-start hook which does basically the same thing as above, just in a hook instead of a command. You can even define the command, and execute the command as part of the hook, giving you the flexibility of both approaches
Just made a dump of the table and imported it on my Google Cloud SQL instance and it totally works!
@kokolegorille, @BrightEyesDavid Thank you for your support, I’ll definitely check out the documentation of edeliver and distillery as my understanding of Elixir/Phoenix get stronger.
I will update this post in the future if I happen to find a viable solution.
Migrations are just facilities to help us manage database, but everything can be done with sql. Including dump, restore, selected dump, schema dump, data only dump etc.