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 start_commands.sh /scripts/start_commands.sh
RUN chmod +x /scripts/start_commands.sh

# Switch to the non root user
USER app

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

And your start-up script would look something like:

#!/bin/bash
./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")

    Ecto.Migrator.run(YourApp.Repo, path, :up, all: true)
    IO.puts("***** FINISHED MIGRATIONS *****")
  end
end

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:

https://elixirschool.com/blog/releasing-an-umbrella-app-with-docker-and-mix-release/