I have an OTP Application that I now need to deploy. To achieve this, I am using distillery. My objective is to pass a self-sufficient file to the PROD machine that contains everything and doesn’t need to be extracted.
Most people using distillery will know the usual route:
MIX_ENV=prod mix release
build/prod/rel/<name>/releases/<version>/<name>.tar.gz
to the deploy serverMy objective is to eliminate step 3. I don’t want to extract anything, I just want to copy the release and run it, like a sudo executable.
According to the documentation one can also run MIX_ENV=prod mix release --executable
or MIX_ENV=prod mix release --transient
. This will create a pseudo executable file that doesn’t need to be extracted.
However, after running the MIX_ENV=prod mix release --executable
command, I usually search the file build/prod/rel/<name>/releases/<version>/<name>.run
. In theory this should be the file I need to copy into my deploy server but I can’t find it anywhere.
Try double checking what you're doing. For reference, I just tried this, and it worked fine. I'm using Elixir 1.7.4 and distillery 2.0.12.
Here's what I did:
create a new project:
mix new test_executable --sup
added distillery to mix.exs
,
ran
mix release.init
ran:
env MIX_ENV=prod mix release --executable
Got this output:
==> Assembling release..
==> Building release test_executable:0.1.0 using environment prod
==> Including ERTS 10.2 from /usr/local/Cellar/erlang/21.2/lib/erlang/erts-10.2
==> Packaging release..
Release successfully built!
To start the release you have built, you can use one of the following tasks:
# start a shell, like 'iex -S mix'
> _build/prod/rel/test_executable/bin/test_executable.run console
# start in the foreground, like 'mix run --no-halt'
> _build/prod/rel/test_executable/bin/test_executable.run foreground
# start in the background, must be stopped with the 'stop' command
> _build/prod/rel/test_executable/bin/test_executable.run start
If you started a release elsewhere, and wish to connect to it:
# connects a local shell to the running node
> _build/prod/rel/test_executable/bin/test_executable.run remote_console
# connects directly to the running node's console
> _build/prod/rel/test_executable/bin/test_executable.run attach
For a complete listing of commands and their use:
> _build/prod/rel/test_executable/bin/test_executable.run help
I can now copy the file elsewhere and run it:
cp _build/prod/rel/test_executable/bin/test_executable.run /tmp
cd /tmp
./test_executable.run console
Erlang/OTP 21 [erts-10.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]
Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(test_executable@127.0.0.1)1>