-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathDockerfile
67 lines (45 loc) · 1.51 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
ARG ELIXIR_VERSION=1.17.2
ARG OTP_VERSION=27.1
ARG ALPINE_VERSION=3.20.3
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-alpine-${ALPINE_VERSION}"
ARG RUNNER_IMAGE="alpine:${ALPINE_VERSION}"
FROM ${BUILDER_IMAGE} AS base
ARG BUILD_ENV=prod
ENV MIX_ENV=$BUILD_ENV
ARG APP_NAME
ENV APP_NAME=${APP_NAME}
RUN echo "Build of $APP_NAME for $MIX_ENV environment started"
RUN apk update && \
apk add --no-cache build-base git openssh
RUN mix local.hex --force --if-missing && \
mix local.rebar --force --if-missing
WORKDIR /app
COPY mix.* ./
COPY config config
RUN mix do deps.get, deps.compile
COPY lib lib
COPY priv priv
FROM base AS dev
WORKDIR /app
COPY test test
COPY .formatter.exs .formatter.exs
COPY .credo.exs .credo.exs
CMD [ "/bin/ash", "-c \"while sleep 1000; do :; done\"" ]
FROM base AS builder
WORKDIR /app
RUN mix compile --warnings-as-errors
RUN mix release
FROM ${RUNNER_IMAGE} AS runner
HEALTHCHECK NONE
# This is needed to connect the GitHub Container Registry package with our repository.
LABEL org.opencontainers.image.source https://github.com/semaphoreio/semaphore
RUN apk update && \
apk add --no-cache \
git openssh-keygen openssl ncurses-libs libstdc++
# Create a non root user
RUN adduser -D default -h /app
USER default
WORKDIR /app
COPY --chown=default --from=builder /app/_build/prod/rel/scouter/ .
COPY --chown=default --from=builder /app/priv/repo/migrations /app/migrations
CMD ["sh", "-c", "bin/scouter eval \"Scouter.Release.migrate()\" && bin/scouter start"]