1- ARG  BASE_IMAGE
1+ ARG  BASE_IMAGE=${:?required} 
22ARG  NGINX_VERSION
3+ ARG  LIBJWT_VERSION
34
4- FROM  ${BASE_IMAGE} AS ngx_http_auth_jwt_builder_base 
5+ FROM  ${BASE_IMAGE} AS ngx_http_auth_jwt_builder 
56LABEL  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+ 
712RUN  <<`
8- apt-get update
9- apt-get install -y curl build-essential
13+ 	set -e
14+ 	apt-get update
15+ 	apt-get upgrade -y
1016`
1117
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
1721RUN  <<`
1822	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
2128`
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+ 
2240WORKDIR  /root/build/ngx-http-auth-jwt-module
2341ADD  config ./
2442ADD  src/*.h src/*.c ./src/
@@ -29,6 +47,7 @@ RUN <<`
2947	curl -O http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
3048	tar -xzf nginx-${NGINX_VERSION}.tar.gz --strip-components 1 -C nginx
3149`
50+ 
3251WORKDIR  /root/build/nginx
3352RUN  <<`
3453	set -e
@@ -89,30 +108,46 @@ RUN <<`
89108		${BUILD_FLAGS}
90109		#  --with-openssl=/usr/local \
91110`
111+ 
92112RUN  make modules
93113RUN  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 .
96117RUN  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
100118
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
104119RUN  <<`
105120	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
109123	apt-get clean
110124`
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+ 
111145COPY  <<` /etc/nginx/nginx.conf
146+ daemon off;
112147user nginx;
113148pid /var/run/nginx.pid;
114149
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;
116151
117152worker_processes 1;
118153
@@ -124,12 +159,17 @@ http {
124159	include mime.types;
125160	default_type application/octet-stream;
126161
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"' ;
130165
131166	access_log /var/log/nginx/access.log main;
132167	include conf.d/*.conf;
133168}
134169`
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