-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
71 lines (54 loc) · 1.33 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
ARG ALPINE_VERSION=3.8
FROM elixir:1.9.4-alpine AS builder
ARG SLACK_TOKEN
ARG KOIN_BOT_ID
ARG APP_NAME
ARG APP_VSN
ARG MIX_ENV=prod
ARG SKIP_PHOENIX=true
ARG PHOENIX_SUBDIR=.
ENV APP_NAME=${APP_NAME} \
APP_VSN=${APP_VSN} \
HOME=/usr/src/alex-koin \
KOIN_BOT_ID=${KOIN_BOT_ID} \
MIX_ENV=${MIX_ENV} \
SLACK_TOKEN=${SLACK_TOKEN}
WORKDIR $HOME
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache \
build-base \
git \
nodejs \
yarn \
postgresql-client && \
mix local.rebar --force && \
mix local.hex --force
COPY . .
RUN mix do deps.get, deps.compile, compile
# This is for a PHOENIX frontend
RUN if [ ! "$SKIP_PHOENIX" = "true" ]; then \
cd ${PHOENIX_SUBDIR}/assets && \
yarn install && \
yarn deploy && \
cd .. && \
mix phx.digest; \
fi
RUN \
mkdir -p /opt/built && \
mix release --verbose && \
cp _build/${MIX_ENV}/rel/${APP_NAME}/releases/${APP_VSN}/${APP_NAME}.tar.gz /opt/built && \
cd /opt/built && \
tar -xzf ${APP_NAME}.tar.gz && \
rm ${APP_NAME}.tar.gz
FROM alpine:${ALPINE_VERSION}
ARG APP_NAME
RUN apk update && \
apk add --no-cache \
bash \
openssl-dev
ENV REPLACE_OS_VARS=true \
APP_NAME=${APP_NAME}
WORKDIR /opt/app
COPY --from=builder /opt/built .
CMD trap 'exit' INT; /opt/app/bin/${APP_NAME} foreground