bitwalker / distillery

Simplify deployments in Elixir with OTP releases!
MIT License
2.97k stars 398 forks source link

Improve support for running in read-only environments #670

Open lasseebert opened 5 years ago

lasseebert commented 5 years ago

Steps to reproduce

Try to start app with e.g. (note that /data is read-write)

HOME=/data/balrog/ RELEASE_MUTABLE_DIR=/data/balrog/ /balrog/bin/balrog foreground

Verbose Logs (Logs from embedded box)

sh: /balrog/releases/0.2.3/libexec/erts.sh: line 306: /balrog/releases/start_erl.data: Read-only file system

Description of issue

This works fine on Distillery 2.0.12, but fails with the Read-only filesystem message on 2.0.13 and 2.0.14.

The app is deployed to a read-only dir, but I point to a read-write dir for the $RELEASE_MUTABLE_DIR.

Downgrading to Distillery 2.0.12 made it work again.

Details:

``` # rel/config.exs # Import all plugins from `rel/plugins` # They can then be used by adding `plugin MyPlugin` to # either an environment, or release definition, where # `MyPlugin` is the name of the plugin module. ~w(rel plugins *.exs) |> Path.join() |> Path.wildcard() |> Enum.map(&Code.eval_file(&1)) use Mix.Releases.Config, # This sets the default release built by `mix release` default_release: :default, # This sets the default environment used by `mix release` default_environment: Mix.env() # For a full list of config options for both releases # and environments, visit https://hexdocs.pm/distillery/config/distillery.html # You may define one or more environments in this file, # an environment's settings will override those of a release # when building in that environment, this combination of release # and environment configuration is called a profile environment :dev do set cookie: :"SECRET" end environment :stag do set cookie: :"SECRET" end environment :prod do set cookie: :"SECRET" end # You may define one or more releases in this file. # If you have not set a default release, or selected one # when running `mix release`, the first release in the file # will be used by default release :balrog do set version: current_version(:balrog) set include_erts: false set include_src: false end ```

I will try to dig deeper into this tomorrow.

bitwalker commented 5 years ago

There hasn't been any change in behavior with regard to start_erl.data in a very long time - 2.0.12 would have failed at the same location as 2.0.14/2.0.x/master - it has not been supported to run Distillery on an entirely read-only system when not including ERTS (i.e. using host ERTS) in a long time, as Distillery's scripts have to detect the system ERTS, and write start_erl.data so the release can be booted.

But this issue got me wondering if start_erl.data could be moved to the mutable directory, and it turns out it can! So I've made that change in the 2.0.x branch. Would you be willing to test that branch in your environment and verify that it works as expected? My local testing looks good, but I would like to test in a "real" environment as well.

lasseebert commented 5 years ago

@bitwalker That sounds amazing. I will make a test as soon as possible.

For the record: My setup works fine with distillery 2.0.12 (deployed to multiple production units).

lasseebert commented 5 years ago

@bitwalker It works with the 2.0.x branch :tada:

Only difference in my project from 2.0.12 is that I have to create the $RELEASE_MUTABLE_DIR before starting the application (which makes sense, but I didn't do that before and it was created for me).

bitwalker commented 5 years ago

I'll publish 2.0.15 soon from that branch then!. It's expected that $RELEASE_MUTABLE_DIR exists, so even if the behavior before was that it took care of it, that was not intended. Thanks for reporting back so quickly!