-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
66 lines (55 loc) · 1.77 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
# syntax=docker/dockerfile:1
ARG ALPINE_VERSION=3.21
FROM alpine:${ALPINE_VERSION} AS nginx
### builder ###
FROM nginx AS builder
WORKDIR /build
RUN apk --no-cache upgrade \
&& apk --no-cache add \
curl \
gcc \
gd-dev \
geoip-dev \
jansson-dev \
libxslt-dev \
linux-headers \
make \
musl-dev \
nginx \
openssl-dev \
pcre-dev \
perl-dev \
zlib-dev \
&& nginx_version=$(nginx -v 2>&1 | sed 's/^[^0-9]*//') \
&& curl -sL -o nginx-${nginx_version}.tar.gz http://nginx.org/download/nginx-${nginx_version}.tar.gz \
&& tar -xf nginx-${nginx_version}.tar.gz \
&& mv nginx-${nginx_version} nginx
COPY config /build/
COPY src/ /build/src/
WORKDIR /build/nginx
RUN nginx_opt=$(nginx -V 2>&1 | tail -1 | sed -e "s/configure arguments://" -e "s| --add-dynamic-module=[^ ]*||g") \
&& ./configure \
${nginx_opt} \
--add-dynamic-module=../ \
--with-cc-opt='-DNGX_HTTP_HEADERS' \
&& make \
&& mkdir -p /usr/lib/nginx/modules \
&& cp objs/ngx_http_auth_jwt_module.so /usr/lib/nginx/modules/ \
&& mkdir -p /etc/nginx/modules \
&& echo 'load_module "/usr/lib/nginx/modules/ngx_http_auth_jwt_module.so";' > /etc/nginx/modules/auth_jwt.conf \
&& nginx -t
### nginx ###
FROM nginx
RUN apk --no-cache upgrade \
&& apk --no-cache add \
jansson \
nginx \
&& sed \
-e 's/^user /#user /' \
-e 's@^error_log .*$@error_log /dev/stderr warn;@' \
-e 's@access_log .*;$@access_log /dev/stdout main;@' \
-i /etc/nginx/nginx.conf
COPY --from=builder /usr/lib/nginx/modules/ngx_http_auth_jwt_module.so /usr/lib/nginx/modules/ngx_http_auth_jwt_module.so
COPY --from=builder /etc/nginx/modules/auth_jwt.conf /etc/nginx/modules/auth_jwt.conf
USER nginx
CMD ["nginx", "-g", "daemon off;"]