I am trying to build a Phoenix application for Sandstorm. Sandstorm runs instances of applications in containers, grains, that all have a read-only filesystem. The only writeable directory is /var
.
In order to prepare a grain a few scripts are run: setup.sh
, build.sh
, and launch.sh
.
setup.sh
is in charge of installing all the necessary dependencies in a VM to setup your development environment.
build.sh
prepares the sources for your application.
launch.sh
starts the actual grain.
In my build.sh
I simply run MIX_ENV=prod mix compile
to build my application. in launch.sh
I start it with MIX_ENV=prod PORT=4000 mix phx.server
.
When trying to start the application I get the following log output:
Compiling 5 files (.ex)
warning: redefining module HistorianWeb.PageController (current version loaded from _build/prod/lib/historian/ebin/Elixir.HistorianWeb.PageController.beam)
lib/historian_web/controllers/page_controller.ex:1
warning: redefining module HistorianWeb.Gettext (current version loaded from _build/prod/lib/historian/ebin/Elixir.HistorianWeb.Gettext.beam)
lib/historian_web/gettext.ex:1
warning: redefining module HistorianWeb.ErrorView (current version loaded from _build/prod/lib/historian/ebin/Elixir.HistorianWeb.ErrorView.beam)
lib/historian_web/views/error_view.ex:1
warning: redefining module HistorianWeb.LayoutView (current version loaded from _build/prod/lib/historian/ebin/Elixir.HistorianWeb.LayoutView.beam)
lib/historian_web/views/layout_view.ex:1
warning: redefining module HistorianWeb.PageView (current version loaded from _build/prod/lib/historian/ebin/Elixir.HistorianWeb.PageView.beam)
lib/historian_web/views/page_view.ex:1
** (File.Error) could not write to file "/opt/app/_build/prod/lib/historian/ebin/Elixir.HistorianWeb.PageView.beam": read-only file system
(elixir) lib/file.ex:953: File.write!/3
(mix) lib/mix/compilers/elixir.ex:560: anonymous fn/4 in Mix.Compilers.Elixir.write_manifest/5
(elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
(mix) lib/mix/compilers/elixir.ex:555: Mix.Compilers.Elixir.write_manifest/5
(mix) lib/mix/compilers/elixir.ex:198: Mix.Compilers.Elixir.compile_manifest/9
(mix) lib/mix/task.ex:316: Mix.Task.run_task/3
(mix) lib/mix/tasks/compile.all.ex:68: Mix.Tasks.Compile.All.run_compiler/2
(mix) lib/mix/tasks/compile.all.ex:52: Mix.Tasks.Compile.All.do_compile/4
Why does it need to compile more code? The fact that all the modules that are being redefined have the word view in their name suggests to me that this has something to do with templates.
Is there a way to compile this extra code before running the application? Or have it recompile without trying to write to the filesystem?
I am using Phoenix 1.3.4, because there are no SQLite adapters for Ecto 3 at the moment.