-
Notifications
You must be signed in to change notification settings - Fork 437
Expand file tree
/
Copy pathnginx-mainline.yaml
More file actions
520 lines (492 loc) · 18 KB
/
Copy pathnginx-mainline.yaml
File metadata and controls
520 lines (492 loc) · 18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
package:
name: nginx-mainline
# MAINLINE VERSIONS MUST USE ODD MINOR VERSIONS (e.g., 1.27.x, 1.29.x)
# Must also bump njs at the same time
version: "1.29.8"
epoch: 2
# HEY YOU! If you update/bump this package you NEED to go and update the equivilent nginx-otel package
description: HTTP and reverse proxy server (mainline version)
copyright:
- license: BSD-2-Clause
cpe:
vendor: f5
product: nginx
dependencies:
provides:
- nginx=${{package.full-version}}
# Let's ensure that we have config. This gets the default, but can also
# be override by users.
runtime:
- merged-usrsbin
- nginx-config
- wolfi-baselayout
resources:
cpu: "1"
memory: 4Gi
test-resources:
cpu: "1"
memory: 2Gi
environment:
contents:
packages:
- autoconf
- automake
- brotli-dev
- build-base
- busybox
- ca-certificates-bundle
- gd-dev
- geoip-dev
- libmaxminddb-dev
- libxml2-dev
- libxslt-dev
- luajit-dev
- ngx_brotli
- openssl-hardened-dev
- pcre2-dev
- perl-dev
- pkgconf
- zeromq-dev
- zlib-dev
var-transforms:
- from: ${{package.version}}
match: '^(\d+)\.(\d+)\.(\d+)'
replace: '$2'
to: minor-version
data:
- name: modules
items:
http_brotli_filter: "10"
http_brotli_static: "10"
http_geoip: "10"
http_image_filter: "10"
http_perl: "10"
http_xslt_filter: "10"
mail: "10"
stream_geoip: "10"
stream: "10"
# TODO look at adding extra modules like alpine does https://git.alpinelinux.org/aports/tree/main/nginx/APKBUILD#n149
# Also note the nginx inc config https://hg.nginx.org/pkg-oss/file/tip/alpine
pipeline:
- name: validate-mainline-version
runs: |
# Ensure mainline version is odd (e.g., 1.27.x, 1.29.x)
MINOR=${{vars.minor-version}}
if [ $((MINOR % 2)) -eq 0 ]; then
echo "ERROR: nginx-mainline must use odd minor versions (e.g., 1.27.x, 1.29.x)"
echo "Current version: ${{package.version}} has even minor version: $MINOR"
exit 1
fi
echo "Version validation passed: ${{package.version}} is a valid mainline version"
- uses: git-checkout
with:
repository: https://github.com/nginx/nginx.git
tag: release-${{package.version}}
expected-commit: 5eaf45f11e85459b52c18f876e69320df420ae29
destination: nginx-mainline
- name: configure
working-directory: nginx-mainline
runs: |
export LUAJIT_LIB="$(pkgconf --variable=libdir luajit)"
export LUAJIT_INC="$(pkgconf --variable=includedir luajit)"
./auto/configure \
--prefix=/var/lib/nginx \
--sbin-path=/usr/bin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/run/nginx.pid \
--lock-path=/run/nginx.lock \
--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 \
--with-perl_modules_path=/usr/lib/perl5/vendor_perl \
\
--user=nginx \
--group=nginx \
--with-threads \
--with-file-aio \
\
--with-compat \
\
--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_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_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-stream=dynamic \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-stream_ssl_preread_module \
--add-dynamic-module=/usr/src/ngx_brotli
- working-directory: nginx-mainline
runs: |
make -j$(nproc)
make DESTDIR=${{targets.destdir}} install
# Stash the configuration into a separate directory so that it's not part
# of the main package and hence configurable by users of -config
# subpackage. We install it separately below in a subpackage.
#
# Unfortunately, there's no way to install configuration into a separate
# directory that I could find.
mkdir pkg-config
mv ${{targets.destdir}}/etc/nginx pkg-config/
# Create parent location for tmp files
mkdir -p ${{targets.destdir}}/var/lib/nginx/tmp
- uses: strip
subpackages:
- name: nginx-mainline-mime-types
description: Nginx mime.types file
dependencies:
provides:
- nginx-mime-types=${{package.full-version}}
pipeline:
- working-directory: nginx-mainline
runs: |
mkdir -p ${{targets.subpkgdir}}/etc/nginx
mv ./pkg-config/nginx/mime.types ${{targets.subpkgdir}}/etc/nginx/
mv ./pkg-config/nginx/mime.types.default ${{targets.subpkgdir}}/etc/nginx/
test:
pipeline:
- runs: |
test -f /etc/nginx/mime.types
test -f /etc/nginx/mime.types.default
- uses: test/virtualpackage
with:
virtual-pkg-name: nginx-mime-types
real-pkg-name: ${{subpkg.name}}
- name: nginx-mainline-fastcgi-params
description: Nginx fastcgi_params file
dependencies:
provides:
- nginx-fastcgi-params=${{package.full-version}}
pipeline:
- working-directory: nginx-mainline
runs: |
mkdir -p ${{targets.subpkgdir}}/etc/nginx
mv ./pkg-config/nginx/fastcgi_params ${{targets.subpkgdir}}/etc/nginx/
mv ./pkg-config/nginx/fastcgi_params.default ${{targets.subpkgdir}}/etc/nginx/
mv ./pkg-config/nginx/fastcgi.conf ${{targets.subpkgdir}}/etc/nginx/
mv ./pkg-config/nginx/fastcgi.conf.default ${{targets.subpkgdir}}/etc/nginx/
test:
pipeline:
- runs: |
stat /etc/nginx/fastcgi_params
stat /etc/nginx/fastcgi_params.default
stat /etc/nginx/fastcgi.conf
stat /etc/nginx/fastcgi.conf.default
- uses: test/virtualpackage
with:
virtual-pkg-name: nginx-fastcgi-params
real-pkg-name: ${{subpkg.name}}
- name: nginx-mainline-scgi-params
description: Nginx scgi_params file
dependencies:
provides:
- nginx-scgi-params=${{package.full-version}}
pipeline:
- working-directory: nginx-mainline
runs: |
mkdir -p ${{targets.subpkgdir}}/etc/nginx
mv ./pkg-config/nginx/scgi_params ${{targets.subpkgdir}}/etc/nginx/
mv ./pkg-config/nginx/scgi_params.default ${{targets.subpkgdir}}/etc/nginx/
test:
pipeline:
- runs: |
stat /etc/nginx/scgi_params
stat /etc/nginx/scgi_params.default
- uses: test/virtualpackage
with:
virtual-pkg-name: nginx-scgi-params
real-pkg-name: ${{subpkg.name}}
- name: nginx-mainline-uwsgi-params
description: Nginx uwsgi_params file
dependencies:
provides:
- nginx-uwsgi-params=${{package.full-version}}
pipeline:
- working-directory: nginx-mainline
runs: |
mkdir -p ${{targets.subpkgdir}}/etc/nginx
mv ./pkg-config/nginx/uwsgi_params ${{targets.subpkgdir}}/etc/nginx/
mv ./pkg-config/nginx/uwsgi_params.default ${{targets.subpkgdir}}/etc/nginx/
test:
pipeline:
- runs: |
stat /etc/nginx/uwsgi_params
stat /etc/nginx/uwsgi_params.default
- uses: test/virtualpackage
with:
virtual-pkg-name: nginx-uwsgi-params
real-pkg-name: ${{subpkg.name}}
- name: nginx-mainline-config
description: Creates nginx config step that can then be overridden by users
dependencies:
runtime:
- merged-usrsbin
- nginx-mainline
- nginx-mainline-fastcgi-params
- nginx-mainline-mime-types
- nginx-mainline-scgi-params
- nginx-mainline-uwsgi-params
- wolfi-baselayout
provides:
- nginx-config=${{package.full-version}}
pipeline:
- working-directory: nginx-mainline
runs: |
# This was moved into ./pkg-config/etc/nginx so put it into the
# subpackage directory here.
mkdir -p ${{targets.subpkgdir}}/etc/nginx
cp -R ./pkg-config/nginx/* ${{targets.subpkgdir}}/etc/nginx/
# default error logs to standard error
sed -i 's/#error_log logs\/error.log;$/error_log stderr notice;/' ${{targets.subpkgdir}}/etc/nginx/nginx.conf
# and both access logs to stdout
sed -i 's/#access_log.*;$/access_log \/dev\/stdout;/' ${{targets.subpkgdir}}/etc/nginx/nginx.conf
test:
pipeline:
- uses: test/virtualpackage
with:
virtual-pkg-name: nginx-config
real-pkg-name: ${{subpkg.name}}
- name: ${{package.name}}-syslog-config
description: Creates nginx config with syslog logging
dependencies:
runtime:
- ${{package.name}}
- ${{package.name}}-fastcgi-params
- ${{package.name}}-mime-types
- ${{package.name}}-scgi-params
- ${{package.name}}-uwsgi-params
provides:
- nginx-config=${{package.full-version}}
pipeline:
- working-directory: nginx-mainline
runs: |
# This was moved into ./pkg-config/etc/nginx so put it into the
# subpackage directory here.
mkdir -p ${{targets.subpkgdir}}/etc/nginx
cp -R ./pkg-config/nginx/* ${{targets.subpkgdir}}/etc/nginx/
# default error logs to syslog
sed -i 's/#error_log logs\/error.log;$/error_log syslog:server=unix:\/dev\/log notice;/' ${{targets.subpkgdir}}/etc/nginx/nginx.conf
# and both access logs to syslog
sed -i 's/#access_log.*;$/access_log syslog:server=unix:\/dev\/log;/' ${{targets.subpkgdir}}/etc/nginx/nginx.conf
test:
pipeline:
- uses: test/virtualpackage
with:
virtual-pkg-name: nginx-config
real-pkg-name: ${{subpkg.name}}
- name: nginx-mainline-package-config
description: Config supplied in packaged nginx.org bundles at https://hg.nginx.org/pkg-oss/
dependencies:
runtime:
- merged-usrsbin
- nginx-mainline
- nginx-mainline-fastcgi-params
- nginx-mainline-mime-types
- nginx-mainline-scgi-params
- nginx-mainline-uwsgi-params
- wolfi-baselayout
provides:
- nginx-package-config=${{package.full-version}}
pipeline:
- runs: |
mkdir -p ${{targets.subpkgdir}}/etc/nginx/conf.d
install -m644 -D nginx.conf ${{targets.subpkgdir}}/etc/nginx/
install -m644 -D nginx.default.conf ${{targets.subpkgdir}}/etc/nginx/conf.d
# Follow Docker Image and link logs to to stdout/stderr
# https://github.com/nginxinc/docker-nginx/blob/73a5acae6945b75b433cafd0c9318e4378e72cbb/mainline/alpine-slim/Dockerfile#L106-L107
mkdir -p ${{targets.subpkgdir}}/var/log/nginx
ln -sf /dev/stdout ${{targets.subpkgdir}}/var/log/nginx/access.log
ln -sf /dev/stderr ${{targets.subpkgdir}}/var/log/nginx/error.log
# Package config has a different default location for html files, rather annoyingly
# Don't really like using a symlink here, but seems better than copying
mkdir -p ${{targets.subpkgdir}}/usr/share/nginx/html
ln -sf /var/lib/nginx/html/50x.html ${{targets.subpkgdir}}/usr/share/nginx/html/50x.html
ln -sf /var/lib/nginx/html/index.html ${{targets.subpkgdir}}/usr/share/nginx/html/index.html
- name: "Create templates directory"
runs: |
mkdir -p ${{targets.contextdir}}/etc/nginx/templates
test:
pipeline:
- uses: test/virtualpackage
with:
virtual-pkg-name: nginx-package-config
real-pkg-name: ${{subpkg.name}}
- name: nginx-mainline-openrc
description: nginx-mainline openrc init
pipeline:
- runs: |
mkdir -p "${{targets.subpkgdir}}"/etc/init.d/
install -Dm755 nginx.initd "${{targets.subpkgdir}}"/etc/init.d/nginx
dependencies:
runtime:
- merged-usrsbin
- wolfi-baselayout
test:
environment:
contents:
packages:
- nginx-mainline
- openrc
pipeline:
- uses: test/tw/contains-files
with:
files: /etc/init.d/nginx
- runs: |
addgroup -S nginx
adduser -S -G nginx -H -h /dev/null nginx
mkdir -p /run/openrc
touch /run/openrc/softlevel
rc-service nginx start
rc-service nginx status
rc-service nginx stop
- range: modules
name: nginx-mainline-mod-${{range.key}}
description: Nginx third-party module ${{range.key}}
dependencies:
provides:
- nginx-mod-${{range.key}}=${{package.full-version}}
runtime:
- merged-usrsbin
- perl-dev
- wolfi-baselayout
pipeline:
- runs: |
mkdir -p ${{targets.subpkgdir}}/usr/lib/nginx/modules
mkdir -p ${{targets.subpkgdir}}/etc/nginx/modules
# --modules-path is only used for installing modules, not loading them
mkdir -p ${{targets.subpkgdir}}/var/lib/nginx/
ln -sf /usr/lib/nginx/modules ${{targets.subpkgdir}}/var/lib/nginx/modules
mv ${{targets.destdir}}/usr/lib/nginx/modules/ngx_${{range.key}}_module.so ${{targets.subpkgdir}}/usr/lib/nginx/modules/
# TODO may need to rework the prefix here if we add other module subpackages like alpine does https://git.alpinelinux.org/aports/tree/main/nginx/APKBUILD#n417
echo "load_module \"modules/ngx_${{range.key}}_module.so\";" >> ${{targets.subpkgdir}}/etc/nginx/modules/${{range.value}}_${{range.key}}.conf
case ${{range.key}} in
http_perl)
mv ${{targets.destdir}}/usr/lib/perl5 ${{targets.subpkgdir}}/usr/lib/
;;
http_naxsi)
install -m644 -D naxsi-*/naxsi_config/naxsi_core.rules \
${{targets.subpkgdir}}/etc/nginx/naxsi_core.rules
;;
stream)
mkdir -p ${{targets.subpkgdir}}/etc/nginx/stream.d
install -m644 -D stream.conf ${{targets.subpkgdir}}/etc/nginx/stream.d/
;;
esac
test:
pipeline:
- uses: test/tw/ldd-check
- name: nginx-mainline-src
description: Nginx source code
dependencies:
runtime:
- merged-usrsbin
- nginx-mainline
- perl-dev
- wolfi-baselayout
provides:
- nginx-src-main=${{package.full-version}}
pipeline:
- runs: |
mkdir -p ${{targets.contextdir}}/usr/src/nginx
cp -r ./nginx-mainline/* ${{targets.contextdir}}/usr/src/nginx
ls -latr ${{targets.contextdir}}/usr/src/nginx
test:
pipeline:
- uses: test/tw/srcpackage
- name: ${{package.name}}-config-compat
description: Nginx config compatibility with upstream image
dependencies:
runtime:
- merged-usrsbin
- nginx-mainline
- wolfi-baselayout
pipeline:
- runs: |
mkdir -p ${{targets.subpkgdir}}/etc/nginx/conf.d
install -m644 -D nginx.default.conf ${{targets.subpkgdir}}/etc/nginx/conf.d/
ln -s /etc/nginx/conf.d/nginx.default.conf ${{targets.subpkgdir}}/etc/nginx/conf.d/default.conf
# test added by a robot (compat)
test:
pipeline:
- runs: |
readlink -v /etc/nginx/conf.d/default.conf
test:
environment:
accounts:
users:
- username: nginx
uid: 65532
groups:
- groupname: nginx
gid: 65532
contents:
packages:
- ${{package.name}}-config
- ${{package.name}}-config-compat
- ${{package.name}}-mod-stream
- curl
- wait-for-it
pipeline:
- name: Verify Nginx Version
runs: |
# Ensure Nginx is installed and shows the correct version
nginx -v || exit 1
- name: Check Main Configuration File
runs: |
# Verify the main configuration file exists and is formatted correctly
if [ ! -f /etc/nginx/nginx.conf ]; then
echo "nginx.conf not found!"
exit 1
fi
head -n 5 /etc/nginx/nginx.conf || exit 1
- name: Check Additional Configuration Files
runs: |
# Verify default and compatibility configuration files are present
if [ ! -f /etc/nginx/conf.d/nginx.default.conf ]; then
echo "nginx.default.conf not found!"
exit 1
fi
head -n 5 /etc/nginx/conf.d/nginx.default.conf || exit 1
- name: Start Nginx and Check Status
runs: |
# Start Nginx and check if it is running
nginx
nginx -t # Verify the configuration is valid
wait-for-it localhost:80 -t 30 # Wait for Nginx to be ready
curl -I http://localhost # Check if Nginx is serving a basic request
if [ -f /run/nginx.pid ]; then
kill $(cat /run/nginx.pid)
fi
- name: Check modules are installed/loadable
runs: |
sed -i '1i include /etc/nginx/modules/*.conf;' /etc/nginx/nginx.conf
nginx -t
update:
enabled: true
github:
identifier: nginx/nginx
use-tag: true
# MAINLINE VERSIONS MUST USE ODD MINOR VERSIONS (e.g., 1.27.x, 1.29.x)
tag-filter: release-1.29
strip-prefix: release-