forked from fholzer/docker-nginx-brotli
-
Notifications
You must be signed in to change notification settings - Fork 58
117 lines (87 loc) · 3.5 KB
/
dockerimage.yml
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
name: Docker Image CI
on:
push:
branches: [ master ]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# https://github.com/FiloSottile/mkcert#installation
- name: Install and setup mkcert
env:
MKCERT_VERSION: v1.4.3
run: |
set -x
sudo apt-get update && \
sudo apt-get install -y libnss3-tools
curl https://github.com/FiloSottile/mkcert/releases/download/${MKCERT_VERSION}/mkcert-${MKCERT_VERSION}-linux-amd64 --location --output /tmp/mkcert
chmod 744 /tmp/mkcert
sudo mv /tmp/mkcert /bin/mkcert
mkcert -install
- name: Create signed TLS certificates for localhost
run: |
mkcert -cert-file tests/localhost.crt -key-file tests/localhost.key localhost 0.0.0.0 ::1
# https://github.com/marketplace/actions/build-and-push-docker-images
- name: Build the Docker image
uses: docker/build-push-action@v6
with:
context: .
tags: macbre/nginx
cache-from: |
ghcr.io/macbre/nginx-http3:latest
- name: Lint the Dockerfile
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
- name: Inspect images
run: |
docker images | head -n3
- name: Are we running as non-root?
run: |
docker run --rm -t macbre/nginx whoami | grep nginx
- name: Run nginx -V and njs -v
run: |
docker run --rm -t macbre/nginx nginx -V | sed 's/\-\-/\n\t--/g' | tee
echo "njs v$(docker run -t macbre/nginx njs -v)"
- name: Serve a static asset
run: |
# expand commands
set -x
./run-docker.sh &
sleep 2; docker ps
curl -v --compressed localhost:8888 2>&1 | tee /tmp/out
grep --fixed-strings --invert-match -i '< Server: nginx' /tmp/out > /dev/null
grep --fixed-strings '< Content-Encoding: br' /tmp/out
grep --fixed-strings '<p>It works!</p>' /tmp/out
curl -v --compressed localhost:8888/FooBar 2>&1 | tee /tmp/out
grep --fixed-strings 'HTTP/1.1 301 Moved Permanently' /tmp/out
grep --fixed-strings '< x-rewrite: 1' /tmp/out
grep --fixed-strings '< Location: http://localhost/foobar' /tmp/out
- name: Check njs module
run: |
set -x
curl -v --compressed -H 'Host: njs' localhost:8888/hello 2>&1 | tee /tmp/out
grep --fixed-strings '< x-njs: 1' /tmp/out
grep 'Hello world from njs' /tmp/out
- name: http2 vs h3
run: |
set -x
curl -v --compressed https://localhost:8889 2>&1 | tee /tmp/h2
grep --fixed-strings '< HTTP/2 200' /tmp/h2
grep --fixed-strings --invert-match -i '< server: nginx' /tmp/h2 > /dev/null
grep --fixed-strings '<p>It works!</p>' /tmp/h2
docker run --rm --network host ghcr.io/macbre/curl-http3 \
curl -v --insecure https://localhost:8889 --http3 --max-time 5 2>&1 | tee /tmp/h3
grep --fixed-strings '< HTTP/3 200' /tmp/h3
grep --fixed-strings --invert-match -i '< server: nginx' /tmp/h3 > /dev/null
grep --fixed-strings '< alt-svc: h3=":8889"; ma=86400' /tmp/h3
grep --fixed-strings '< quic-status: h3' /tmp/h3
grep --fixed-strings '<p>It works!</p>' /tmp/h3
- name: Test njs command line
run: |
echo "console.log('Using njs v' + njs.version)" | docker run -i --rm macbre/nginx njs -q - | grep "Using njs v0.8.4"
- name: Show logs
if: always()
run: docker logs test_nginx