I’ve done this a lot when using distillery - for example, bundling a script which will execute an ecto.migration task.
Here’s an example of with this kind of configuration.
The reason this is important is for kubernetes. Kubernetes has various lifecycle hooks such as healthcheck, startup, etc.
It’s very nice to provide the cluster administrators with the means to run extra tasks - and it’s even nicer when you package this with the application so that you have targets like this :
docker run --rm -ti \
-e POSTGRES_HOSTNAME=postgres.notifications \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DATABASE=notifications_dev \
-e DATADOG_AGENT_HOSTNAME=localhost \
-e DATADOG_AGENT_APM_PORT=8126 \
-e EXQ_HOST=redis.notifications \
-e EXQ_PASSWORD= \
-e EXQ_PORT=6379 \
-e EXQ_NAMESPACE=exq \
--name notificatons \
--network notifications \
--hostname notifications \
-p 4000:4000 \
foo/notifications:latest help
Usage: notifications COMMAND [ARGS]
The known commands are:
start Starts the system
start_iex Starts the system with IEx attached
daemon Starts the system as a daemon
daemon_iex Starts the system as a daemon with IEx attached
eval "EXPR" Executes the given expression on a new, non-booted system
rpc "EXPR" Executes the given expression remotely on the running system
remote Connects to the running system via a remote shell
restart Restarts the running system via a remote command
stop Stops the running system via a remote command
pid Prints the OS PID of the running system via a remote command
version Prints the release name and version to be booted
--> run_migration Run ecto migration
--> update_email_templates Update email templates (for example)
ERROR: Unknown command help