Skip to content
This repository was archived by the owner on Jan 11, 2025. It is now read-only.

Commit 9ad72de

Browse files
linting
1 parent 726c21e commit 9ad72de

25 files changed

+1566
-1792
lines changed

.github/workflows/linter.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ jobs:
2222
uses: docker://github/super-linter:v3
2323
env:
2424
VALIDATE_ALL_CODEBASE: true
25+
DOCKERFILE_HADOLINT_FILE_NAME: .hadolint.yml

README.md

+62-25
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ Nginx 1.19+ with Lua support based on Alpine Linux, Amazon Linux, CentOS, Debian
2828
## Supported tags and respective `Dockerfile` links
2929

3030
<!-- START_SUPPORTED_TAGS -->
31-
- [`1`,`1.19`,`1.19.3`,`alpine`,`1-alpine`,`1.19-alpine`,`1.19.3-alpine`,`1-alpine3.12.1`,`1-alpine3.12.1`,`1.19-alpine3.12.1`,`1.19.3-alpine3.12.1`,`latest`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/alpine/3.12.1/Dockerfile)
32-
- [`amazonlinux`,`1-amazonlinux`,`1.19-amazonlinux`,`1.19.3-amazonlinux`,`1-amazonlinux2.0.20200722.0`,`1-amazonlinux2.0.20200722.0`,`1.19-amazonlinux2.0.20200722.0`,`1.19.3-amazonlinux2.0.20200722.0`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/amazonlinux/2.0.20200722.0/Dockerfile)
33-
- [`centos`,`1-centos`,`1.19-centos`,`1.19.3-centos`,`1-centoscentos8`,`1-centoscentos8`,`1.19-centoscentos8`,`1.19.3-centoscentos8`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/centos/centos8/Dockerfile)
34-
- [`debian`,`1-debian`,`1.19-debian`,`1-debian10.6`,`1-debian10.6`,`1.19.3-debian`,`1.19-debian10.6`,`1.19.3-debian10.6`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/debian/10.6/Dockerfile)
35-
- [`fedora`,`1-fedora`,`1-fedora33`,`1-fedora33`,`1.19-fedora`,`1.19-fedora33`,`1.19.3-fedora`,`1.19.3-fedora33`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/fedora/33/Dockerfile)
36-
- [`ubuntu`,`1-ubuntu`,`1.19-ubuntu`,`1-ubuntu20.04`,`1-ubuntu20.04`,`1.19.3-ubuntu`,`1.19-ubuntu20.04`,`1.19.3-ubuntu20.04`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/ubuntu/20.04/Dockerfile)
31+
- [`1`,`1.19`,`1.19.3`,`alpine`,`1-alpine`,`1.19-alpine`,`1.19.3-alpine`,`1-alpine3.12.1`,`1-alpine3.12.1`,`1.19-alpine3.12.1`,`1.19.3-alpine3.12.1`,`latest`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/alpine/3.12.1/Dockerfile)
32+
- [`amazonlinux`,`1-amazonlinux`,`1.19-amazonlinux`,`1.19.3-amazonlinux`,`1-amazonlinux2.0.20200722.0`,`1-amazonlinux2.0.20200722.0`,`1.19-amazonlinux2.0.20200722.0`,`1.19.3-amazonlinux2.0.20200722.0`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/amazonlinux/2.0.20200722.0/Dockerfile)
33+
- [`centos`,`1-centos`,`1.19-centos`,`1.19.3-centos`,`1-centoscentos8`,`1-centoscentos8`,`1.19-centoscentos8`,`1.19.3-centoscentos8`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/centos/centos8/Dockerfile)
34+
- [`debian`,`1-debian`,`1.19-debian`,`1-debian10.6`,`1-debian10.6`,`1.19.3-debian`,`1.19-debian10.6`,`1.19.3-debian10.6`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/debian/10.6/Dockerfile)
35+
- [`fedora`,`1-fedora`,`1-fedora33`,`1-fedora33`,`1.19-fedora`,`1.19-fedora33`,`1.19.3-fedora`,`1.19.3-fedora33`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/fedora/33/Dockerfile)
36+
- [`ubuntu`,`1-ubuntu`,`1.19-ubuntu`,`1-ubuntu20.04`,`1-ubuntu20.04`,`1.19.3-ubuntu`,`1.19-ubuntu20.04`,`1.19.3-ubuntu20.04`](https://github.com/fabiocicerchia/nginx-lua/blob/master/nginx/1.19.3/ubuntu/20.04/Dockerfile)
3737
<!-- END_SUPPORTED_TAGS -->
3838

3939
**Note:** The full list of supported/unsupported tags can be found on [`docs/TAGS.md`](https://github.com/fabiocicerchia/nginx-lua/blob/master/docs/TAGS.md).
4040

4141
## Quick reference (cont.)
4242

43-
- **Where to file issues:** [https://github.com/fabiocicerchia/nginx-lua/issues](https://github.com/fabiocicerchia/nginx-lua/issues)
44-
- **Supported architectures:** amd64
45-
- **Published image artifact details:** [repo-info repo's docs/metadata/ directory](https://github.com/fabiocicerchia/nginx-lua/tree/master/docs/examples) ([history](https://github.com/fabiocicerchia/nginx-lua/commits/master/docs/metadata)) (image metadata, transfer size, etc)
43+
- **Where to file issues:** [https://github.com/fabiocicerchia/nginx-lua/issues](https://github.com/fabiocicerchia/nginx-lua/issues)
44+
- **Supported architectures:** amd64
45+
- **Published image artifact details:** [repo-info repo's docs/metadata/ directory](https://github.com/fabiocicerchia/nginx-lua/tree/master/docs/examples) ([history](https://github.com/fabiocicerchia/nginx-lua/commits/master/docs/metadata)) (image metadata, transfer size, etc)
4646

4747
## What is nginx?
4848

@@ -111,12 +111,16 @@ Lua is a lightweight, high-level, multi-paradigm programming language designed p
111111
```console
112112
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d fabiocicerchia/nginx-lua
113113
```
114+
114115
Alternatively, a simple `Dockerfile` can be used to generate a new image that includes the necessary content (which is a much cleaner solution than the bind mount above):
116+
115117
```dockerfile
116118
FROM fabiocicerchia/nginx-lua
117119
COPY static-html-directory /usr/share/nginx/html
118120
```
121+
119122
Place this file in the same directory as your directory of content ("static-html-directory"), run `docker build -t some-content-nginx .`, then start your container:
123+
120124
```console
121125
$ docker run --name some-nginx -d some-content-nginx
122126
```
@@ -126,34 +130,43 @@ $ docker run --name some-nginx -d some-content-nginx
126130
```console
127131
$ docker run --name some-nginx -d -p 8080:80 some-content-nginx
128132
```
133+
129134
Then you can hit `http://localhost:8080` or `http://host-ip:8080` in your browser.
130135

131136
### Complex configuration
132137

133138
```console
134139
$ docker run --name my-custom-nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d fabiocicerchia/nginx-lua
135140
```
141+
136142
For information on the syntax of the nginx configuration files, see [the official documentation](http://nginx.org/en/docs/) (specifically the [Beginner's Guide](http://nginx.org/en/docs/beginners_guide.html#conf_structure)).
137143
If you wish to adapt the default configuration, use something like the following to copy it from a running nginx container:
144+
138145
```console
139146
$ docker run --name tmp-nginx-container -d fabiocicerchia/nginx-lua
140147
$ docker cp tmp-nginx-container:/etc/nginx/nginx.conf /host/path/nginx.conf
141148
$ docker rm -f tmp-nginx-container
142149
```
150+
143151
This can also be accomplished more cleanly using a simple `Dockerfile` (in `/host/path/`):
152+
144153
```dockerfile
145154
FROM fabiocicerchia/nginx-lua
146155
COPY nginx.conf /etc/nginx/nginx.conf
147156
```
157+
148158
If you add a custom `CMD` in the Dockerfile, be sure to include `-g daemon off;` in the `CMD` in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)!
149159
Then build the image with `docker build -t custom-nginx .` and run it as follows:
160+
150161
```console
151162
$ docker run --name my-custom-nginx-container -d custom-nginx
152163
```
164+
153165
#### Using environment variables in nginx configuration (new in 1.19)
154166

155167
Out-of-the-box, nginx doesn't support environment variables inside most configuration blocks. But this image has a function, which will extract environment variables before nginx starts.
156168
Here is an example using docker-compose.yml:
169+
157170
```yaml
158171
web:
159172
image: fabiocicerchia/nginx-lua
@@ -165,30 +178,41 @@ web:
165178
- NGINX_HOST=foobar.com
166179
- NGINX_PORT=80
167180
```
181+
168182
By default, this function reads template files in `/etc/nginx/templates/*.template` and outputs the result of executing `envsubst` to `/etc/nginx/conf.d`.
169183
So if you place `templates/default.conf.template` file, which contains variable references like this:
170-
listen ${NGINX_PORT};
184+
185+
```
186+
listen ${NGINX_PORT};
187+
```
188+
171189
outputs to `/etc/nginx/conf.d/default.conf` like this:
172-
listen 80;
190+
191+
```
192+
listen 80;
193+
```
194+
173195
This behavior can be changed via the following environment variables:
174-
- `NGINX_ENVSUBST_TEMPLATE_DIR`
175-
- A directory which contains template files (default: `/etc/nginx/templates`)
176-
- When this directory doesn't exist, this function will do nothing about template processing.
177-
- `NGINX_ENVSUBST_TEMPLATE_SUFFIX`
178-
- A suffix of template files (default: `.template`)
179-
- This function only processes the files whose name ends with this suffix.
180-
- `NGINX_ENVSUBST_OUTPUT_DIR`
181-
- A directory where the result of executing envsubst is output (default: `/etc/nginx/conf.d`)
182-
- The output filename is the template filename with the suffix removed.
183-
- ex.) `/etc/nginx/templates/default.conf.template` will be output with the filename `/etc/nginx/conf.d/default.conf`.
184-
- This directory must be writable by the user running a container.
196+
- `NGINX_ENVSUBST_TEMPLATE_DIR`
197+
- A directory which contains template files (default: `/etc/nginx/templates`)
198+
- When this directory doesn't exist, this function will do nothing about template processing.
199+
- `NGINX_ENVSUBST_TEMPLATE_SUFFIX`
200+
- A suffix of template files (default: `.template`)
201+
- This function only processes the files whose name ends with this suffix.
202+
- `NGINX_ENVSUBST_OUTPUT_DIR`
203+
- A directory where the result of executing envsubst is output (default: `/etc/nginx/conf.d`)
204+
- The output filename is the template filename with the suffix removed.
205+
- ex.) `/etc/nginx/templates/default.conf.template` will be output with the filename `/etc/nginx/conf.d/default.conf`.
206+
- This directory must be writable by the user running a container.
185207

186208
### Running nginx in read-only mode
187209

188210
To run nginx in read-only mode, you will need to mount a Docker volume to every location where nginx writes information. The default nginx configuration requires write access to `/var/cache` and `/var/run`. This can be easily accomplished by running nginx as follows:
211+
189212
```console
190213
$ docker run -d -p 80:80 --read-only -v $(pwd)/nginx-cache:/var/cache/nginx -v $(pwd)/nginx-pid:/var/run fabiocicerchia/nginx-lua
191214
```
215+
192216
If you have a more advanced configuration that requires nginx to write to other locations, simply add more volume mounts to those locations.
193217

194218
### Running nginx in debug mode
@@ -212,13 +236,15 @@ web:
212236
### Entrypoint quiet logs
213237

214238
Since version 1.19.0, a verbose entrypoint was added. It provides information on what's happening during container startup. You can silence this output by setting environment variable `NGINX_ENTRYPOINT_QUIET_LOGS`:
239+
215240
```console
216241
$ docker run -d -e NGINX_ENTRYPOINT_QUIET_LOGS=1 fabiocicerchia/nginx-lua
217242
```
218243

219244
### User and group id
220245

221246
Since 1.17.0, both alpine- and debian-based images variants use the same user and group ids to drop the privileges for worker processes:
247+
222248
```console
223249
$ id
224250
uid=101(nginx) gid=101(nginx) groups=101(nginx)
@@ -227,14 +253,19 @@ uid=101(nginx) gid=101(nginx) groups=101(nginx)
227253
### Running nginx as a non-root user
228254

229255
It is possible to run the image as a less privileged arbitrary UID/GID. This, however, requires modification of nginx configuration to use directories writeable by that specific UID/GID pair:
256+
230257
```console
231258
$ docker run -d -v $PWD/nginx.conf:/etc/nginx/nginx.conf fabiocicerchia/nginx-lua
232259
```
260+
233261
where nginx.conf in the current directory should have the following directives re-defined:
262+
234263
```nginx
235264
pid /tmp/nginx.pid;
236265
```
266+
237267
And in the http context:
268+
238269
```nginx
239270
http {
240271
client_body_temp_path /tmp/client_temp;
@@ -384,23 +415,29 @@ $ docker run -it --rm -p 80:80 \
384415
## Image Variants
385416

386417
### `fabiocicerchia/nginx-lua:<version>`
418+
387419
The default Nginx + Lua + extra lua modules image. Uses Alpine for base image.
388420

389421
### `fabiocicerchia/nginx-lua:<version>-<distro>`
422+
390423
Provides Nginx + Lua + extra lua modules. Uses Alpine, Amazon Linux, CentOS, Debian, Fedora, Ubuntu for base image.
391424

392425
### `fabiocicerchia/nginx-lua:<version>-<distro><version>`
426+
393427
Provides Nginx + Lua + extra lua modules. Uses pinned version for Alpine, Amazon Linux, CentOS, Debian, Fedora, Ubuntu for base image.
394428

395429
### `fabiocicerchia/nginx-lua:<version>-minimal`
430+
396431
Provides Nginx + Lua image. Uses Alpine for base image.
397432
**WARNING:** Not available as tag, need manual build, see [Minimal Image](#minimal-image)
398433

399434
### `fabiocicerchia/nginx-lua:<version>-<distro>-minimal`
435+
400436
Provides Nginx + Lua. Uses Alpine, Amazon Linux, CentOS, Debian, Fedora, Ubuntu for base image.
401437
**WARNING:** Not available as tag, need manual build, see [Minimal Image](#minimal-image)
402438

403439
### `fabiocicerchia/nginx-lua:<version>-<distro><version>-minimal`
440+
404441
Provides Nginx + Lua. Uses pinned version for Alpine, Amazon Linux, CentOS, Debian, Fedora, Ubuntu for base image.
405442
**WARNING:** Not available as tag, need manual build, see [Minimal Image](#minimal-image)
406443

@@ -524,9 +561,9 @@ More details about the benchark can be found in [docs/benchmarks/distros](docs/b
524561

525562
Extract of [openresty/lua-nginx-module](https://github.com/openresty/lua-nginx-module) under [BSD license](https://github.com/openresty/lua-nginx-module#copyright-and-license).
526563

527-
- [LUA Nginx Module - Known Issues](docs/lua-nginx-module/known-issues.md)
528-
- [LUA Nginx Module - Directives](docs/lua-nginx-module/directives.md)
529-
- [Nginx API for Lua](docs/lua-nginx-module/nginx-api-for-lua.md)
564+
- [LUA Nginx Module - Known Issues](docs/lua-nginx-module/known-issues.md)
565+
- [LUA Nginx Module - Directives](docs/lua-nginx-module/directives.md)
566+
- [Nginx API for Lua](docs/lua-nginx-module/nginx-api-for-lua.md)
530567

531568
![Lua Nginx Modules Directives](docs/lua-nginx-module/lua_nginx_modules_directives.png)
532569

bin/generate_tags.py

+40-26
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33
import re
44
import subprocess
55

6-
files = subprocess.getoutput('find nginx -type f | sort -V').splitlines()
6+
files = subprocess.getoutput("find nginx -type f | sort -V").splitlines()
77

8-
result = subprocess.run(['./bin/docker-supported.sh'], stdout=subprocess.PIPE)
9-
supported = result.stdout.decode('utf-8').splitlines()
8+
result = subprocess.run(["./bin/docker-supported.sh"], stdout=subprocess.PIPE)
9+
supported = result.stdout.decode("utf-8").splitlines()
1010

1111
tags = {}
1212
for file in files:
13-
pieces = re.search('nginx/(.+)/(.+)/(.+)/Dockerfile', file)
13+
pieces = re.search("nginx/(.+)/(.+)/(.+)/Dockerfile", file)
1414

1515
nginxVer, os, osVer = pieces.group(1, 2, 3)
16-
nginxVerPieces = re.split('\.', nginxVer)
16+
nginxVerPieces = re.split("\.", nginxVer)
1717
nginxVerMajor, nginxVerMinor, nginxVerPatch = nginxVerPieces
1818

19-
#tags[os] = file # currently missing
20-
tags[nginxVerMajor + '.' + nginxVerMinor + '.' + nginxVerPatch + '-' + os + osVer] = file
21-
tags[nginxVerMajor + '.' + nginxVerMinor + '.' + nginxVerPatch + '-' + os] = file
22-
if os == 'alpine':
23-
tags[nginxVerMajor + '.' + nginxVerMinor + '-' + nginxVerPatch] = file
24-
tags[nginxVerMajor + '.' + nginxVerMinor + '-' + os + osVer] = file
25-
if not(os == 'amazonlinux' and osVer.startswith('2018')):
26-
tags[nginxVerMajor + '.' + nginxVerMinor + '-' + os] = file
27-
if os == 'alpine':
28-
tags[nginxVerMajor + '.' + nginxVerMinor] = file
29-
tags[nginxVerMajor + '-' + os + osVer] = file
19+
# tags[os] = file # currently missing
20+
tags[nginxVerMajor + "." + nginxVerMinor + "." + nginxVerPatch + "-" + os + osVer] = file
21+
tags[nginxVerMajor + "." + nginxVerMinor + "." + nginxVerPatch + "-" + os] = file
22+
if os == "alpine":
23+
tags[nginxVerMajor + "." + nginxVerMinor + "-" + nginxVerPatch] = file
24+
tags[nginxVerMajor + "." + nginxVerMinor + "-" + os + osVer] = file
25+
if not(os == "amazonlinux" and osVer.startswith("2018")):
26+
tags[nginxVerMajor + "." + nginxVerMinor + "-" + os] = file
27+
if os == "alpine":
28+
tags[nginxVerMajor + "." + nginxVerMinor] = file
29+
tags[nginxVerMajor + "-" + os + osVer] = file
3030
tags[os] = file
31-
if not(os == 'amazonlinux' and osVer.startswith('2018')):
32-
tags[nginxVerMajor + '-' + os] = file
33-
if os == 'alpine':
31+
if not(os == "amazonlinux" and osVer.startswith("2018")):
32+
tags[nginxVerMajor + "-" + os] = file
33+
if os == "alpine":
3434
tags[nginxVerMajor] = file
35-
tags['latest'] = file
35+
tags["latest"] = file
3636

3737
dockerfiles = {}
3838
reversed = files
@@ -41,15 +41,29 @@
4141
if dockerfile not in dockerfiles:
4242
dockerfiles[dockerfile] = []
4343
dockerfiles[dockerfile].append(tag)
44-
dockerfiles[dockerfile] = sorted(dockerfiles[dockerfile], key = operator.itemgetter(0))
44+
dockerfiles[dockerfile] = sorted(
45+
dockerfiles[dockerfile], key=operator.itemgetter(0)
46+
)
4547

46-
print('# Tags\n')
47-
print('## Supported Tags\n')
48+
print("# Tags\n")
49+
print("## Supported Tags\n")
4850
for file in supported:
4951
reversed.remove(file)
50-
print('- [`' + '`, `'.join(dockerfiles[file]) + '`](https://github.com/fabiocicerchia/nginx-lua/blob/master/' + file + ')')
52+
print(
53+
"- [`"
54+
+ "`, `".join(dockerfiles[file])
55+
+ "`](https://github.com/fabiocicerchia/nginx-lua/blob/master/"
56+
+ file
57+
+ ")"
58+
)
5159

52-
print('\n## Unsupported Tags\n')
60+
print("\n## Unsupported Tags\n")
5361
reversed = list(reversed)[::-1]
5462
for file in reversed:
55-
print('- [`' + '`, `'.join(dockerfiles[file]) + '`](https://github.com/fabiocicerchia/nginx-lua/blob/master/' + file + ')')
63+
print(
64+
"- [`"
65+
+ "`, `".join(dockerfiles[file])
66+
+ "`](https://github.com/fabiocicerchia/nginx-lua/blob/master/"
67+
+ file
68+
+ ")"
69+
)

bin/readme-tags.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function tag() {
4747
STR="$STR,\`latest\`"
4848
fi
4949

50-
STR=" - [$STR](https://github.com/fabiocicerchia/nginx-lua/blob/master/$DOCKERFILE)"
50+
STR="- [$STR](https://github.com/fabiocicerchia/nginx-lua/blob/master/$DOCKERFILE)"
5151
echo "$STR"
5252
}
5353

docs/BENCHMARKS.md

-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ More details about the benchark can be found in [docs/benchmarks/different_image
1515
![Benchmark Median Response Time](http://chart.googleapis.com/chart?&chco=0D597F,9CCE28,CD2B4A,3D6EB4,DD4915&chd=t:9.86|9.93|10.4|10.06|10.3&chdl=alpine|centos|debian|fedora|ubuntu&chdlp=bvr&chds=9.5,10&chma=20,20,20,20&chs=300x200&cht=bvg&chts=000000,15,l&chtt=Median+Response+Time&chxl=0:|msec&chxr=1,9.5,10,0.1&chxt=x,y)
1616

1717
More details about the benchark can be found in [docs/benchmarks/distros](docs/benchmarks/distros).
18-

docs/DEV.md

-25
This file was deleted.

0 commit comments

Comments
 (0)