Set up mix_gleam archive, gleam_stdlib, and gleeunit deps. Add Gleam compiler to all Dockerfiles, CI workflows, nix shell, and .tool-versions. Rewrite Numeric, QueryHelpers, and URLValidator from Elixir to Gleam with full ExUnit test coverage. Update all callers to use the Gleam modules directly via :towerops@module syntax. Remove duplicate sanitize_like/1 private functions in snmp.ex and trace.ex. Reviewed-on: graham/towerops-web#98
80 lines
2.5 KiB
Docker
80 lines
2.5 KiB
Docker
# Multi-stage base images for Towerops Phoenix app
|
|
# Pre-bakes all the setup from k8s/Dockerfile so app deploys are faster
|
|
#
|
|
# This image is designed to be rebuilt regularly to get latest security updates
|
|
|
|
ARG ELIXIR_VERSION=1.19.4
|
|
ARG OTP_VERSION=28.3
|
|
ARG DEBIAN_VERSION=trixie-20251229-slim
|
|
|
|
#
|
|
# BUILDER BASE IMAGE
|
|
# Pre-installs build dependencies, hex, and rebar so every deploy is faster
|
|
#
|
|
FROM docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION} AS builder
|
|
|
|
LABEL maintainer="towerops"
|
|
LABEL description="Elixir builder base with pre-installed build tools"
|
|
|
|
# Set parallel compilation
|
|
ENV MIX_OS_DEPS_COMPILE_PARTITION_COUNT=6
|
|
|
|
# Install build dependencies (matches k8s/Dockerfile builder stage exactly)
|
|
# This step takes ~30 seconds on every deploy, so we bake it in
|
|
RUN apt-get update \
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
git \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Gleam compiler
|
|
ARG GLEAM_VERSION=1.15.2
|
|
RUN curl -fsSL https://github.com/gleam-lang/gleam/releases/download/v${GLEAM_VERSION}/gleam-v${GLEAM_VERSION}-x86_64-unknown-linux-musl.tar.gz \
|
|
| tar xz -C /usr/local/bin/
|
|
|
|
# Install hex + rebar + mix_gleam archive (matches k8s/Dockerfile exactly)
|
|
# This step takes ~10 seconds on every deploy, so we bake it in
|
|
RUN mix local.hex --force \
|
|
&& mix local.rebar --force \
|
|
&& mix archive.install hex mix_gleam --force
|
|
|
|
# Set build ENV
|
|
ENV MIX_ENV="prod"
|
|
|
|
WORKDIR /app
|
|
|
|
#
|
|
# RUNTIME BASE IMAGE
|
|
# Pre-installs runtime dependencies and configures locale
|
|
#
|
|
FROM docker.io/debian:${DEBIAN_VERSION} AS runtime
|
|
|
|
LABEL maintainer="towerops"
|
|
LABEL description="Debian 13 runtime base with pre-installed system packages and locale"
|
|
|
|
# Install runtime dependencies (matches k8s/Dockerfile runner stage exactly)
|
|
# This step takes ~30-60 seconds on every deploy, so we bake it in
|
|
RUN apt-get update \
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get upgrade -y \
|
|
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
libstdc++6 \
|
|
openssl \
|
|
libncurses6 \
|
|
locales \
|
|
ca-certificates \
|
|
iputils-ping \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Configure locale (matches k8s/Dockerfile exactly)
|
|
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
|
|
&& locale-gen
|
|
|
|
ENV LANG=en_US.UTF-8
|
|
ENV LANGUAGE=en_US:en
|
|
ENV LC_ALL=en_US.UTF-8
|
|
|
|
# Set up /app directory (matches k8s/Dockerfile exactly)
|
|
WORKDIR "/app"
|
|
RUN chown nobody /app
|