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

Commit 746385e

Browse files
fabiocicerchiaweb-flow
authored andcommitted
Updated benchmarks + added auto updated repo + added linter (#6)
* Updated benchmarks + added auto updated repo + added linter * linting
1 parent 2e24b3a commit 746385e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4186
-371
lines changed

.github/linters/.dockerfilelintrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rules:
2+
invalid_command: off

.github/linters/.markdown-lint.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
line-length: false

.github/workflows/auto_update.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Auto Update
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
7+
env:
8+
IMAGE_NAME: fabiocicerchia/nginx-lua
9+
10+
jobs:
11+
auto_update:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Generate Supported Versions
17+
run: ./bin/auto_update.sh

.github/workflows/linter.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
###########################
3+
###########################
4+
## Linter GitHub Actions ##
5+
###########################
6+
###########################
7+
name: Lint Code Base
8+
9+
#
10+
# Documentation:
11+
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
12+
#
13+
14+
#############################
15+
# Start the job on all push #
16+
#############################
17+
on:
18+
push:
19+
branches-ignore:
20+
- 'master'
21+
22+
###############
23+
# Set the Job #
24+
###############
25+
jobs:
26+
build:
27+
# Name the Job
28+
name: Lint Code Base
29+
# Set the agent to run on
30+
runs-on: ubuntu-latest
31+
32+
##################
33+
# Load all steps #
34+
##################
35+
steps:
36+
##########################
37+
# Checkout the code base #
38+
##########################
39+
- name: Checkout Code
40+
uses: actions/checkout@v2
41+
42+
################################
43+
# Run Linter against code base #
44+
################################
45+
- name: Lint Code Base
46+
uses: docker://github/super-linter:v3
47+
env:
48+
VALIDATE_ALL_CODEBASE: true

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker
1+
name: Docker Builds
22

33
on:
44
push:

.shellcheckrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
disable=SC2086,SC2178,SC1091
2+

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MIT License
1+
# MIT License
22

33
Copyright (c) 2020 Fabio Cicerchia
44

README.md

+138-277
Large diffs are not rendered by default.

bin/auto_update.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
# shellcheck disable=SC2086,SC2178,SC1091,SC2004
3+
4+
./bin/generate_supported_versions.sh | tee supported_versions
5+
./bin/dockerfile-generate.sh
6+
./bin/generate_tags.py | tee docs/TAGS.md
7+
git config --global user.name "fabiocicerchia"
8+
git config --global user.email "[email protected]"
9+
git add -A
10+
git commit -m "Automated updates"
11+
set +x
12+
git remote set-url --push origin "https://fabiocicerchia:${GH_TOKEN}@github.com/fabiocicerchia/nginx-lua.git"
13+
set -x
14+
git push origin HEAD:master

bin/benchmark.sh

100644100755
+141-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,146 @@
11
#!/bin/bash
2+
# shellcheck disable=SC2086,SC2178,SC1091,SC2004
3+
4+
# VM: ubuntu-s-1vcpu-2gb-fra1-01
5+
6+
# SETUP
7+
sudo apt-get update
8+
sudo apt-get install \
9+
apt-transport-https \
10+
ca-certificates \
11+
curl \
12+
gnupg-agent \
13+
software-properties-common
14+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
15+
sudo apt-key fingerprint 0EBFCD88
16+
sudo add-apt-repository \
17+
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
18+
$(lsb_release -cs) \
19+
stable"
20+
sudo apt-get update
21+
sudo apt-get install docker-ce docker-ce-cli containerd.io
22+
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
23+
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
24+
sudo apt-get install -y nodejs
25+
26+
# RUN
227
npm install artillery
3-
docker-compose -f docker-compose.test.yml up
28+
docker-compose -f docker-compose.test.yml up -d
29+
430
echo "ARTILLERY - NGINX"
5-
./node_modules/.bin/artillery run test/artillery-nginx.yml
31+
./node_modules/.bin/artillery run test/artillery-nginx.yml > artillery.nginx.1.txt
632
echo "ARTILLERY - NGINX-LUA"
7-
./node_modules/.bin/artillery run test/artillery-nginx-lua.yml
33+
./node_modules/.bin/artillery run test/artillery-nginx-lua.yml > artillery.nginx-lua.1.txt
834
echo "ARTILLERY - OPENRESTY"
9-
./node_modules/.bin/artillery run test/artillery-openresty.yml
35+
./node_modules/.bin/artillery run test/artillery-openresty.yml > artillery.openresty.1.txt
36+
37+
echo "ARTILLERY - NGINX"
38+
./node_modules/.bin/artillery run test/artillery-nginx.yml > artillery.nginx.2.txt
39+
echo "ARTILLERY - NGINX-LUA"
40+
./node_modules/.bin/artillery run test/artillery-nginx-lua.yml > artillery.nginx-lua.2.txt
41+
echo "ARTILLERY - OPENRESTY"
42+
./node_modules/.bin/artillery run test/artillery-openresty.yml > artillery.openresty.2.txt
43+
44+
echo "ARTILLERY - NGINX"
45+
./node_modules/.bin/artillery run test/artillery-nginx.yml > artillery.nginx.3.txt
46+
echo "ARTILLERY - NGINX-LUA"
47+
./node_modules/.bin/artillery run test/artillery-nginx-lua.yml > artillery.nginx-lua.3.txt
48+
echo "ARTILLERY - OPENRESTY"
49+
./node_modules/.bin/artillery run test/artillery-openresty.yml > artillery.openresty.3.txt
50+
51+
echo "ARTILLERY - NGINX"
52+
./node_modules/.bin/artillery run test/artillery-nginx.yml > artillery.nginx.4.txt
53+
echo "ARTILLERY - NGINX-LUA"
54+
./node_modules/.bin/artillery run test/artillery-nginx-lua.yml > artillery.nginx-lua.4.txt
55+
echo "ARTILLERY - OPENRESTY"
56+
./node_modules/.bin/artillery run test/artillery-openresty.yml > artillery.openresty.4.txt
57+
58+
echo "ARTILLERY - NGINX"
59+
./node_modules/.bin/artillery run test/artillery-nginx.yml > artillery.nginx.5.txt
60+
echo "ARTILLERY - NGINX-LUA"
61+
./node_modules/.bin/artillery run test/artillery-nginx-lua.yml > artillery.nginx-lua.5.txt
62+
echo "ARTILLERY - OPENRESTY"
63+
./node_modules/.bin/artillery run test/artillery-openresty.yml > artillery.openresty.5.txt
64+
65+
#####
66+
67+
echo "ARTILLERY - ALPINE"
68+
./node_modules/.bin/artillery run test/artillery-alpine.yml > artillery.alpine.1.txt
69+
echo "ARTILLERY - UBUNTU"
70+
./node_modules/.bin/artillery run test/artillery-ubuntu.yml > artillery.ubuntu.1.txt
71+
echo "ARTILLERY - DEBIAN"
72+
./node_modules/.bin/artillery run test/artillery-debian.yml > artillery.debian.1.txt
73+
echo "ARTILLERY - FEDORA"
74+
./node_modules/.bin/artillery run test/artillery-fedora.yml > artillery.fedora.1.txt
75+
echo "ARTILLERY - CENTOS"
76+
./node_modules/.bin/artillery run test/artillery-centos.yml > artillery.centos.1.txt
77+
78+
echo "ARTILLERY - ALPINE"
79+
./node_modules/.bin/artillery run test/artillery-alpine.yml > artillery.alpine.2.txt
80+
echo "ARTILLERY - UBUNTU"
81+
./node_modules/.bin/artillery run test/artillery-ubuntu.yml > artillery.ubuntu.2.txt
82+
echo "ARTILLERY - DEBIAN"
83+
./node_modules/.bin/artillery run test/artillery-debian.yml > artillery.debian.2.txt
84+
echo "ARTILLERY - FEDORA"
85+
./node_modules/.bin/artillery run test/artillery-fedora.yml > artillery.fedora.2.txt
86+
echo "ARTILLERY - CENTOS"
87+
./node_modules/.bin/artillery run test/artillery-centos.yml > artillery.centos.2.txt
88+
89+
echo "ARTILLERY - ALPINE"
90+
./node_modules/.bin/artillery run test/artillery-alpine.yml > artillery.alpine.3.txt
91+
echo "ARTILLERY - UBUNTU"
92+
./node_modules/.bin/artillery run test/artillery-ubuntu.yml > artillery.ubuntu.3.txt
93+
echo "ARTILLERY - DEBIAN"
94+
./node_modules/.bin/artillery run test/artillery-debian.yml > artillery.debian.3.txt
95+
echo "ARTILLERY - FEDORA"
96+
./node_modules/.bin/artillery run test/artillery-fedora.yml > artillery.fedora.3.txt
97+
echo "ARTILLERY - CENTOS"
98+
./node_modules/.bin/artillery run test/artillery-centos.yml > artillery.centos.3.txt
99+
100+
echo "ARTILLERY - ALPINE"
101+
./node_modules/.bin/artillery run test/artillery-alpine.yml > artillery.alpine.4.txt
102+
echo "ARTILLERY - UBUNTU"
103+
./node_modules/.bin/artillery run test/artillery-ubuntu.yml > artillery.ubuntu.4.txt
104+
echo "ARTILLERY - DEBIAN"
105+
./node_modules/.bin/artillery run test/artillery-debian.yml > artillery.debian.4.txt
106+
echo "ARTILLERY - FEDORA"
107+
./node_modules/.bin/artillery run test/artillery-fedora.yml > artillery.fedora.4.txt
108+
echo "ARTILLERY - CENTOS"
109+
./node_modules/.bin/artillery run test/artillery-centos.yml > artillery.centos.4.txt
110+
111+
echo "ARTILLERY - ALPINE"
112+
./node_modules/.bin/artillery run test/artillery-alpine.yml > artillery.alpine.5.txt
113+
echo "ARTILLERY - UBUNTU"
114+
./node_modules/.bin/artillery run test/artillery-ubuntu.yml > artillery.ubuntu.5.txt
115+
echo "ARTILLERY - DEBIAN"
116+
./node_modules/.bin/artillery run test/artillery-debian.yml > artillery.debian.5.txt
117+
echo "ARTILLERY - FEDORA"
118+
./node_modules/.bin/artillery run test/artillery-fedora.yml > artillery.fedora.5.txt
119+
echo "ARTILLERY - CENTOS"
120+
./node_modules/.bin/artillery run test/artillery-centos.yml > artillery.centos.5.txt
121+
122+
echo Nginx
123+
TESTS=$(grep -r virtual docs/benchmark/reports/different_images/*nginx.* -A10 | grep 'median' | sed 's/.*: //' | sort -n | tail -n4 | head -n3 | tr '\n' '+')
124+
echo "scale=2; (${TESTS%?})/3" | bc
125+
echo Nginx-Lua
126+
TESTS=$(grep -r virtual docs/benchmark/reports/different_images/*nginx-lua* -A10 | grep 'median' | sed 's/.*: //' | sort -n | tail -n4 | head -n3 | tr '\n' '+')
127+
echo "scale=2; (${TESTS%?})/3" | bc
128+
echo OpenResty
129+
TESTS=$(grep -r virtual docs/benchmark/reports/different_images/*openresty* -A10 | grep 'median' | sed 's/.*: //' | sort -n | tail -n4 | head -n3 | tr '\n' '+')
130+
echo "scale=2; (${TESTS%?})/3" | bc
131+
132+
echo Alpine
133+
TESTS=$(grep -r virtual docs/benchmark/reports/distros/*alpine* -A10 | grep 'median' | sed 's/.*: //' | sort -n | tail -n4 | head -n3 | tr '\n' '+')
134+
echo "scale=2; (${TESTS%?})/3" | bc
135+
echo Ubuntu
136+
TESTS=$(grep -r virtual docs/benchmark/reports/distros/*ubuntu* -A10 | grep 'median' | sed 's/.*: //' | sort -n | tail -n4 | head -n3 | tr '\n' '+')
137+
echo "scale=2; (${TESTS%?})/3" | bc
138+
echo Debian
139+
TESTS=$(grep -r virtual docs/benchmark/reports/distros/*debian* -A10 | grep 'median' | sed 's/.*: //' | sort -n | tail -n4 | head -n3 | tr '\n' '+')
140+
echo "scale=2; (${TESTS%?})/3" | bc
141+
echo Fedora
142+
TESTS=$(grep -r virtual docs/benchmark/reports/distros/*fedora* -A10 | grep 'median' | sed 's/.*: //' | sort -n | tail -n4 | head -n3 | tr '\n' '+')
143+
echo "scale=2; (${TESTS%?})/3" | bc
144+
echo Centos
145+
TESTS=$(grep -r virtual docs/benchmark/reports/distros/*centos* -A10 | grep 'median' | sed 's/.*: //' | sort -n | tail -n4 | head -n3 | tr '\n' '+')
146+
echo "scale=2; (${TESTS%?})/3" | bc

bin/docker-build.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# shellcheck disable=SC2086,SC2178,SC1091,SC2004,SC2046
23

34
source supported_versions
45

@@ -22,7 +23,7 @@ function build() {
2223
MINOR=$MAJOR.$(echo $NGINX_VER | cut -d '.' -f 2)
2324
PATCH=$NGINX_VER
2425

25-
if [ "$FORCE" == "0" -a $(docker_tag_exists fabiocicerchia/nginx-lua $PATCH-$OS$OS_VER) == 0 ]; then
26+
if [ "$FORCE" == "0" ] && [ $(docker_tag_exists fabiocicerchia/nginx-lua $PATCH-$OS$OS_VER) == 0 ]; then
2627
return
2728
fi
2829

bin/docker-push.sh

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# shellcheck disable=SC2086,SC2178,SC1091,SC2004,SC2046
23

34
source supported_versions
45

@@ -15,14 +16,11 @@ function push() {
1516
OS_TAGS=$5
1617
DEFAULT=$6
1718

18-
DOCKERFILE_PATH=nginx/$NGINX_VER/$OS/$OS_VER
19-
DOCKERFILE=$DOCKERFILE_PATH/Dockerfile
20-
2119
MAJOR=$(echo $NGINX_VER | cut -d '.' -f 1)
2220
MINOR=$MAJOR.$(echo $NGINX_VER | cut -d '.' -f 2)
2321
PATCH=$NGINX_VER
2422

25-
if [ "$FORCE" == "0" -a $(docker_tag_exists fabiocicerchia/nginx-lua $PATCH-$OS$OS_VER) == 0 ]; then
23+
if [ "$FORCE" == "0" ] && [ $(docker_tag_exists fabiocicerchia/nginx-lua $PATCH-$OS$OS_VER) == 0 ]; then
2624
return
2725
fi
2826

bin/docker-supported.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# shellcheck disable=SC2086,SC2178,SC1091,SC2004
3+
4+
source supported_versions
5+
6+
NLEN=${#NGINX[@]}
7+
for (( I=0; I<$NLEN; I++ )); do
8+
NGINX_VER="${NGINX[$I]}"
9+
10+
OS=alpine
11+
for OS_VER in "${ALPINE[@]}"; do echo nginx/$NGINX_VER/$OS/$OS_VER/Dockerfile; done
12+
13+
OS=amazonlinux
14+
for OS_VER in "${AMAZONLINUX[@]}"; do echo nginx/$NGINX_VER/$OS/$OS_VER/Dockerfile; done
15+
16+
OS=centos
17+
for OS_VER in "${CENTOS[@]}"; do echo nginx/$NGINX_VER/$OS/$OS_VER/Dockerfile; done
18+
19+
OS=debian
20+
for OS_VER in "${DEBIAN[@]}"; do echo nginx/$NGINX_VER/$OS/$OS_VER/Dockerfile; done
21+
22+
OS=fedora
23+
for OS_VER in "${FEDORA[@]}"; do echo nginx/$NGINX_VER/$OS/$OS_VER/Dockerfile; done
24+
25+
OS=ubuntu
26+
for OS_VER in "${UBUNTU[@]}"; do echo nginx/$NGINX_VER/$OS/$OS_VER/Dockerfile; done
27+
28+
done

bin/dockerfile-generate.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# shellcheck disable=SC2086,SC2178,SC1091,SC2004
23

34
source supported_versions
45

bin/generate_supported_versions.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#!/bin/bash
2+
# shellcheck disable=SC2086,SC2178,SC1091,SC2004,SC2207,SC2206
23

3-
VER_NGINX=$(DISTRO=nginx; wget -q https://registry.hub.docker.com/v1/repositories/$DISTRO/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | egrep "\d+\.\d+\.\d+" | egrep -v "alpine|perl" | sort -Vr | head -n1)
4+
VER_NGINX=$(DISTRO=nginx; wget -q https://registry.hub.docker.com/v1/repositories/$DISTRO/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | grep -E "\d+\.\d+\.\d+" | grep -E -v "alpine|perl" | sort -Vr | head -n1)
45
NGINX=()
56
for VER in $VER_NGINX; do
67
NGINX+=($VER)
78
done
89

9-
VER_ALPINE=$(DISTRO=alpine; wget -q https://registry.hub.docker.com/v1/repositories/$DISTRO/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | egrep "\d+\.\d+\.\d+" | sort -Vr | head -n 2)
10+
VER_ALPINE=$(DISTRO=alpine; wget -q https://registry.hub.docker.com/v1/repositories/$DISTRO/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | grep -E "\d+\.\d+\.\d+" | sort -Vr | head -n 2)
1011
ALPINE=()
1112
for VER in $VER_ALPINE; do
1213
ALPINE+=($VER)
1314
done
1415

15-
VER_AMAZONLINUX=$(DISTRO=amazonlinux; wget -q https://registry.hub.docker.com/v1/repositories/$DISTRO/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | egrep -v "with-|^201" | egrep "\d+\." | sort -Vr | head -n 2)
16+
VER_AMAZONLINUX=$(DISTRO=amazonlinux; wget -q https://registry.hub.docker.com/v1/repositories/$DISTRO/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | grep -E -v "with-|^201" | grep -E "\d+\." | sort -Vr | head -n 2)
1617
AMAZONLINUX=()
1718
for VER in $VER_AMAZONLINUX; do
1819
AMAZONLINUX+=($VER)

bin/generate_tags.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3
2+
import operator
3+
import re
4+
import subprocess
5+
6+
files = subprocess.getoutput('find nginx -type f | sort -V').splitlines()
7+
8+
result = subprocess.run(['./bin/docker-supported.sh'], stdout=subprocess.PIPE)
9+
supported = result.stdout.decode('utf-8').splitlines()
10+
11+
tags = {}
12+
for file in files:
13+
pieces = re.search('nginx/(.+)/(.+)/(.+)/Dockerfile', file)
14+
15+
nginxVer, os, osVer = pieces.group(1, 2, 3)
16+
nginxVerPieces = re.split('\.', nginxVer)
17+
nginxVerMajor, nginxVerMinor, nginxVerPatch = nginxVerPieces
18+
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+
tags[nginxVerMajor + '.' + nginxVerMinor + '-' + os] = file
26+
if os == 'alpine':
27+
tags[nginxVerMajor + '.' + nginxVerMinor] = file
28+
tags[nginxVerMajor + '-' + os + osVer] = file
29+
tags[nginxVerMajor + '-' + os] = file
30+
if os == 'alpine':
31+
tags[nginxVerMajor] = file
32+
tags['latest'] = file
33+
34+
dockerfiles = {}
35+
for tag in tags:
36+
dockerfile = tags[tag]
37+
if dockerfile not in dockerfiles:
38+
dockerfiles[dockerfile] = []
39+
dockerfiles[dockerfile].append(tag)
40+
dockerfiles[dockerfile] = sorted(dockerfiles[dockerfile], key = operator.itemgetter(0))
41+
42+
print('# Tags\n')
43+
print('## Supported Tags\n')
44+
for file in supported:
45+
print('- [`' + '`, `'.join(dockerfiles[file]) + '`](https://github.com/fabiocicerchia/nginx-lua/blob/master' + file + ')')
46+
47+
print('\n## Unsupported Tags\n')
48+
reversed = list(set(files) - set(supported))[::-1]
49+
for file in reversed:
50+
print('- [`' + '`, `'.join(dockerfiles[file]) + '`](https://github.com/fabiocicerchia/nginx-lua/blob/master' + file + ')')

0 commit comments

Comments
 (0)