Skip to content

ASIC Sentry - How to make release?

Clond source code

git clone https://github.com/nguyenvinhlinh/ASIC-Sentry

Set the environment variables:

mix phx.gen.secret
REALLY_LONG_SECRET

export SECRET_KEY_BASE=REALLY_LONG_SECRET
export DATABASE_URL=ecto://USER:PASS@HOST/database

Install npm pacakge in assets

cd assets
npm install

Then load dependencies to compile code and assets:

# Fetch and compile
mix deps.get --only prod
MIX_ENV=prod mix compile

# Compile assets
MIX_ENV=prod mix assets.deploy

And now run mix phx.gen.release (RUN 1 TIME ONLY, IT WILL MODIFY EXISTING FILES release.ex...):

➜ asic_sentry (milestone-1-cleanup) ✗ mix phx.gen.release
* creating rel/overlays/bin/server
* creating rel/overlays/bin/server.bat
* creating rel/overlays/bin/migrate
* creating rel/overlays/bin/migrate.bat
* creating lib/asic_sentry/release.ex

Your application is ready to be deployed in a release!

See https://hexdocs.pm/mix/Mix.Tasks.Release.html for more information about Elixir releases.

Here are some useful release commands you can run in any release environment:

    # To build a release
    mix release

    # To start your system with the Phoenix server running
    _build/dev/rel/asic_sentry/bin/server

    # To run migrations
    _build/dev/rel/asic_sentry/bin/migrate

Once the release is running you can connect to it remotely:

    _build/dev/rel/asic_sentry/bin/asic_sentry remote

To list all commands:

    _build/dev/rel/asic_sentry/bin/asic_sentry

Finally, run MIX_ENV=prod mix release

➜ asic_sentry (milestone-1-cleanup) ✗ mix phx.gen.release
Generated asic_sentry app
* assembling asic_sentry-0.1.0 on MIX_ENV=prod
* using config/runtime.exs to configure the release at runtime

Release created at _build/prod/rel/asic_sentry

    # To start your system
    _build/prod/rel/asic_sentry/bin/asic_sentry start

Once the release is running:

    # To connect to it remotely
    _build/prod/rel/asic_sentry/bin/asic_sentry remote

    # To stop it gracefully (you may also send SIGINT/SIGTERM)
    _build/prod/rel/asic_sentry/bin/asic_sentry stop

To list all commands:

    _build/prod/rel/asic_sentry/bin/asic_sentry

Now, this is the release directory, _build/prod/rel/asic_sentry

➜ asic_sentry ✗ tree -L 1 _build/prod/rel/asic_sentry
_build/prod/rel/asic_sentry
├── bin
├── erts-15.0
├── lib
└── releases