-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.frontend
105 lines (81 loc) · 2.89 KB
/
Dockerfile.frontend
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
## BUILDER
# - bsd-compat-headers required for bcrypt
FROM elixir:1.11.2-alpine as builder
RUN apk add --no-cache \
gcc \
git \
make \
musl-dev \
bsd-compat-headers
RUN mix local.rebar --force && \
mix local.hex --force
## DEPS
FROM builder as deps
ARG MIX_ENV=staging
ENV MIX_ENV ${MIX_ENV}
RUN echo " ===> [debug] MIX_ENV=$MIX_ENV"
# Provide the release tag
ARG RELEASE_TAG
ENV RELEASE_TAG ${RELEASE_TAG}
RUN echo " ===> [debug] RELEASE_TAG=$RELEASE_TAG"
WORKDIR /app
COPY mix.* /app/
COPY apps/creators_portal_web/mix.* /app/apps/creators_portal_web/
COPY apps/video_tutorials_services/mix.* /app/apps/video_tutorials_services/
COPY apps/video_tutorials_data/mix.* /app/apps/video_tutorials_data/
COPY apps/video_tutorials_proxy/mix.* /app/apps/video_tutorials_proxy/
COPY apps/video_tutorials_web/mix.* /app/apps/video_tutorials_web/
COPY packages packages
RUN mix do deps.get --only $MIX_ENV, deps.compile
## FRONT-END - WEB
FROM node:14.4.0-alpine3.12 as frontend-creators-portal
WORKDIR /app
COPY apps/shared_assets /shared_assets
COPY apps/creators_portal_web/assets/package*.json /app/
COPY --from=deps /app/deps/phoenix /deps/phoenix
COPY --from=deps /app/deps/phoenix_html /deps/phoenix_html
COPY --from=deps /app/deps/phoenix_live_view /deps/phoenix_live_view
RUN npm ci
COPY apps/creators_portal_web/assets /app
RUN npm run deploy
## FRONT-END - BACKOFFICE
FROM node:14.4.0-alpine3.12 as frontend-video-tutorials
WORKDIR /app
COPY apps/shared_assets /shared_assets
COPY apps/video_tutorials_web/assets/package*.json /app/
COPY --from=deps /app/deps/phoenix /deps/phoenix
COPY --from=deps /app/deps/phoenix_html /deps/phoenix_html
COPY --from=deps /app/deps/phoenix_live_view /deps/phoenix_live_view
RUN npm ci
COPY apps/video_tutorials_web/assets /app
RUN npm run deploy
## RELEASER
FROM deps as releaser
WORKDIR /app
COPY config config
COPY apps apps
COPY --from=frontend-creators-portal /priv/static apps/creators_portal_web/priv/static
COPY --from=frontend-video-tutorials /priv/static apps/video_tutorials_web/priv/static
ENV MIX_ENV ${MIX_ENV}
RUN MIX_ENV=$MIX_ENV mix do phx.digest, release video_tutorials_frontend
## RUNNER
FROM alpine:3.11 as runner
# bash and openssl for Phoenix
# and curl to perform deployments on Heroku
RUN apk add --no-cache -U bash libssl1.1 openssl openssh curl python imagemagick postgresql-client
WORKDIR /app
# Provide a default for the MIX_ENV, see heroku.yml for more information
ARG MIX_ENV=staging
ENV PORT=4000 \
SHELL=/bin/bash
COPY --from=releaser /app/_build/$MIX_ENV/rel/video_tutorials_frontend .
RUN ln -s /app/bin/video_tutorials_frontend /app/bin/video_tutorials
# Copy shell scripts
COPY bin/ /app/bin
RUN \
adduser -s /bin/sh -u 1001 -G root -h /app -S -D default && \
chown -R 1001:0 /app
USER default
# EXPOSE is not used by Heroku, it uses the PORT env var and expose the same value
EXPOSE 4000
CMD ["/app/bin/video_tutorials", "start"]