-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
67 lines (50 loc) · 1.39 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
#
# Step 1 - build the OTP binary
#
FROM hexpm/elixir:1.13.3-erlang-24.2.2-alpine-3.15.0 AS otp-builder
ENV MIX_ENV=prod
WORKDIR /build
# Install Alpine dependencies
RUN apk update --no-cache && \
apk upgrade --no-cache && \
apk add --no-cache git build-base
# Install Erlang dependencies
RUN mix local.rebar --force && \
mix local.hex --force
# Install dependencies
COPY mix.* ./
RUN mix deps.get --only prod && \
mix deps.compile
# Compile codebase
COPY config config
COPY lib lib
COPY priv priv
RUN mix compile
# Build OTP release
RUN mix release
#
# Step 2 - build a lean runtime container
#
FROM alpine:3.15.0
ARG APP_NAME
ARG APP_VERSION
ENV APP_NAME=${APP_NAME} \
APP_VERSION=${APP_VERSION}
# Install Alpine dependencies
RUN apk update --no-cache && \
apk upgrade --no-cache && \
apk add --no-cache bash shadow su-exec openssl libgcc libstdc++
WORKDIR /opt/boreale
# Copy OTP binary from step 1
COPY --from=otp-builder /build/_build/prod/${APP_NAME}-${APP_VERSION}.tar.gz .
RUN tar -xvzf ${APP_NAME}-${APP_VERSION}.tar.gz && \
rm ${APP_NAME}-${APP_VERSION}.tar.gz
# Copy the entrypoint script
COPY docker-entrypoint.sh /usr/local/bin
RUN chmod a+x /usr/local/bin/docker-entrypoint.sh
COPY boreale-cli.sh bin/boreale-cli
RUN chmod u+x bin/boreale-cli
# Create a non-root user
RUN adduser -D boreale && chown -R boreale: /opt/boreale
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["start"]