-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
82 lines (61 loc) · 1.32 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
72
73
74
75
76
77
78
79
80
81
82
# build elixir
FROM elixir:1.6.6-alpine as elixir-build
# install build dependencies
RUN apk add --update git
# prepare build dir
RUN mkdir /app
WORKDIR /app
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# set build ENV
ENV MIX_ENV=prod
# install mix dependencies
COPY api/mix.exs api/mix.lock ./
COPY api/config ./
RUN mix deps.get
RUN mix deps.compile
ENV SECRET_KEY_BASE `openssl rand -hex 64`
# build release
COPY api .
RUN mix release --no-tar --verbose
# build node
FROM node:8.11.3-alpine as node-build
RUN apk add --update yarn
RUN mkdir /app
WORKDIR /app
COPY web/package.json web/yarn.lock ./
RUN yarn
COPY web .
RUN yarn build
# run stage
FROM elixir:1.6.6-alpine
RUN apk add --update \
bash \
git \
nginx \
nodejs \
nodejs-npm
RUN npm install -g foreman
RUN mix local.hex --force && \
mix local.rebar --force
# add Procfile
RUN mkdir /app
WORKDIR /app
COPY Procfile.prod ./Procfile
COPY entrypoint.sh ./
# setup nginx
RUN mkdir -p /run/nginx
COPY nginx.conf /etc/nginx/nginx.conf
# setup the api application
RUN mkdir api
WORKDIR /app/api
ENV REPLACE_OS_VARS true
COPY --from=elixir-build /app/_build/prod/rel/api .
# setup the web application
WORKDIR /app
RUN mkdir web
WORKDIR /app/web
COPY --from=node-build /app .
WORKDIR /app
CMD ["./entrypoint.sh"]