On this page

Elixir

Guara Cloud fully supports Elixir applications, including frameworks like Phoenix, Ecto, and any other Elixir-based project. Elixir’s BEAM runtime provides fault-tolerant, highly concurrent applications ideal for real-time workloads.

Supported versions

The following Elixir versions are auto-detected by Buildpack:

  • Elixir 1.15
  • Elixir 1.16
  • Elixir 1.17

The version is determined from the elixir field in your mix.exs file. If no version is specified, the latest stable version is used.

# mix.exs
defmodule MyApp.MixProject do
  use Mix.Project

  def project do
    [
      app: :my_app,
      version: "0.1.0",
      elixir: "~> 1.17"
    ]
  end
end

Deploy with Dockerfile

A multi-stage build is the recommended approach for Elixir applications. It compiles your release in a full Elixir environment, then copies only the release into a minimal runtime image.

FROM elixir:1.17 AS builder

ENV MIX_ENV=prod

WORKDIR /app

RUN mix local.hex --force && mix local.rebar --force

COPY mix.exs mix.lock ./
RUN mix deps.get --only prod
RUN mix deps.compile

COPY . .
RUN mix assets.deploy 2>/dev/null || true
RUN mix release

FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y libstdc++6 openssl libncurses5 locales \
    && rm -rf /var/lib/apt/lists/*

RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LANG=en_US.UTF-8

WORKDIR /app
COPY --from=builder /app/_build/prod/rel/my_app ./

EXPOSE 4000

CMD ["bin/my_app", "start"]

Deploy with Buildpack

If your repository does not contain a Dockerfile, Guara Cloud automatically detects your Elixir project by the presence of a mix.exs file in the root directory.

The Buildpack will:

  1. Detect the Elixir and OTP version from mix.exs
  2. Install dependencies with mix deps.get
  3. Compile assets if a Phoenix project with assets is detected
  4. Build a Mix release with mix release
  5. Start the release binary

Port configuration

Your application must listen on the port configured in your service settings. For Phoenix applications, the default is 4000, but you can change it at any time in your service settings.

# config/runtime.exs
config :my_app, MyAppWeb.Endpoint,
  http: [port: String.to_integer(System.get_env("PORT") || "4000")],
  server: true

Example project structure

my-elixir-app/
  mix.exs
  mix.lock
  config/
    config.exs
    runtime.exs
  lib/
    my_app/
    my_app_web/
  priv/
  Dockerfile          # optional — omit to use Buildpack

Environment variables

These environment variables are commonly used with Elixir deployments:

VariableRecommended valueDescription
PORTSet by platformThe port your application must listen on
MIX_ENVprodEnsures the application compiles in production mode
SECRET_KEY_BASERandom 64+ charsSecret used for signing sessions and tokens in Phoenix
DATABASE_URLConnection stringPostgreSQL connection URL for Ecto
PHX_HOSTYour domainThe hostname used for URL generation in Phoenix

Common pitfalls