-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.prod
194 lines (135 loc) · 4.24 KB
/
Dockerfile.prod
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# syntax=docker/dockerfile:1.4
# SPDX-FileCopyrightText: 2020-2024 Technostructures
# SPDX-License-Identifier: AGPL-3.0-only
# This Dockerfile was generated by [dockerize](https://hex.pm/packages/dockerize)
# at 2021-08-18 18:55:17
# 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.
# -----------------------------------
# Base Image #1: Elixir Builder
# - This is used for building later
# docker image, with a development
# toolset.
# -----------------------------------
FROM bitwalker/alpine-elixir-phoenix:1.15 AS elixir-builder
ENV MIX_ENV=prod
ENV AP_BASE_PATH=/
# If you're using a hex mirror:
# ARG HEX_MIRROR=https://my_hex_mirror
RUN mix local.hex --force
RUN mix local.rebar --force
RUN mkdir -p .config/rebar3 && \
echo '{plugins, [rebar3_hex]}.' > .config/rebar3/rebar.config
RUN /opt/mix/elixir/1-15/rebar3 plugins upgrade rebar3_hex
# -----------------------------------
# Base Image #2: Elixir Runner
# - Elixir Application Runner
# This is used as a simple operating
# system image to host your
# application
# -----------------------------------
FROM alpine:3.18 as elixir-runner
# You can add any libraries required by your application
# here:
# RUN apt-get update && \
# apt-get install -y \
# # If you're using `:crypto`, you'll need openssl installed \
# libssl-dev \
# locales
RUN apk add --no-cache openssl ncurses-libs libstdc++
# RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
# locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# -----------------------------------
# - stage: install
# - job: dependencies
# -----------------------------------
FROM elixir-builder AS deps
# If you're using a hex mirror:
# ARG HEX_MIRROR=https://my_hex_mirror
WORKDIR /src
COPY --link config /src/config
COPY --link mix.exs mix.lock /src/
COPY --link activity_pub/ ./activity_pub
COPY --link matrix_app_service/ ./matrix_app_service
COPY --link polyjuice_client/ ./polyjuice_client
# If inside an umbrella project, you also need to add all `mix.exs`
# e.g
# COPY apps/my_app_1/mix.exs /src/apps/my_app_1/mix.exs
# COPY apps/my_app_2/mix.exs /src/apps/my_app_2/mix.exs
# If you're using your own organization on hex.pm, uncomment the
# following lines:
# ARG HEX_AUTH_KEY
# RUN mix hex.organization auth my_org --key ${HEX_AUTH_KEY}
RUN mix deps.get --only $MIX_ENV
# -----------------------------------
# - stage: build
# - job: compile_deps
# -----------------------------------
FROM deps AS compile_deps
WORKDIR /src
RUN mix deps.compile
# -----------------------------------
# - stage: build
# - job: compile_app
# -----------------------------------
FROM compile_deps AS compile_app
WORKDIR /src
ARG MIX_ENV=prod
ARG AP_BASE_PATH=/
COPY --link lib/ ./lib
COPY --link priv/ ./priv
RUN mix compile
# -----------------------------------
# - stage: build
# - job: assets
# -----------------------------------
FROM deps AS assets
WORKDIR /src/assets
COPY --link assets/package.json assets/package-lock.json ./
ARG NPM_REGISTRY=https://registry.npmjs.com/
RUN npm \
--registry ${NPM_REGISTRY} \
--prefer-offline \
--no-audit \
--ignore-scripts \
ci
ARG SASS_BINARY_SITE
RUN npm rebuild node-sass
COPY --link assets/ ./
COPY --link lib/ ../lib
RUN npm run deploy
# -----------------------------------
# - stage: build
# - job: digest
# -----------------------------------
FROM compile_deps AS digest
WORKDIR /src
ARG MIX_ENV=prod
COPY --link --from=assets /src/priv ./priv
RUN mix phx.digest
# -----------------------------------
# - stage: release
# - job: mix_release
# -----------------------------------
FROM compile_app AS mix_release
WORKDIR /src
COPY --link --from=digest /src/priv ./priv
RUN mix release --path /app --quiet
# -----------------------------------
# - stage: release
# - job: release_image
# -----------------------------------
FROM elixir-runner AS release_image
ARG APP_REVISION=latest
RUN mkdir /app
RUN chown nobody:nogroup /app
USER nobody
COPY --from=mix_release --chown=nobody:nogroup /app /app
WORKDIR /app
ENTRYPOINT ["/app/bin/kazarma"]
CMD ["start"]