Skip to main content
Skip to main content
🚧 Work in Progress

Customise Elixir runtime environment

Build Custom Runtime Images​

Zerops allows you to build custom runtime images (CRI) when the default base runtime images don't meet your Elixir application's requirements. This is an optional phase in the build and deploy pipeline.

Configuration​

Default Elixir Runtime Environment​

The default Elixir runtime environment contains:

  • Alpine 3.20
  • Selected version of Elixir when the runtime service was created
  • zCLI
  • Erlang, Elixir, Hex, Rebar and Git

When You Need a Custom Runtime Image​

If your Elixir application needs more than what's included in the default environment, you'll need to build a custom runtime image. Common scenarios include:

  • System packages for processing: When your app processes images, videos, or files (requiring packages like sudo apk add imagemagick)
  • Erlang libraries: When you need additional Erlang libraries not included by default
  • Native dependencies: When your Mix dependencies require system libraries that aren't in the default environment
  • Different base OS: When you need Ubuntu instead of Alpine for specific compatibility requirements
important

You should not include your application code in the custom runtime image, as your built/packaged code is deployed automatically into fresh containers.

Here are Elixir-specific examples of configuring custom runtime images in your zerops.yml:

Basic Elixir Setup​

run:
os: ubuntu
base: elixir@1.16
prepareCommands:
- sudo apt-get update
- sudo apt-get install -y imagemagick
- mix local.hex --force
- mix archive.install hex phx_new

Using Build Files in Runtime Preparation​

build:
addToRunPrepare:
- mix.exs
- mix.lock
run:
prepareCommands:
- sudo apk add imagemagick
- mix deps.get

For complete configuration details, see the runtime prepare phase configuration guide.

Process and Caching​

How Runtime Prepare Works​

The runtime prepare process follows the same steps for all runtimes. See how runtime prepare works for the complete process details.

Caching Behavior​

Zerops caches custom runtime images to optimize deployment times. Learn about custom runtime image caching including when images are cached and reused.

Build Management​

For information about managing builds and deployments, see managing builds and deployments.

Warning

Shared storage mounts are not available during the runtime prepare phase.

Troubleshooting​

If your prepareCommands fail, check the prepare runtime log for specific error messages.