Skip to content

Commit e019e20

Browse files
clean up & fix build process
1 parent df75972 commit e019e20

File tree

4 files changed

+143
-84
lines changed

4 files changed

+143
-84
lines changed

.github/workflows/make-releases.yml

+8-15
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
needs: meta
3030
strategy:
3131
matrix:
32-
# NGINX versions to build/test against
3332
nginx-version:
3433
- 1.20.2 # legacy
3534
- 1.22.1 # legacy
@@ -39,14 +38,6 @@ jobs:
3938
- 1.27.3 # mainline
4039
- 1.27.4 # mainline
4140

42-
# The following versions of libjwt are compatible:
43-
# * v1.0 - v1.12.0
44-
# * v1.12.1 - v1.14.0
45-
# * v1.15.0+
46-
# At the time of writing this:
47-
# * Debian and Ubuntu's repos have v1.10.2
48-
# * EPEL has v1.12.1
49-
# This compiles against each version prior to a breaking change and the latest release
5041
libjwt-version:
5142
- 1.12.0
5243
- 1.14.0
@@ -80,9 +71,10 @@ jobs:
8071
- name: Build jansson
8172
working-directory: ./jansson
8273
run: |
83-
cmake . -DJANSSON_BUILD_SHARED_LIBS=1 -DJANSSON_BUILD_DOCS=OFF && \
84-
make && \
85-
make check && \
74+
set -e
75+
cmake . -DJANSSON_BUILD_SHARED_LIBS=1 -DJANSSON_BUILD_DOCS=OFF
76+
make
77+
make check
8678
sudo make install
8779
8880
# TODO cache the build result so we don't have to do this every time?
@@ -96,9 +88,10 @@ jobs:
9688
- name: Build libjwt
9789
working-directory: ./libjwt
9890
run: |
99-
autoreconf -i && \
100-
./configure && \
101-
make all && \
91+
set -e
92+
autoreconf -i
93+
./configure
94+
make all
10295
sudo make install
10396
10497
- name: Download NGINX

nginx.dockerfile

+68-28
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
1-
ARG BASE_IMAGE
1+
ARG BASE_IMAGE=${:?required}
22
ARG 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
56
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+
712
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
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
1721
RUN <<`
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+
2240
WORKDIR /root/build/ngx-http-auth-jwt-module
2341
ADD config ./
2442
ADD 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+
3251
WORKDIR /root/build/nginx
3352
RUN <<`
3453
set -e
@@ -89,30 +108,46 @@ RUN <<`
89108
${BUILD_FLAGS}
90109
# --with-openssl=/usr/local \
91110
`
111+
92112
RUN make modules
93113
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 .
96117
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
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
104119
RUN <<`
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+
111145
COPY <<` /etc/nginx/nginx.conf
146+
daemon off;
112147
user nginx;
113148
pid /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

117152
worker_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

Comments
 (0)