|
| 1 | +ARG BASE_IMAGE |
| 2 | +ARG NGINX_VERSION |
| 3 | + |
| 4 | + |
| 5 | +FROM ${BASE_IMAGE} as ngx_http_auth_jwt_builder_base |
| 6 | +LABEL stage=ngx_http_auth_jwt_builder |
| 7 | +RUN <<` |
| 8 | +apt-get update |
| 9 | +apt-get install -y curl build-essential |
| 10 | +` |
| 11 | + |
| 12 | + |
| 13 | +FROM ngx_http_auth_jwt_builder_base as ngx_http_auth_jwt_builder_module |
| 14 | +LABEL stage=ngx_http_auth_jwt_builder |
| 15 | +ENV PATH "${PATH}:/etc/nginx" |
| 16 | +ENV LD_LIBRARY_PATH=/usr/local/lib |
| 17 | +ARG NGINX_VERSION |
| 18 | +RUN <<` |
| 19 | + set -e |
| 20 | + apt-get install -y libjwt-dev libjwt0 libjansson-dev libjansson4 libpcre2-dev zlib1g-dev libpcre3-dev |
| 21 | + mkdir -p /root/build/ngx-http-auth-jwt-module |
| 22 | +` |
| 23 | +WORKDIR /root/build/ngx-http-auth-jwt-module |
| 24 | +ADD config ./ |
| 25 | +ADD src/*.h src/*.c ./src/ |
| 26 | +WORKDIR /root/build |
| 27 | +RUN <<` |
| 28 | + set -e |
| 29 | + mkdir nginx |
| 30 | + curl -O http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz |
| 31 | + tar -xzf nginx-${NGINX_VERSION}.tar.gz --strip-components 1 -C nginx |
| 32 | +` |
| 33 | +WORKDIR /root/build/nginx |
| 34 | +RUN <<` |
| 35 | + set -e |
| 36 | + BUILD_FLAGS='' |
| 37 | + MAJ=$(echo ${NGINX_VERSION} | cut -f1 -d.) |
| 38 | + MIN=$(echo ${NGINX_VERSION} | cut -f2 -d.) |
| 39 | + REV=$(echo ${NGINX_VERSION} | cut -f3 -d.) |
| 40 | + |
| 41 | + # NGINX 1.23.0+ changes cookies to use a linked list, and renames `cookies` to `cookie` |
| 42 | + if [ "${MAJ}" -gt 1 ] || [ "${MAJ}" -eq 1 -a "${MIN}" -ge 23 ]; then |
| 43 | + BUILD_FLAGS="${BUILD_FLAGS} --with-cc-opt='-DNGX_LINKED_LIST_COOKIES=1'" |
| 44 | + fi |
| 45 | + |
| 46 | + ./configure \ |
| 47 | + --prefix=/etc/nginx \ |
| 48 | + --sbin-path=/usr/sbin/nginx \ |
| 49 | + --modules-path=/usr/lib64/nginx/modules \ |
| 50 | + --conf-path=/etc/nginx/nginx.conf \ |
| 51 | + --error-log-path=/var/log/nginx/error.log \ |
| 52 | + --http-log-path=/var/log/nginx/access.log \ |
| 53 | + --pid-path=/var/run/nginx.pid \ |
| 54 | + --lock-path=/var/run/nginx.lock \ |
| 55 | + --http-client-body-temp-path=/var/cache/nginx/client_temp \ |
| 56 | + --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ |
| 57 | + --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ |
| 58 | + --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ |
| 59 | + --http-scgi-temp-path=/var/cache/nginx/scgi_temp \ |
| 60 | + --user=nginx \ |
| 61 | + --group=nginx \ |
| 62 | + --with-compat \ |
| 63 | + --with-debug \ |
| 64 | + --with-file-aio \ |
| 65 | + --with-threads \ |
| 66 | + --with-http_addition_module \ |
| 67 | + --with-http_auth_request_module \ |
| 68 | + --with-http_dav_module \ |
| 69 | + --with-http_flv_module \ |
| 70 | + --with-http_gunzip_module \ |
| 71 | + --with-http_gzip_static_module \ |
| 72 | + --with-http_mp4_module \ |
| 73 | + --with-http_random_index_module \ |
| 74 | + --with-http_realip_module \ |
| 75 | + --with-http_secure_link_module \ |
| 76 | + --with-http_slice_module \ |
| 77 | + --with-http_ssl_module \ |
| 78 | + --with-http_stub_status_module \ |
| 79 | + --with-http_sub_module \ |
| 80 | + --with-http_v2_module \ |
| 81 | + --with-mail \ |
| 82 | + --with-mail_ssl_module \ |
| 83 | + --with-stream \ |
| 84 | + --with-stream_realip_module \ |
| 85 | + --with-stream_ssl_module \ |
| 86 | + --with-stream_ssl_preread_module \ |
| 87 | + --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.25.4/debian/debuild-base/nginx-1.25.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' \ |
| 88 | + --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' \ |
| 89 | + --add-dynamic-module=../ngx-http-auth-jwt-module \ |
| 90 | + ${BUILD_FLAGS} |
| 91 | + # --with-openssl=/usr/local \ |
| 92 | +` |
| 93 | +RUN make modules |
| 94 | +RUN make install |
| 95 | +WORKDIR /usr/lib64/nginx/modules |
| 96 | +RUN cp /root/build/nginx/objs/ngx_http_auth_jwt_module.so . |
| 97 | +RUN rm -rf /root/build |
| 98 | +RUN adduser --system --no-create-home --shell /bin/false --group --disabled-login nginx |
| 99 | +RUN mkdir -p /var/cache/nginx /var/log/nginx |
| 100 | +WORKDIR /etc/nginx |
| 101 | + |
| 102 | +FROM ngx_http_auth_jwt_builder_module AS ngx_http_auth_jwt_nginx |
| 103 | +LABEL maintainer= "TeslaGov" email= "[email protected]" |
| 104 | +ARG NGINX_VERSION |
| 105 | +RUN <<` |
| 106 | + set -e |
| 107 | + |
| 108 | + apt-get update |
| 109 | + apt-get install -y libjansson4 libjwt0 |
| 110 | + apt-get clean |
| 111 | +` |
| 112 | +COPY <<` /etc/nginx/nginx.conf |
| 113 | +user nginx; |
| 114 | +pid /var/run/nginx.pid; |
| 115 | + |
| 116 | +load_module /usr/lib64/nginx/modules/ngx_http_auth_jwt_module.so; |
| 117 | + |
| 118 | +worker_processes 1; |
| 119 | + |
| 120 | +events { |
| 121 | + worker_connections 1024; |
| 122 | +} |
| 123 | + |
| 124 | +http { |
| 125 | + include mime.types; |
| 126 | + default_type application/octet-stream; |
| 127 | + |
| 128 | + log_format main '$$remote_addr - $$remote_user [$$time_local] "$$request" ' |
| 129 | + '$$status $$body_bytes_sent "$$http_referer" ' |
| 130 | + '"$$http_user_agent" "$$http_x_forwarded_for"'; |
| 131 | + |
| 132 | + access_log /var/log/nginx/access.log main; |
| 133 | + include conf.d/*.conf; |
| 134 | +} |
| 135 | +` |
| 136 | +ENTRYPOINT ["nginx", "-g", "daemon off;"] |
0 commit comments