-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
62 lines (47 loc) · 1.29 KB
/
Dockerfile
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
ARG ELIXIR_VERSION=1.17.3
ARG ERLANG_VERSION=27.2
ARG DEBIAN_VERSION=bookworm-20241202-slim
FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-debian-${DEBIAN_VERSION} AS build
ENV LANG=C.UTF-8
# install build dependencies
RUN apt update && \
apt upgrade -y && \
apt install -y --no-install-recommends git build-essential nodejs yarnpkg && \
apt clean -y && rm -rf /var/lib/apt/lists/*
# prepare build dir
RUN mkdir /app
WORKDIR /app
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# set build ENV
ENV MIX_ENV=prod
# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix deps.get
RUN mix deps.compile
# build assets
COPY assets assets
RUN cd assets && yarnpkg install && yarnpkg run webpack --mode production
RUN mix phx.digest
# build project
COPY priv priv
COPY lib lib
RUN mix compile
# build release
COPY rel rel
RUN mix do sentry.package_source_code, release
# prepare release image
FROM debian:${DEBIAN_VERSION} AS app
RUN apt update && \
apt upgrade -y && \
apt install --no-install-recommends -y bash openssl && \
apt clean -y && rm -rf /var/lib/apt/lists/*
RUN mkdir /app
WORKDIR /app
COPY --from=build /app/_build/prod/rel/preview ./
RUN chown -R nobody: /app
USER nobody
ENV HOME=/app
ENV LANG=C.UTF-8