1
- ARG BASE_IMAGE
1
+ ARG BASE_IMAGE=${:?required}
2
2
ARG NGINX_VERSION
3
+ ARG LIBJWT_VERSION
3
4
4
- FROM ${BASE_IMAGE} AS ngx_http_auth_jwt_builder_base
5
+ FROM ${BASE_IMAGE} AS ngx_http_auth_jwt_builder
5
6
LABEL stage=ngx_http_auth_jwt_builder
6
- RUN chmod 1777 /tmp
7
+ ENV PATH="${PATH}:/etc/nginx"
8
+ ENV LD_LIBRARY_PATH=/usr/local/lib
9
+ ARG NGINX_VERSION
10
+ ARG LIBJWT_VERSION
11
+
7
12
RUN <<`
8
- apt-get update
9
- apt-get install -y curl build-essential
13
+ set -e
14
+ apt-get update
15
+ apt-get upgrade -y
10
16
`
11
17
12
- FROM ngx_http_auth_jwt_builder_base AS ngx_http_auth_jwt_builder_module
13
- LABEL stage=ngx_http_auth_jwt_builder
14
- ENV PATH "${PATH}:/etc/nginx"
15
- ENV LD_LIBRARY_PATH=/usr/local/lib
16
- ARG NGINX_VERSION
18
+ RUN apt-get install -y curl git zlib1g-dev libpcre3-dev build-essential libpcre2-dev zlib1g-dev libpcre3-dev pkg-config cmake dh-autoreconf
19
+
20
+ WORKDIR /root/build/libjansson
17
21
RUN <<`
18
22
set -e
19
- apt-get install -y libjwt-dev libjwt0 libjansson-dev libjansson4 libpcre2-dev zlib1g-dev libpcre3-dev
20
- mkdir -p /root/build/ngx-http-auth-jwt-module
23
+ git clone --depth 1 --branch v2.14 https://github.com/akheron/jansson .
24
+ cmake . -DJANSSON_BUILD_SHARED_LIBS=1 -DJANSSON_BUILD_DOCS=OFF
25
+ make
26
+ make check
27
+ make install
21
28
`
29
+
30
+ WORKDIR /root/build/libjwt
31
+ RUN <<`
32
+ set -e
33
+ git clone --depth 1 --branch v${LIBJWT_VERSION} https://github.com/benmcollins/libjwt .
34
+ autoreconf -i
35
+ ./configure
36
+ make all
37
+ make install
38
+ `
39
+
22
40
WORKDIR /root/build/ngx-http-auth-jwt-module
23
41
ADD config ./
24
42
ADD src/*.h src/*.c ./src/
@@ -29,6 +47,7 @@ RUN <<`
29
47
curl -O http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
30
48
tar -xzf nginx-${NGINX_VERSION}.tar.gz --strip-components 1 -C nginx
31
49
`
50
+
32
51
WORKDIR /root/build/nginx
33
52
RUN <<`
34
53
set -e
@@ -89,30 +108,46 @@ RUN <<`
89
108
${BUILD_FLAGS}
90
109
# --with-openssl=/usr/local \
91
110
`
111
+
92
112
RUN make modules
93
113
RUN make install
94
- WORKDIR /usr/lib64/nginx/modules
95
- RUN cp /root/build/nginx/objs/ngx_http_auth_jwt_module.so .
114
+
115
+ WORKDIR /usr/lib/nginx/modules
116
+ RUN mv /root/build/nginx/objs/ngx_http_auth_jwt_module.so .
96
117
RUN rm -rf /root/build
97
- RUN adduser --system --no-create-home --shell /bin/false --group --disabled-login nginx
98
- RUN mkdir -p /var/cache/nginx /var/log/nginx
99
- WORKDIR /etc/nginx
100
118
101
- FROM ngx_http_auth_jwt_builder_module AS ngx_http_auth_jwt_nginx
102
- LABEL maintainer=
"TeslaGov" email=
"[email protected] "
103
- ARG NGINX_VERSION
104
119
RUN <<`
105
120
set -e
106
-
107
- apt-get update
108
- apt-get install -y libjansson4 libjwt0
121
+ apt-get remove -y curl git zlib1g-dev libpcre3-dev build-essential libpcre2-dev zlib1g-dev libpcre3-dev pkg-config cmake dh-autoreconf
122
+ # apt-get install -y gnupg2 ca-certificates lsb-release debian-archive-keyring
109
123
apt-get clean
110
124
`
125
+
126
+ RUN <<`
127
+ set -e
128
+ groupadd nginx
129
+ useradd -g nginx nginx
130
+ `
131
+
132
+ # RUN <<`
133
+ # set -e
134
+ # curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor > /usr/share/keyrings/nginx-archive-keyring.gpg
135
+ # printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/debian `lsb_release -cs` nginx\n" > /etc/apt/sources.list.d/nginx.list
136
+ # printf "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" > /etc/apt/preferences.d/99nginx
137
+ # `
138
+
139
+ # RUN <<`
140
+ # set -e
141
+ # apt-get update
142
+ # apt-get install -y nginx
143
+ # `
144
+
111
145
COPY <<` /etc/nginx/nginx.conf
146
+ daemon off;
112
147
user nginx;
113
148
pid /var/run/nginx.pid;
114
149
115
- load_module /usr/lib64 /nginx/modules/ngx_http_auth_jwt_module.so;
150
+ load_module /usr/lib /nginx/modules/ngx_http_auth_jwt_module.so;
116
151
117
152
worker_processes 1;
118
153
@@ -124,12 +159,17 @@ http {
124
159
include mime.types;
125
160
default_type application/octet-stream;
126
161
127
- log_format main '$$ remote_addr - $$ remote_user [$$ time_local] "$ $request" '
128
- '$$ status $$ body_bytes_sent "$ $http_referer" '
129
- '"$$ http_user_agent" "$ $http_x_forwarded_for"' ;
162
+ log_format main '\$ remote_addr - \$ remote_user [\$ time_local] "\ $ request" '
163
+ '\$ status \$ body_bytes_sent "\ $ http_referer" '
164
+ '"\$ http_user_agent" "\ $ http_x_forwarded_for"' ;
130
165
131
166
access_log /var/log/nginx/access.log main;
132
167
include conf.d/*.conf;
133
168
}
134
169
`
135
- ENTRYPOINT ["nginx" , "-g" , "daemon off;" ]
170
+
171
+ WORKDIR /var/cache/nginx
172
+ RUN chown nginx:nginx .
173
+
174
+ WORKDIR /
175
+ CMD ["nginx" ]
0 commit comments