-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
66 lines (51 loc) · 1.55 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
ARG ALPINE_VERSION=3.9
##################################################
## FRONTEND BUILDER ##
##################################################
FROM node:10.16.3-alpine AS frontend-builder
WORKDIR /app
ADD ./hippo-frontend /app/
RUN npm install
RUN npm run build
##################################################
## BACKEND BUILDER ##
##################################################
FROM elixir:1.9.1-alpine AS backend-builder
# we're always building using prod environment
ENV APP_NAME="hippo"
ENV MIX_ENV=prod
WORKDIR /app
# install the tools we need, but no overages
RUN apk update && \
apk upgrade --no-cache && \
apk add --no-cache \
git \
build-base && \
mix local.rebar --force && \
mix local.hex --force
# copy the application resouces
COPY ./hippo-backend .
# then copy the front-end artefacts to the Elixir layer
COPY --from=frontend-builder /app/build/ /app/priv/static/
# install and compile dependencies, then compile our app
RUN mix do deps.get, deps.compile, compile
# make a release
RUN mix release
##################################################
## FINAL IMAGE ##
##################################################
# build the application image
FROM alpine:${ALPINE_VERSION}
RUN apk update && \
apk add --no-cache \
bash \
openssl-dev
ENV APP_NAME="hippo"
# Expose for http traffic
EXPOSE 4000
WORKDIR /opt/app
# copy the artefacts from the builder image into /opt/app
COPY --from=backend-builder /app/_build/prod/rel/${APP_NAME} .
ADD start.sh .
# start command
CMD /opt/app/start.sh