-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
80 lines (53 loc) · 1.34 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ARG ELIXIR_VERSION=1.11.0
ARG ERLANG_VERSION=23.1.1
ARG ALPINE_VERSION=3.12.0
ARG NODE_VERSION=14.13.1
# OTP env
# --------
FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION} AS otp-build
RUN apk --no-cache --update add \
build-base \
git && \
mix local.rebar --force && \
mix local.hex --force
# Deps builder
# ------------
FROM otp-build AS deps
ENV MIX_ENV=prod
WORKDIR /opt/app
COPY config config
COPY mix.* ./
RUN mix do deps.get --only=$MIX_ENV, deps.compile
# Assets builder
# ---------------
FROM node:${NODE_VERSION}-alpine AS assets-build
ENV NODE_ENV=prod
WORKDIR /opt/app
COPY --from=deps /opt/app/deps deps
COPY assets assets
RUN npm --prefix assets ci && npm run --prefix assets deploy
# Release builder
# ---------------
FROM deps AS release
ENV MIX_ENV=prod
WORKDIR /opt/app
COPY --from=assets-build /opt/app/priv/static priv/static
RUN mix phx.digest
COPY . .
RUN mix do compile, deps.compile sentry --force, release --quiet
# App final
# ---------
FROM alpine:${ALPINE_VERSION} AS app
ARG PORT=4000
ENV HOME=/opt/app
ENV PORT=${PORT}
RUN apk --no-cache --update add \
bash \
openssl
WORKDIR /opt/app
COPY --from=release /opt/app/_build/prod/rel/phoenix_starter ./
RUN chown -R nobody: /opt/app
USER nobody
EXPOSE ${PORT}
ENTRYPOINT ["/opt/app/docker-entrypoint.sh"]
CMD ["start"]