-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
61 lines (46 loc) · 1.15 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
FROM elixir:1.11.2-alpine AS builder
RUN apk add --no-cache yarn build-base
RUN mkdir /app
WORKDIR /app
# Mix env
ENV MIX_ENV=prod
# Cache elixir deps
ADD mix.exs mix.lock ./
RUN mix local.rebar
RUN mix local.hex --force
RUN mix do deps.get, deps.compile
# Same with node deps
COPY assets assets
RUN yarn --cwd assets install --force
COPY lib lib
COPY config config
COPY priv priv
# Run frontend build, compile, and digest assets
RUN yarn --cwd assets deploy && \
cd - && mix do compile, phx.digest
RUN mix release
# ---- Application Stage ----
FROM alpine AS app
ARG HOST
ARG PORT
ARG DB_URL
ARG BOT_TOKEN
ARG SECRET_KEY_BASE
ENV MIX_ENV=prod \
DB_URL=$DB_URL \
HOST=$HOST \
PORT=$PORT \
BOT_TOKEN=$BOT_TOKEN \
SECRET_KEY_BASE=$SECRET_KEY_BASE
# Intall needed packages
RUN apk add --no-cache openssl \
ncurses-libs postgresql-client curl
# Copy over the build artifact from the previous step and create a non root user
RUN adduser -D -h /home/lovelace lovelace
WORKDIR /home/lovelace
COPY --from=builder /app/_build .
RUN chown -R lovelace: ./prod
USER lovelace
COPY entrypoint.sh .
# Run the Phoenix app
CMD ["./entrypoint.sh"]