Skip to content

Commit f4f415c

Browse files
authored
ops: update dockerfile with new elixir version (#545)
1 parent cca102d commit f4f415c

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
erl_crash.dump
4141

4242
# Static artifacts - These should be fetched and built inside the Docker image
43+
# https://hexdocs.pm/phoenix/Mix.Tasks.Phx.Gen.Release.html#module-docker
4344
/assets/node_modules/
4445
/priv/static/assets/
4546
/priv/static/cache_manifest.json

Dockerfile

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian
22
# instead of Alpine to avoid DNS resolution issues in production.
33
#
4-
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
5-
# https://hub.docker.com/_/ubuntu?tab=tags
4+
# https://hub.docker.com/r/hexpm/elixir/tags?name=ubuntu
5+
# https://hub.docker.com/_/ubuntu/tags
66
#
77
# This file is based on these images:
88
#
99
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image
10-
# - https://hub.docker.com/_/debian?tab=tags&page=1&name=bullseye-20240701-slim - for the release image
10+
# - https://hub.docker.com/_/debian/tags?name=bookworm-20251103-slim - for the release image
1111
# - https://pkgs.org/ - resource for finding needed packages
12-
# - Ex: hexpm/elixir:1.17.2-erlang-27.0-debian-bullseye-20240701-slim
12+
# - Ex: docker.io/hexpm/elixir:1.19.1-erlang-28.1.1-debian-bookworm-20251103-slim
1313
#
14-
ARG ELIXIR_VERSION=1.17.2
15-
ARG OTP_VERSION=27.0
16-
ARG DEBIAN_VERSION=bullseye-20240701-slim
14+
ARG ELIXIR_VERSION=1.19.1
15+
ARG OTP_VERSION=28.1.1
16+
ARG DEBIAN_VERSION=bookworm-20251103-slim
1717

18-
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
19-
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
18+
ARG BUILDER_IMAGE="docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
19+
ARG RUNNER_IMAGE="docker.io/debian:${DEBIAN_VERSION}"
2020

21-
FROM ${BUILDER_IMAGE} as builder
21+
FROM ${BUILDER_IMAGE} AS builder
2222

2323
# install build dependencies
24-
RUN apt-get update -y && apt-get install -y build-essential git \
25-
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
24+
RUN apt-get update \
25+
&& apt-get install -y --no-install-recommends build-essential git \
26+
&& rm -rf /var/lib/apt/lists/*
2627

2728
# prepare build dir
2829
WORKDIR /app
2930

3031
# install hex + rebar
31-
RUN mix local.hex --force && \
32-
mix local.rebar --force
32+
RUN mix local.hex --force \
33+
&& mix local.rebar --force
3334

3435
# set build ENV
3536
ENV MIX_ENV="prod"
@@ -45,18 +46,20 @@ RUN mkdir config
4546
COPY config/config.exs config/${MIX_ENV}.exs config/
4647
RUN mix deps.compile
4748

49+
RUN mix assets.setup
50+
4851
COPY priv priv
4952

5053
COPY lib lib
5154

55+
# Compile the release
56+
RUN mix compile
57+
5258
COPY assets assets
5359

5460
# compile assets
5561
RUN mix assets.deploy
5662

57-
# Compile the release
58-
RUN mix compile
59-
6063
# Changes to config/runtime.exs don't require recompiling the code
6164
COPY config/runtime.exs config/
6265

@@ -65,18 +68,19 @@ RUN mix release
6568

6669
# start a new build stage so that the final image will only contain
6770
# the compiled release and other runtime necessities
68-
FROM ${RUNNER_IMAGE}
71+
FROM ${RUNNER_IMAGE} AS final
6972

70-
RUN apt-get update -y && \
71-
apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates \
72-
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
73+
RUN apt-get update \
74+
&& apt-get install -y --no-install-recommends libstdc++6 openssl libncurses5 locales ca-certificates \
75+
&& rm -rf /var/lib/apt/lists/*
7376

7477
# Set the locale
75-
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
78+
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
79+
&& locale-gen
7680

77-
ENV LANG en_US.UTF-8
78-
ENV LANGUAGE en_US:en
79-
ENV LC_ALL en_US.UTF-8
81+
ENV LANG=en_US.UTF-8
82+
ENV LANGUAGE=en_US:en
83+
ENV LC_ALL=en_US.UTF-8
8084

8185
WORKDIR "/app"
8286
RUN chown nobody /app

lib/safira/release.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ defmodule Safira.Release do
5555
end
5656

5757
defp load_app do
58-
Application.load(@app)
58+
# Many platforms require SSL when connecting to the database
59+
Application.ensure_all_started(:ssl)
60+
Application.ensure_loaded(@app)
5961
end
6062
end

0 commit comments

Comments
 (0)