-
Notifications
You must be signed in to change notification settings - Fork 38
/
Dockerfile
67 lines (55 loc) · 1.55 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
# Base image
FROM nginx:1.27.1-alpine3.20 as base
# Build image
FROM base as builder
ARG JWT_MODULE_PATH=/usr/local/lib/ngx-http-auth-jwt-module
ARG LIBJWT_VERSION=1.17.1
RUN mkdir -p $JWT_MODULE_PATH/src
RUN apk add --no-cache \
# nginx
gcc \
libc-dev \
make \
openssl-dev \
pcre-dev \
zlib-dev \
linux-headers \
curl \
gnupg \
libxslt-dev \
gd-dev \
# libjwt
jansson-dev \
autoconf \
automake \
libtool \
cmake \
check-dev
# BEGIN libjwt install
RUN mkdir libjwt \
&& curl -sL https://github.com/benmcollins/libjwt/archive/v${LIBJWT_VERSION}.tar.gz \
| tar -zx -C libjwt/ --strip-components=1 \
&& cd libjwt \
&& autoreconf -i \
&& ./configure \
&& make all \
&& make check \
&& make install
RUN curl -fSL http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz -o nginx.tar.gz \
&& mkdir -p /usr/src \
&& tar -zxC /usr/src -f nginx.tar.gz \
&& rm nginx.tar.gz
ADD config $JWT_MODULE_PATH/config
ADD src $JWT_MODULE_PATH/src
RUN cd /usr/src/nginx-${NGINX_VERSION} \
&& ./configure --with-compat --add-dynamic-module=$JWT_MODULE_PATH \
&& make modules
# Final image
FROM base as jwt-nginx
ARG LIBJWT=libjwt.so.2.10.1
COPY --from=builder /usr/src/nginx-${NGINX_VERSION}/objs/ngx_http_auth_jwt_module.so /usr/lib/nginx/modules/ngx_http_auth_jwt_module.so
COPY --from=builder /usr/local/lib/${LIBJWT} /lib
RUN apk add --no-cache jansson \
&& sed -i '1iload_module modules/ngx_http_auth_jwt_module.so;' /etc/nginx/nginx.conf \
&& ln -s /lib/${LIBJWT} /lib/libjwt.so.2 \
&& ln -s /lib/${LIBJWT} /lib/libjwt.so