-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
64 lines (51 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
# The version of Alpine to use for the final image
# This should match the version of Alpine that the release-builder image uses
# https://github.com/bitwalker/alpine-erlang/blob/master/VERSION
ARG ALPINE_VERSION=3.13.2
# 1.11.0
FROM bitwalker/alpine-elixir-phoenix:1.11.3 as release-builder
ENV \
MIX_ENV=prod \
HOME=/app/
WORKDIR $HOME
RUN apk add --update alpine-sdk coreutils
# Download and compile Hex deps
COPY mix.exs mix.lock ./
COPY config ./config
RUN mix do \
deps.get --only prod, \
deps.compile
# Download npm deps
COPY package.json package-lock.json ./
RUN npm ci
# Compile backend app
COPY lib ./lib
COPY priv ./priv
RUN mix compile
# Compile frontend app
COPY . .
RUN npm run frontend-build && mix phx.digest
# Compile the release
RUN mix release
#
# Final image
#
FROM alpine:${ALPINE_VERSION}
LABEL maintainer="Kalda <[email protected]>"
EXPOSE 4000
ENV PORT=4000 \
MIX_ENV=prod \
SHELL=/bin/bash \
LANG=en_US.UTF-8 \
HOME=/app/ \
TERM=xterm
WORKDIR $HOME
# Copy the compiled release to this image
COPY --from=release-builder /app/_build/prod/rel/kalda ./
# Install OS deps and create unprivileged user to run app as
RUN apk add --no-cache openssl-dev bash libgcc curl \
&& adduser -S www-kalda \
&& chown --recursive www-kalda $HOME
USER www-kalda
# Run the app as the container starts
CMD ["/app/bin/kalda", "start"]