Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
256 lines (225 loc) · 11.6 KB
/
Copy pathDockerfile
File metadata and controls
256 lines (225 loc) · 11.6 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# syntax=docker/dockerfile:1.29.0@sha256:572cebbc2b15e6f84c077742952674889cb63cd5e9b80abdffcbe587b6f19183
FROM alpine:3.24.4@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf AS nginx
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
ARG LUAJIT_INC=/usr/include/luajit-2.1
ARG LUAJIT_LIB=/usr/lib
ARG AWSLC_VER=4378134b6206a0a0fa62f31367d0729ca0780e4c # v5.15.0
ARG NGINX_VER=6c42faed5ed3b296074dfe59dea3d9312118702f # release-1.31.10
ARG NB_VER=42fd8006b13f8a64f1a4ab8b84435c888cb35318 # 1.1.0
ARG NUB_VER=a09e2fe091c2729a0aee62a16d67d94f19c1ff86 # 1.1.0
ARG ZNM_VER=33324b7e365b65a0b157973c07d48a12b69749de # 0.2.0
ARG NHUZFM_VER=1dffe587aeb1346819a942367a961c4044df7f2c # 1.1.0
ARG NF_VER=70311f239ec1e88ff79c669d126d08532ddb8554 # v0.6.0
ARG HMNM_VER=e30b10e0bb1cfb042d76ba3a865410ff95d65660 # v0.42
ARG NDK_VER=bd44d16302273052d6005d7bdb55f74e23813de3 # v0.3.4
ARG LNM_VER=0b5ce7ed53591f212c73378a027dd65e7da3a932 # v0.10.32rc8
ARG NJS_VER=72e6a980b9bf2a28ae2d568bbc3b6830a5d7c39e # 1.0.2
ARG NAL_VER=c7cc57b2fdec647efa37883f96585058eda4382c # v1.4.0
ARG VTS_VER=38b8612527ecb003ea15cefe934f302cf1a7c27e # v0.2.7
ARG NNTLM_VER=3da77b0cb30e517dfee01d7e7f7d649144d24051 # master
WORKDIR /src
COPY patches /src/patches
COPY rootfs/usr/local/bin/git-clone-commit.sh /usr/local/bin/git-clone-commit.sh
RUN apk upgrade --no-cache -a && \
apk add --no-cache git clang lld compiler-rt llvm-libunwind-dev libc++-dev linux-headers cmake ninja make pkgconf llvm file \
libatomic_ops-dev pcre2-dev luajit-dev zlib-ng-dev brotli-dev zstd-dev libxslt-dev openldap-dev quickjs-ng-dev libmaxminddb-dev clang-dev
RUN for f in $(apk info --no-cache -qL libgcc-static libstdc++-dev); do rm -v /"$f"; done && \
echo "-fuse-ld=lld --rtlib=compiler-rt --unwindlib=libunwind -stdlib=libc++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE" | tee /etc/clang*/*.cfg
ARG CC=clang
ARG CXX=clang++
ARG LD=ld.lld
ARG AR=llvm-ar
ARG FLAGS
ARG CFLAGS="$FLAGS -m64 -O3 -pipe -flto=full -ffunction-sections -fdata-sections -fno-math-errno -ffp-contract=fast -fstack-clash-protection -fstack-protector-strong -fzero-call-used-regs=used-gpr -fstrict-flex-arrays=3 -ftrivial-auto-var-init=zero -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -fno-semantic-interposition -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wformat=2 -Werror=format-security"
ARG CXXFLAGS="$CFLAGS"
ARG LDFLAGS="-m64 -Wl,-s -Wl,-O2 -Wl,--lto-O3 -Wl,--icf=safe -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--sort-common -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,--no-copy-dt-needed-entries"
RUN git config --global advice.detachedHead false && \
git config --global init.defaultBranch main
RUN git-clone-commit.sh https://github.com/aws/aws-lc "$AWSLC_VER" /src/aws-lc && \
cd /src/aws-lc && \
git apply /src/patches/aws-lc/tls13-cipher-preference.patch && \
cmake /src/aws-lc -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DDISABLE_GO=ON -DDISABLE_PERL=ON -DBUILD_TESTING=OFF && \
ninja install
RUN git-clone-commit.sh https://github.com/nginx/nginx "$NGINX_VER" /src/nginx && \
cd /src/nginx && \
git apply /src/patches/nginx/*.patch && \
\
git-clone-commit.sh https://github.com/HanadaLee/ngx_http_brotli_module "$NB_VER" /src/ngx_http_brotli_module && \
git-clone-commit.sh https://github.com/HanadaLee/ngx_http_unbrotli_filter_module "$NUB_VER" /src/ngx_http_unbrotli_filter_module && \
git-clone-commit.sh https://github.com/HanadaLee/ngx_http_zstd_module "$ZNM_VER" /src/zstd-nginx-module && \
git-clone-commit.sh https://github.com/HanadaLee/ngx_http_unzstd_filter_module "$NHUZFM_VER" /src/ngx_http_unzstd_filter_module && \
git-clone-commit.sh https://github.com/aperezdc/ngx-fancyindex "$NF_VER" /src/ngx-fancyindex && \
cd /src/ngx-fancyindex && \
git apply /src/patches/ngx-fancyindex/close-headerfooter-files.patch && \
git-clone-commit.sh https://github.com/openresty/headers-more-nginx-module "$HMNM_VER" /src/headers-more-nginx-module && \
git-clone-commit.sh https://github.com/vision5/ngx_devel_kit "$NDK_VER" /src/ngx_devel_kit && \
git-clone-commit.sh https://github.com/openresty/lua-nginx-module "$LNM_VER" /src/lua-nginx-module && \
cd /src/lua-nginx-module && \
git apply /src/patches/lua-nginx-module/aws-lc.patch && \
\
git-clone-commit.sh https://github.com/nginx/njs "$NJS_VER" /src/njs && \
cd /src/njs && \
git apply /src/patches/njs/zlib-ng.patch && \
git-clone-commit.sh https://github.com/kvspb/nginx-auth-ldap "$NAL_VER" /src/nginx-auth-ldap && \
git-clone-commit.sh https://github.com/vozlt/nginx-module-vts "$VTS_VER" /src/nginx-module-vts && \
git-clone-commit.sh https://github.com/gabihodoroaga/nginx-ntlm-module "$NNTLM_VER" /src/nginx-ntlm-module
RUN cd /src/nginx && \
/src/nginx/auto/configure \
--build=NPMplus \
--user=root \
--group=root \
--with-debug \
--with-compat \
--with-threads \
--with-file-aio \
--with-libatomic \
--with-control-api \
--with-pcre \
--with-pcre-jit \
--without-select_module \
--without-poll_module \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-stream_geoip_module \
--with-http_v2_module \
--with-http_v3_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_sub_module \
--with-http_json_module \
--with-http_geoip_module \
--with-http_addition_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--add-module=/src/ngx_http_brotli_module \
--add-module=/src/ngx_http_unbrotli_filter_module \
--add-module=/src/zstd-nginx-module \
--add-module=/src/ngx_http_unzstd_filter_module \
--add-module=/src/ngx-fancyindex \
--add-module=/src/headers-more-nginx-module \
--add-module=/src/ngx_devel_kit \
--add-module=/src/lua-nginx-module \
--add-dynamic-module=/src/njs/nginx \
--add-dynamic-module=/src/nginx-auth-ldap \
--add-dynamic-module=/src/nginx-module-vts \
--add-dynamic-module=/src/nginx-ntlm-module \
--with-ld-opt="$LDFLAGS" && \
\
make -j "$(nproc)" install
RUN find /usr/local/nginx/modules -name "*.so" -exec llvm-strip -s {} \; && \
llvm-strip -s /usr/local/nginx/sbin/nginx && \
llvm-strip -s /usr/local/lib/libcrypto.so && \
llvm-strip -s /usr/local/lib/libssl.so && \
llvm-strip -s /usr/local/bin/bssl && \
\
find /usr/local/nginx/modules -name "*.so" -exec file {} \; && \
file /usr/local/nginx/sbin/nginx && \
file /usr/local/lib/libcrypto.so && \
file /usr/local/lib/libssl.so && \
file /usr/local/bin/bssl && \
/usr/local/nginx/sbin/nginx -V
FROM --platform="$BUILDPLATFORM" node:26.13.1-alpine3.24@sha256:6bd9ab43c0ec0190ca7b2d193906cb8b7edf6e7f4afa43ddeccd6452710bffb5 AS frontend
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
ARG NODE_ENV=production
ARG NODE_OPTIONS=--use-openssl-ca
WORKDIR /app
COPY frontend/package.json frontend/pnpm-lock.yaml frontend/pnpm-workspace.yaml /app/
RUN apk upgrade --no-cache -a && \
apk add --no-cache --virtual nodejs && \
apk add --no-cache pnpm brotli && \
pnpm install --frozen-lockfile
COPY frontend /app
RUN pnpm vite build && \
find /app/dist -type f ! -name "*.jpg" ! -name "*.png" -print0 | xargs -r0 -P "$(nproc)" -n 1 brotli -q 11 -sf
FROM --platform=$BUILDPLATFORM node:26.13.1-alpine3.24@sha256:6bd9ab43c0ec0190ca7b2d193906cb8b7edf6e7f4afa43ddeccd6452710bffb5 AS backend
ARG NODE_ENV=production
ARG NODE_OPTIONS=--use-openssl-ca
WORKDIR /app
COPY backend/package.json backend/pnpm-lock.yaml backend/pnpm-workspace.yaml /app/
RUN apk upgrade --no-cache -a && \
apk add --no-cache --virtual nodejs && \
apk add --no-cache pnpm && \
pnpm install --frozen-lockfile --prod && \
find /app/node_modules -name "*.map" -delete
COPY backend /app
FROM node:26.13.1-alpine3.24@sha256:6bd9ab43c0ec0190ca7b2d193906cb8b7edf6e7f4afa43ddeccd6452710bffb5 AS node
RUN apk upgrade --no-cache -a && \
apk add --no-cache binutils file && \
strip -s /usr/local/bin/node && \
file /usr/local/bin/node
FROM alpine:3.24.4@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
ENV NODE_ENV=production
ENV NODE_OPTIONS=--use-openssl-ca
ARG LRC_VER=8c8091a829fc5209980821c3845f936851d5c5e5 # v0.1.35rc3
ARG LRL_VER=3ff6300e68b73ba20e909c7d16bd839aef2e5a4b # v0.15
ARG LCSB_VER=92a8617ede3b781c33cd39e73734505597e318fd # main
ARG CERTBOT_VER=5.10.0
COPY --from=nginx /usr/local/nginx /usr/local/nginx
COPY --from=nginx /usr/local/bin/bssl /usr/local/bin/bssl
COPY --from=nginx /usr/local/lib/libssl.so /usr/local/lib/libssl.so
COPY --from=nginx /usr/local/lib/libcrypto.so /usr/local/lib/libcrypto.so
COPY --from=backend /app /app
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY rootfs /
COPY MIT.LICENSE /MIT.LICENSE
COPY COPYING /COPYING
WORKDIR /app
RUN apk upgrade --no-cache -a && \
apk add --no-cache tzdata tini dinit llvm-libunwind libc++ \
pcre2 luajit zlib-ng brotli zstd lua5.1-cjson libxml2 libldap quickjs-ng-libs libmaxminddb-libs \
curl coreutils findutils grep jq openssl shadow su-exec \
bash bash-completion nano \
logrotate goaccess \
luarocks5.1 git make \
libatomic libstdc++ \
python3 uv && \
\
luarocks-5.1 install lua-resty-http && \
luarocks-5.1 install lua-resty-string && \
luarocks-5.1 install lua-resty-openssl && \
sed -i 's|^local legacy_nids = {}$|C.ERR_clear_error()\n&|' /usr/local/share/lua/5.1/resty/openssl/pkey.lua && \
\
git config --global advice.detachedHead false && \
git config --global init.defaultBranch main && \
\
git-clone-commit.sh https://github.com/openresty/lua-resty-core "$LRC_VER" /src/lua-resty-core && \
cd /src/lua-resty-core && \
make -j "$(nproc)" install LUA_LIB_DIR=/usr/local/share/lua/5.1 && \
\
git-clone-commit.sh https://github.com/openresty/lua-resty-lrucache "$LRL_VER" /src/lua-resty-lrucache && \
cd /src/lua-resty-lrucache && \
make -j "$(nproc)" install LUA_LIB_DIR=/usr/local/share/lua/5.1 && \
\
git-clone-commit.sh https://github.com/crowdsecurity/lua-cs-bouncer "$LCSB_VER" /src/lua-cs-bouncer && \
mv /src/lua-cs-bouncer/lib/* /usr/local/share/lua/5.1 && \
mv /src/lua-cs-bouncer/templates/captcha.html /etc/captcha.html.original && \
mv /src/lua-cs-bouncer/templates/ban.html /etc/ban.html.original && \
\
cd && \
rm -vr /src /tmp/luarocks_local_cache-* && \
apk del --no-cache luarocks5.1 git make && \
\
uv venv --allow-existing /usr/local && \
uv pip install --no-cache certbot=="$CERTBOT_VER" && \
uv pip freeze | tee /etc/pip-constraints.txt && \
echo "certbot==$CERTBOT_VER" | tee /etc/pip-overrides.txt && \
\
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx && \
ln -s /app/password-reset.js /usr/local/bin/password-reset.js && \
ln -s /app/lib/ocsp.js /usr/local/bin/ocsp.js && \
ln -s /app/index.js /usr/local/bin/index.js && \
\
chmod +x /usr/local/bin/*
ENV UV_CONSTRAINT=/etc/pip-constraints.txt
ENV UV_OVERRIDE=/etc/pip-overrides.txt
COPY --from=frontend /app/dist /app/frontend
ENTRYPOINT ["tini", "--", "entrypoint.sh"]
HEALTHCHECK CMD ["healthcheck.sh"]
LABEL com.centurylinklabs.watchtower.monitor-only="true"
LABEL wud.watch="false"
LABEL wud.watch.digest="false"