|
1 |
| -FROM centos:7 |
| 1 | +ARG NGINX_VERSION=1.22.0 |
2 | 2 |
|
3 |
| -LABEL maintainer= "TeslaGov" email= "[email protected]" |
4 |
| - |
5 |
| -ARG NGINX_VERSION=1.16.1 |
6 |
| -ARG JANSSON_VERSION=2.13.1 |
7 |
| -ARG LIBJWT_VERSION=1.12.0 |
8 |
| - |
9 |
| -ENV LD_LIBRARY_PATH=/usr/local/lib |
10 |
| -ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/share/pkgconfig |
11 |
| - |
12 |
| -RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm |
13 |
| -RUN echo "" >>/etc/yum.repos.d/nginx.repo |
14 |
| -RUN echo "[nginx]" >>/etc/yum.repos.d/nginx.repo |
15 |
| -RUN echo "name=nginx repo" >>/etc/yum.repos.d/nginx.repo |
16 |
| -RUN echo "baseurl=https://nginx.org/packages/centos/7/x86_64/" >>/etc/yum.repos.d/nginx.repo |
17 |
| -RUN echo "gpgcheck=0" >>/etc/yum.repos.d/nginx.repo |
18 |
| -RUN echo "enabled=1" >>/etc/yum.repos.d/nginx.repo |
19 |
| - |
20 |
| -RUN yum -y update && \ |
21 |
| - yum -y groupinstall 'Development Tools' && \ |
22 |
| - yum -y install pcre-devel pcre zlib-devel openssl-devel wget cmake3 check-devel check && \ |
23 |
| - yum -y install nginx-$NGINX_VERSION |
24 |
| - |
25 |
| -# for compiling for epel7 |
26 |
| -RUN yum -y install libxml2 libxslt libxml2-devel libxslt-devel gd gd-devel perl-ExtUtils-Embed geoip geoip-devel google-perftools google-perftools-devel |
27 |
| - |
28 |
| -RUN mkdir -p /root/dl |
29 |
| -WORKDIR /root/dl |
30 | 3 |
|
31 |
| -# build jansson |
32 |
| -RUN wget https://github.com/akheron/jansson/archive/v$JANSSON_VERSION.zip && \ |
33 |
| - unzip v$JANSSON_VERSION.zip && \ |
34 |
| - rm v$JANSSON_VERSION.zip && \ |
35 |
| - ln -sf jansson-$JANSSON_VERSION jansson && \ |
36 |
| - cd /root/dl/jansson && \ |
37 |
| - cmake3 . -DJANSSON_BUILD_SHARED_LIBS=1 -DJANSSON_BUILD_DOCS=OFF && \ |
38 |
| - make && \ |
39 |
| - make check && \ |
40 |
| - make install |
| 4 | +FROM debian:bullseye-slim as BASE_IMAGE |
| 5 | +LABEL stage=builder |
| 6 | +RUN apt-get update \ |
| 7 | + && apt-get install -y curl build-essential |
41 | 8 |
|
42 |
| -# build libjwt |
43 |
| -RUN wget https://github.com/benmcollins/libjwt/archive/v$LIBJWT_VERSION.zip && \ |
44 |
| - unzip v$LIBJWT_VERSION.zip && \ |
45 |
| - rm v$LIBJWT_VERSION.zip && \ |
46 |
| - ln -sf libjwt-$LIBJWT_VERSION libjwt && \ |
47 |
| - cd /root/dl/libjwt && \ |
48 |
| - autoreconf -i && \ |
49 |
| - ./configure && \ |
50 |
| - make all && \ |
51 |
| - make install |
52 | 9 |
|
| 10 | +FROM BASE_IMAGE as BUILD_IMAGE |
| 11 | +LABEL stage=builder |
| 12 | +ENV LD_LIBRARY_PATH=/usr/local/lib |
| 13 | +ARG NGINX_VERSION |
53 | 14 | ADD . /root/dl/ngx-http-auth-jwt-module
|
54 |
| - |
55 |
| -# after 1.11.5 when compiling for a server that was compiled with --with-compat use this command |
56 |
| -# ./configure --with-compat --add-dynamic-module=../ngx-http-auth-jwt-module --with-cc-opt='-std=gnu99' |
57 |
| -# cp /root/dl/nginx/objs/ngx_http_auth_jwt_module.so /etc/nginx/modules/. |
58 |
| -# build nginx module against nginx sources |
59 |
| -# |
60 |
| -# 1.10.2 from nginx by default use config flags... I had to add the -std=c99 and could not achieve "binary compatibility" |
61 |
| -# ./configure --add-dynamic-module=../ngx-http-auth-jwt-module --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-file-aio --with-threads --with-ipv6 --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -std=c99' |
62 |
| -# |
63 |
| -# rh-nginx110 uses these config flags |
64 |
| -# ./configure --add-dynamic-module=../ngx-http-auth-jwt-module --prefix=/opt/rh/rh-nginx110/root/usr/share/nginx --sbin-path=/opt/rh/rh-nginx110/root/usr/sbin/nginx --modules-path=/opt/rh/rh-nginx110/root/usr/lib64/nginx/modules --conf-path=/etc/opt/rh/rh-nginx110/nginx/nginx.conf --error-log-path=/var/opt/rh/rh-nginx110/log/nginx/error.log --http-log-path=/var/opt/rh/rh-nginx110/log/nginx/access.log --http-client-body-temp-path=/var/opt/rh/rh-nginx110/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/opt/rh/rh-nginx110/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/opt/rh/rh-nginx110/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/opt/rh/rh-nginx110/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/opt/rh/rh-nginx110/lib/nginx/tmp/scgi --pid-path=/var/opt/rh/rh-nginx110/run/nginx/nginx.pid --lock-path=/var/opt/rh/rh-nginx110/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -std=c99' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' |
65 |
| -# |
66 |
| -# epel7 version 1.12.1 uses these config flags |
67 |
| -# ./configure --add-dynamic-module=../ngx-http-auth-jwt-module --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -std=gnu99' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' |
68 |
| -# |
69 |
| -# epel7 version 1.16.1 uses these config flags |
70 |
| -# ./configure --add-dynamic-module=../ngx-http-auth-jwt-module --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' |
71 |
| - |
72 |
| -# ARG CACHEBUST=1 |
73 |
| - |
74 |
| -RUN wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && \ |
75 |
| - tar -xzf nginx-$NGINX_VERSION.tar.gz && \ |
76 |
| - rm nginx-$NGINX_VERSION.tar.gz && \ |
77 |
| - ln -sf nginx-$NGINX_VERSION nginx && \ |
78 |
| - cd /root/dl/nginx && \ |
79 |
| - ./configure --with-compat --add-dynamic-module=../ngx-http-auth-jwt-module --with-cc-opt='-std=gnu99' && \ |
80 |
| - make modules && \ |
81 |
| - cp /root/dl/nginx/objs/ngx_http_auth_jwt_module.so /usr/lib64/nginx/modules/. |
82 |
| - |
83 |
| -# Get nginx ready to run |
84 |
| -COPY resources/nginx.conf /etc/nginx/nginx.conf |
85 |
| -COPY resources/test-jwt-nginx.conf /etc/nginx/conf.d/test-jwt-nginx.conf |
86 |
| -COPY resources/rsa_key_2048-pub.pem /etc/nginx/rsa-key.conf |
87 |
| -RUN rm -rf /usr/share/nginx/html |
88 |
| -RUN cp -r /root/dl/nginx/html /usr/share/nginx |
89 |
| -RUN cp -r /usr/share/nginx/html /usr/share/nginx/secure |
90 |
| -RUN cp -r /usr/share/nginx/html /usr/share/nginx/secure-rs256 |
91 |
| -RUN cp -r /usr/share/nginx/html /usr/share/nginx/secure-auth-header |
92 |
| -RUN cp -r /usr/share/nginx/html /usr/share/nginx/secure-no-redirect |
93 |
| -RUN cp -r /usr/share/nginx/html /usr/share/nginx/secure-rs256-file |
94 |
| - |
95 |
| -ENTRYPOINT ["/usr/sbin/nginx"] |
96 |
| - |
97 |
| -EXPOSE 8000 |
| 15 | +RUN set -x \ |
| 16 | + && apt-get install -y libjwt-dev libjwt0 libjansson-dev libjansson4 libpcre2-dev zlib1g-dev libpcre3-dev \ |
| 17 | + && mkdir -p /root/dl |
| 18 | +WORKDIR /root/dl |
| 19 | +RUN set -x \ |
| 20 | + && curl -O http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz \ |
| 21 | + && tar -xzf nginx-$NGINX_VERSION.tar.gz \ |
| 22 | + && rm nginx-$NGINX_VERSION.tar.gz \ |
| 23 | + && ln -sf nginx-$NGINX_VERSION nginx \ |
| 24 | + && cd /root/dl/nginx \ |
| 25 | + && ./configure --with-compat --add-dynamic-module=../ngx-http-auth-jwt-module \ |
| 26 | + && make modules |
| 27 | + |
| 28 | + |
| 29 | +FROM nginx:${NGINX_VERSION} |
| 30 | +LABEL stage=builder |
| 31 | +RUN apt-get update \ |
| 32 | + && apt-get -y install libjansson4 libjwt0 \ |
| 33 | + && cd /etc/nginx \ |
| 34 | + && cp nginx.conf nginx.conf.orig \ |
| 35 | + && sed -ri '/pid\s+\/var\/run\/nginx\.pid;$/a load_module \/usr\/lib64\/nginx\/modules\/ngx_http_auth_jwt_module\.so;' nginx.conf |
| 36 | + |
| 37 | + |
| 38 | +LABEL stage= |
| 39 | +LABEL maintainer= "TeslaGov" email= "[email protected]" |
| 40 | +COPY --from=BUILD_IMAGE /root/dl/nginx/objs/ngx_http_auth_jwt_module.so /usr/lib64/nginx/modules/ |
0 commit comments