Run seeds on deployment

hello there,
i try deploy my app in docker container, everything works fine, but i can’t understand how can i run seeds on deployment ?i do it without distillery.
Thanks for your help

hello and welcome,

I usually backup and restore the db manually. If You use postgres, that would be pg_dump and restore on the production machine.

I am not sure it is the right way, but it works fine for me :slight_smile:

Another option is to run any database migrations / population prior to starting your app via a start up script.

For example, in your Dockerfile you’d copy over a start up script (in the example below from the root directory of your app):

# Add the start commands bash file
ADD /scripts/
RUN chmod +x /scripts/

# Switch to the non root user
USER app

# set the entrypoint to the start commands script
ENTRYPOINT ["/scripts/"]

And your start-up script would look something like:

./prod/rel/<your_app>/bin/<your_app> eval "YourApp.ReleaseTasks.migrate"
./prod/rel/<your_app>/bin/<your_app> start

And the release tasks module could look something like the below where you’ve added any data population / default data scripts that you want as part of production to your migrations:

defmodule YourApp.ReleaseTasks do
  @moduledoc false
  def migrate do
    IO.puts("***** RUNNING MIGRATIONS *****")
    {:ok, _} = Application.ensure_all_started(:your_app)

    path = Application.app_dir(:your_app, "priv/repo/migrations"), path, :up, all: true)
    IO.puts("***** FINISHED MIGRATIONS *****")
1 Like

thanks a lot

These two pages helped me deploy my umbrella app. They also show how to make a deployment migration script.

This helped me get started:

This helped with the nuances of deploying an umbrella app: