forked from beyond-all-reason/teiserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
91 lines (72 loc) · 2.55 KB
/
Dockerfile
File metadata and controls
91 lines (72 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# This file is modeled after https://hexdocs.pm/phoenix/releases.html#containers
# and the build script from teiserver repo.
#
# This file is written in a way that tries to optimize caching of the build steps
# as much as possible. It is increasing the complexity of the file a bit.
#
# The image can be built with the following command from the teiserver repo root:
#
# sudo podman build -t teiserver -f .
#
# The release is copied and placed in the filesystem of the host, but it could be
# also run as a container with something like:
#
# sudo podman run --rm -it \
# --network=host \
# -v /etc/ssl/certs/teiserver.crt:/etc/ssl/certs/teiserver.crt:ro \
# -v /etc/ssl/certs/teiserver_full.crt:/etc/ssl/certs/teiserver_full.crt:ro \
# -v /etc/ssl/private/teiserver.key:/etc/ssl/private/teiserver.key:ro \
# -v /etc/ssl/dhparam.pem:/etc/ssl/dhparam.pem:ro \
# teiserver
#
ARG ELIXIR_VERSION=1.19.4
ARG OTP_VERSION=26.2.5.1
ARG DEBIAN_VERSION=trixie-20251208
ARG BUILDER_IMAGE="docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="docker.io/debian:${DEBIAN_VERSION}-slim"
FROM ${BUILDER_IMAGE} as builder
RUN apt-get update \
&& apt-get install --no-install-recommends --yes git make build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mix local.hex --force \
&& mix local.rebar --force
RUN mkdir /build
WORKDIR /build
ENV MIX_ENV="prod"
COPY mix.exs mix.lock ./
RUN mix deps.get
RUN mkdir config
COPY config/config.exs config/
# Need to also compiled dev to be able to compile static assets...
COPY config/dev.exs config/
RUN MIX_ENV=dev mix deps.compile
# Now time to compile dependencies for prod.
COPY config/prod.exs config/
RUN mix deps.compile
COPY priv priv
COPY assets assets
# The assets compilation works only in dev environment but files are needed for
# the prod one... https://github.com/beyond-all-reason/teiserver/issues/238
RUN MIX_ENV=dev mix assets.deploy
# Compile for prod
COPY lib lib
RUN mix compile
# Create release files
COPY config/runtime.exs config/
COPY rel rel
RUN mix release
FROM ${RUNNER_IMAGE}
RUN apt-get update \
&& apt-get install --no-install-recommends --yes libstdc++6 openssl libncurses6 locales tini \
&& apt-get clean \
&& 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
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
WORKDIR "/app"
ENV MIX_ENV="prod"
COPY --from=builder /build/_build/${MIX_ENV}/rel/teiserver ./
ENTRYPOINT ["tini", "--"]
CMD /app/bin/teiserver start