m_burg

m_burg

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.

First Post!

ConnorRigby

ConnorRigby

Nerves Core Team

I don’t do much work with Phoenix, but i know it is possible to deploy Elixir/Phoenix apps to a RO filesystem. That is how we deploy Nerves devices. We compile and build the release on a regular development machine and deploy the erlang release (which can in itself include erts removing the need to install erlang on your production machine)

Most Liked

OvermindDL1

OvermindDL1

The issue is that it looks like it’s being launched via mix instead of a release. mix is designed for development purposes, so it will often recompile a lot of things on every launch, especially as it dynamically loads modules.

Releases on the other hand don’t, they are static, and if build_embedded is on then all modules get statically loaded regardless (no hickups on first-loading of modules), etc… You always want to use a release.

chrismcg

chrismcg

Check you’ve changed the :my_app to your actual app name where @repos is defined in the example code.

m_burg

m_burg OP

You use Distillery for that, right? I’ll try that.

Last Post!

m_burg

m_burg OP

That was indeed the problem.

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
peck
Hi everyone. My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
Alvinkariuki
How Can I Optimise Compile Time Dependencies I have been building an elixir application for about 2 years now. Many modules and files ha...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews