-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
71 lines (51 loc) · 1.52 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
FROM hexpm/elixir:1.11.3-erlang-23.2.2-alpine-3.12.1 AS base
WORKDIR /workspace
# Install build tools
RUN --mount=type=cache,id=apk,sharing=locked,target=/var/cache/apk \
apk add make gcc libc-dev
# Install Mix depedencies
RUN mix do local.rebar --force, local.hex --force
FROM base AS deps
# Define production build env
ENV MIX_ENV=prod
# Copy root Mix project
COPY mix.exs mix.lock ./
# Copy umbrella Mix projects
COPY apps/celestial/mix.exs apps/celestial/
COPY apps/celestial_gateway/mix.exs apps/celestial_gateway/
COPY apps/celestial_portal/mix.exs apps/celestial_portal/
COPY apps/celestial_web/mix.exs apps/celestial_web/
COPY apps/noslib/mix.exs apps/noslib/
COPY apps/nostalex/mix.exs apps/nostalex/
# Pull config
COPY config config
# Pull depedencies
RUN --mount=id=hex-cache,type=cache,target=/root/.hex \
mix do deps.get, deps.compile
FROM deps AS source
# Copy source
COPY apps apps
COPY rel rel
FROM source AS release
# Assemble release
RUN mix release
FROM alpine:3.11.3
# Install Erlang Runtime dependencies
RUN --mount=type=cache,id=apk,sharing=locked,target=/var/cache/apk \
apk add openssl ncurses-libs
WORKDIR /celestial
# Create application user
RUN adduser \
--disabled-password \
--gecos "Celestial" \
--shell "/sbin/nologin" \
--no-create-home \
celestial
USER celestial
# Set tmp directory
ENV RELEASE_TMP=/tmp/celestial
# Copy release assembly
COPY --from=release --chown=celestial /workspace/_build/prod/rel/celestial .
# Set entrypoint
ENTRYPOINT [ "/celestial/bin/celestial" ]
CMD [ "start" ]