-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile
87 lines (54 loc) · 1.54 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
81
82
83
84
85
86
87
# ---------------------------
# Base Image - elixir-builder
# ---------------------------
# NOTE: make sure these versions match in .tool-versions
# NOTE: make sure the alpine version matches down below
FROM docker.io/hexpm/elixir:1.18.1-erlang-27.2-alpine-3.21.1 AS elixir-builder
ARG MIX_ENV=prod
WORKDIR /src
# system updates
RUN mix do \
local.rebar --force,\
local.hex --force
RUN apk --update upgrade && \
apk add build-base git
# fetch deps
COPY config /src/config
COPY mix.exs mix.lock /src/
RUN mix deps.get --only $MIX_ENV && \
mix deps.compile && \
mix npm_deps.get
# compile apps
COPY lib/ ./lib
COPY priv/ ./priv
RUN mix compile
# build && deploy assets
COPY assets/ ./assets
RUN mix assets.deploy
# build release
RUN mix release --path /app --quiet
# --------------------------
# Base Image - elixir-runner
# --------------------------
FROM docker.io/alpine:3.21.1 as elixir-runner
ARG SHAKA_PACKAGER_VERSION=3.4.1
RUN apk --update upgrade && \
apk add openssl ncurses-libs libstdc++ ffmpeg curl
RUN curl -L \
-o /usr/local/bin/shaka-packager \
https://github.com/google/shaka-packager/releases/download/v$SHAKA_PACKAGER_VERSION/packager-linux-x64
RUN chmod +x /usr/local/bin/shaka-packager
# -------------
# Release image
# -------------
FROM elixir-runner AS release-image
ARG APP_REVISION=latest
ARG MIX_ENV=prod
ENV PHX_SERVER=true
COPY --from=elixir-builder --chown=nobody:nogroup /app /app
RUN mkdir -p /app/uploads
VOLUME /app/uploads
USER nobody
WORKDIR /app
ENTRYPOINT ["/app/bin/ambry"]
CMD ["start"]