-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (41 loc) · 1.05 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
# Step 1 - hex dependencies
#
FROM hexpm/elixir:1.13.2-erlang-24.2.1-alpine-3.15.0 AS otp-dependencies
WORKDIR /app
ENV MIX_ENV="prod"
# Install Alpine dependencies
RUN apk add --no-cache git && \
apk --no-cache add build-base
# Install Erlang dependencies
RUN mix local.rebar --force && \
mix local.hex --force
# Install hex dependencies
# COPY mix.* ./
COPY mix.exs mix.lock ./
RUN mix deps.get --only prod
RUN mix deps.compile
# Compile codebase
COPY config config
COPY lib lib
# Compile assets
COPY priv priv
COPY assets assets
RUN mix assets.deploy
RUN mix compile
# Build OTP release
COPY rel rel
RUN mix release
#
# Step 2 - build a lean runtime container
#
FROM alpine:3.15.0
# Install Alpine dependencies
RUN apk update --no-cache && \
apk upgrade --no-cache && \
apk add --no-cache bash openssl libgcc libstdc++ ncurses-libs
WORKDIR /app
RUN chown nobody /app
# Only copy the final release from the build stage
COPY --from=otp-dependencies --chown=nobody:root /app/_build/prod/rel/brasil_em_dados ./
USER nobody
CMD /app/bin/server