-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
140 lines (88 loc) · 2.57 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# syntax = docker/dockerfile:1.0-experimental
# This Dockerfile was generated by [dockerize](https://hex.pm/packages/dockerize)
# at 2021-05-13 17:59:54
# with `mix dockerize.init`
# It leverages multi-stage-building of docker to build as fast as possible.
# How stages work together: https://user-images.githubusercontent.com/43009/84713978-e59a2700-af9e-11ea-9bbd-9dcf28d23da7.png
# You are free to edit this dockerfile.
# -----------------------------------
# - stage: install
# - job: dependencies
# -----------------------------------
# see: https://github.com/qhwa/docker-elixir-builder
FROM qhwa/elixir-builder:latest AS deps
ARG MIX_ENV=prod
ARG HEX_MIRROR_URL=https://repo.hex.pm
WORKDIR /src
COPY config /src/config
COPY mix.exs mix.lock /src/
RUN mix deps.get --only $MIX_ENV
# -----------------------------------
# - stage: build
# - job: compile_deps
# -----------------------------------
FROM deps AS compile_deps
WORKDIR /src
ARG MIX_ENV=prod
ARG APPSIGNAL_HTTP_PROXY
RUN mix deps.compile
# -----------------------------------
# - stage: build
# - job: compile_app
# -----------------------------------
FROM compile_deps AS compile_app
WORKDIR /src
ARG MIX_ENV=prod
COPY lib/ ./lib
COPY priv/ ./priv
RUN mix compile
# -----------------------------------
# - stage: build
# - job: assets
# -----------------------------------
FROM deps AS assets
WORKDIR /src/assets
COPY assets/package.json assets/package-lock.json ./
ARG NPM_REGISTRY=https://registry.npmjs.com/
ARG APPSIGNAL_HTTP_PROXY
RUN npm \
--registry ${NPM_REGISTRY} \
--prefer-offline \
--no-audit \
--ignore-scripts \
ci
ARG SASS_BINARY_SITE
RUN npm rebuild node-sass
COPY assets/ ./
RUN npm run deploy
# -----------------------------------
# - stage: build
# - job: digest
# -----------------------------------
FROM compile_deps AS digest
WORKDIR /src
ARG MIX_ENV=prod
COPY --from=assets /src/priv ./priv
RUN mix phx.digest
# -----------------------------------
# - stage: release
# - job: mix_release
# -----------------------------------
FROM compile_app AS mix_release
WORKDIR /src
ARG MIX_ENV=prod
COPY --from=digest /src/priv/static ./priv/static
RUN mix release --path /app --quiet
# -----------------------------------
# - stage: release
# - job: release_image
# -----------------------------------
# See: https://github.com/qhwa/docker-elixir-runner
FROM qhwa/elixir-runner:latest AS release_image
ARG APP_REVISION=latest
ARG MIX_ENV=prod
RUN chown nobody:nobody /app
USER nobody
COPY --from=mix_release --chown=nobody:nobody /app /app
ENTRYPOINT ["/app/bin/bonfire"]
CMD ["start"]