Skip to content

Commit 06ddc8b

Browse files
committedMar 8, 2022
New project structure
1 parent 3c7fc11 commit 06ddc8b

24 files changed

+388
-657
lines changed
 

‎.github/dependabot.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
version: 2
23
updates:
34
# Maintain dependencies for GitHub Actions

‎.github/labels.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# The labels in this file are automatically synced with the repository
2+
# using the micnncim/action-label-syncer action.
3+
---
4+
- name: C-dependency
5+
color: 1abc9c
6+
description: "Category: Dependency"
7+
- name: PR-block
8+
color: 3498db
9+
description: "Pull Request: Do not merge"
10+
- name: PR-merge
11+
color: 3498db
12+
description: "Pull Request: Merge when ready"

‎.github/release-drafter.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name-template: '$RESOLVED_VERSION 🌈'
3+
tag-template: '$RESOLVED_VERSION'
4+
version-template: '$MAJOR.$MINOR'
5+
categories:
6+
- title: '🚀 Features'
7+
labels:
8+
- 'feature'
9+
- 'enhancement'
10+
- title: '🐛 Bug Fixes'
11+
labels:
12+
- 'fix'
13+
- 'bugfix'
14+
- 'bug'
15+
- title: '🧰 Maintenance'
16+
label: 'chore'
17+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
18+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
19+
version-resolver:
20+
major:
21+
labels:
22+
- 'major'
23+
minor:
24+
labels:
25+
- 'minor'
26+
patch:
27+
labels:
28+
- 'patch'
29+
default: minor
30+
template: |
31+
## Changes
32+
33+
$CHANGES

‎.github/workflows/action_branch.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: build
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# When to run
11+
# -------------------------------------------------------------------------------------------------
12+
on:
13+
push:
14+
15+
16+
jobs:
17+
18+
# (1/2) Determine repository params
19+
params:
20+
uses: ./.github/workflows/params.yml
21+
22+
# (2/2) Build
23+
docker:
24+
needs: [params]
25+
uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master
26+
with:
27+
enabled: true
28+
can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }}
29+
name: ${{ needs.params.outputs.name }}
30+
matrix: ${{ needs.params.outputs.matrix }}
31+
refs: ${{ needs.params.outputs.refs }}
32+
secrets:
33+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
34+
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: build
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# When to run
11+
# -------------------------------------------------------------------------------------------------
12+
on:
13+
pull_request:
14+
15+
16+
jobs:
17+
18+
# (1/2) Determine repository params
19+
params:
20+
uses: ./.github/workflows/params.yml
21+
# Only run for forks (contributor)
22+
if: github.event.pull_request.head.repo.fork
23+
24+
# (2/2) Build
25+
docker:
26+
needs: [params]
27+
uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master
28+
with:
29+
enabled: true
30+
can_deploy: false
31+
name: ${{ needs.params.outputs.name }}
32+
matrix: ${{ needs.params.outputs.matrix }}
33+
refs: ${{ needs.params.outputs.refs }}
34+
secrets:
35+
dockerhub_username: ""
36+
dockerhub_password: ""

‎.github/workflows/action_schedule.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: nightly
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# When to run
11+
# -------------------------------------------------------------------------------------------------
12+
on:
13+
# Runs daily
14+
schedule:
15+
- cron: '0 0 * * *'
16+
17+
18+
jobs:
19+
20+
# (1/2) Determine repository params
21+
params:
22+
uses: ./.github/workflows/params.yml
23+
24+
# (2/2) Build
25+
docker:
26+
needs: [params]
27+
uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master
28+
with:
29+
enabled: true
30+
can_deploy: true
31+
name: ${{ needs.params.outputs.name }}
32+
matrix: ${{ needs.params.outputs.matrix }}
33+
refs: ${{ needs.params.outputs.refs }}
34+
secrets:
35+
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
36+
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}

‎.github/workflows/build.yml

-166
This file was deleted.

‎.github/workflows/contributor.yml

-86
This file was deleted.

‎.github/workflows/lint.yml

+1-18
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,4 @@ on:
1919
# -------------------------------------------------------------------------------------------------
2020
jobs:
2121
lint:
22-
name: "Lint"
23-
runs-on: ubuntu-latest
24-
steps:
25-
# ------------------------------------------------------------
26-
# Setup repository
27-
# ------------------------------------------------------------
28-
- name: Checkout repository
29-
uses: actions/checkout@v2
30-
with:
31-
fetch-depth: 0
32-
33-
# ------------------------------------------------------------
34-
# Lint repository
35-
# ------------------------------------------------------------
36-
- name: Lint workflow
37-
id: vars
38-
run: |
39-
make lint-workflow
22+
uses: devilbox/github-actions/.github/workflows/lint-generic.yml@master

‎.github/workflows/nightly.yml

-175
This file was deleted.

‎.github/workflows/params.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
3+
# -------------------------------------------------------------------------------------------------
4+
# Job Name
5+
# -------------------------------------------------------------------------------------------------
6+
name: params
7+
8+
9+
# -------------------------------------------------------------------------------------------------
10+
# Custom Variables
11+
# -------------------------------------------------------------------------------------------------
12+
env:
13+
NAME: Nginx
14+
MATRIX: >-
15+
[
16+
{
17+
"NAME": "Nginx",
18+
"VERSION": ["stable"],
19+
"ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"]
20+
21+
}
22+
]
23+
24+
25+
# -------------------------------------------------------------------------------------------------
26+
# When to run
27+
# -------------------------------------------------------------------------------------------------
28+
on:
29+
workflow_call:
30+
outputs:
31+
name:
32+
description: "The project name"
33+
value: ${{ jobs.params.outputs.name }}
34+
matrix:
35+
description: "The determined version matrix"
36+
value: ${{ jobs.params.outputs.matrix }}
37+
refs:
38+
description: "The determined git ref matrix (only during scheduled run)"
39+
value: ${{ jobs.params.outputs.refs }}
40+
41+
jobs:
42+
params:
43+
runs-on: ubuntu-latest
44+
45+
outputs:
46+
name: ${{ steps.set-name.outputs.name }}
47+
matrix: ${{ steps.set-matrix.outputs.matrix }}
48+
refs: ${{ steps.set-refs.outputs.matrix }}
49+
50+
steps:
51+
- name: "Set Name"
52+
id: set-name
53+
run: |
54+
echo '::set-output name=name::${{ env.NAME }}'
55+
56+
- name: "[Set-Output] Matrix"
57+
id: set-matrix
58+
run: |
59+
echo "::set-output name=matrix::$( echo '${{ env.MATRIX }}' | jq -M -c )"
60+
61+
- name: "[Set-Output] Matrix 'Refs' (master branch and latest tag)"
62+
id: set-refs
63+
uses: cytopia/git-ref-matrix-action@v0.1.2
64+
with:
65+
repository_default_branch: master
66+
branches: master
67+
num_latest_tags: 1
68+
if: github.event_name == 'schedule'
69+
70+
- name: "[DEBUG] Show settings'"
71+
run: |
72+
echo 'Name'
73+
echo '--------------------'
74+
echo '${{ steps.set-name.outputs.name }}'
75+
echo
76+
77+
echo 'Matrix'
78+
echo '--------------------'
79+
echo '${{ steps.set-matrix.outputs.matrix }}'
80+
echo
81+
82+
echo 'Matrix: Refs'
83+
echo '--------------------'
84+
echo '${{ steps.set-matrix-refs.outputs.matrix }}'
85+
echo

‎.github/workflows/release-drafter.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Release Drafter
3+
4+
on:
5+
push:
6+
# branches to consider in the event; optional, defaults to all
7+
branches:
8+
- master
9+
10+
jobs:
11+
update_release_draft:
12+
runs-on: ubuntu-latest
13+
steps:
14+
# Drafts your next Release notes as Pull Requests are merged into "master"
15+
- uses: release-drafter/release-drafter@v5
16+
with:
17+
publish: true
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.RELEASE_DRAFTER_TOKEN }}

‎.github/workflows/repository.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Repository
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
paths:
9+
- .github/labels.yml
10+
11+
jobs:
12+
labels:
13+
name: Labels
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
20+
- name: Sync labels
21+
uses: micnncim/action-label-syncer@v1
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
with:
25+
manifest: .github/labels.yml

‎.gitignore

+2-86
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,2 @@
1-
# Note:
2-
# To effectively apply the changes you will have
3-
# to re-index the git index (if there are already
4-
# commited files)
5-
#
6-
# $ git rm -r --cached .
7-
# $ git add .
8-
# $ git commit -m ".gitignore index rebuild"
9-
#
10-
11-
12-
######################################
13-
# CUSTOM
14-
######################################
15-
16-
17-
######################################
18-
# GENERIC
19-
######################################
20-
21-
###### std ######
22-
.lock
23-
*.log
24-
25-
###### patches/diffs ######
26-
*.patch
27-
*.diff
28-
*.orig
29-
*.rej
30-
31-
32-
######################################
33-
# Operating Systems
34-
######################################
35-
36-
###### OSX ######
37-
._*
38-
.DS*
39-
.Spotlight-V100
40-
.Trashes
41-
42-
###### Windows ######
43-
Thumbs.db
44-
ehthumbs.db
45-
Desktop.ini
46-
$RECYCLE.BIN/
47-
*.lnk
48-
*.shortcut
49-
50-
######################################
51-
# Editors
52-
######################################
53-
54-
###### Sublime ######
55-
*.sublime-workspace
56-
*.sublime-project
57-
58-
###### Eclipse ######
59-
.classpath
60-
.buildpath
61-
.project
62-
.settings/
63-
64-
###### Netbeans ######
65-
/nbproject/
66-
67-
###### Intellij IDE ######
68-
.idea/
69-
.idea_modules/
70-
71-
###### vim ######
72-
*.swp
73-
*.swo
74-
*.swn
75-
*.swm
76-
*~
77-
78-
###### TextMate ######
79-
.tm_properties
80-
*.tmproj
81-
82-
###### BBEdit ######
83-
*.bbprojectd
84-
*.bbproject
85-
86-
.vagrant
1+
Makefile.docker
2+
Makefile.lint

‎.yamllint

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
extends: default
3+
4+
ignore: |
5+
.yamllint
6+
7+
8+
rules:
9+
truthy:
10+
allowed-values: ['true', 'false', 'yes', 'no']
11+
check-keys: False
12+
level: error
13+
line-length: disable

‎Makefile

+44-96
Original file line numberDiff line numberDiff line change
@@ -2,138 +2,86 @@ ifneq (,)
22
.error This Makefile requires GNU Make.
33
endif
44

5+
# Ensure additional Makefiles are present
6+
MAKEFILES = Makefile.docker Makefile.lint
7+
$(MAKEFILES): URL=https://raw.githubusercontent.com/devilbox/makefiles/master/$(@)
8+
$(MAKEFILES):
9+
@if ! (curl --fail -sS -o $(@) $(URL) || wget -O $(@) $(URL)); then \
10+
echo "Error, curl or wget required."; \
11+
echo "Exiting."; \
12+
false; \
13+
fi
14+
include $(MAKEFILES)
15+
16+
# Set default Target
17+
.DEFAULT_GOAL := help
18+
519

620
# -------------------------------------------------------------------------------------------------
7-
# Docker configuration
21+
# Default configuration
822
# -------------------------------------------------------------------------------------------------
23+
# Own vars
24+
TAG = latest
925

10-
DIR = .
11-
FILE = Dockerfile
12-
IMAGE = devilbox/nginx-stable
13-
TAG = latest
14-
ARCH = linux/amd64
15-
NO_CACHE =
26+
# Makefile.docker overwrites
27+
NAME = Nginx
28+
VERSION = stable
29+
IMAGE = devilbox/nginx-stable
30+
DIR = .
31+
FILE = Dockerfile
32+
DOCKER_TAG = $(TAG)
33+
ARCH = linux/amd64
1634

1735

1836
# -------------------------------------------------------------------------------------------------
1937
# Default Target
2038
# -------------------------------------------------------------------------------------------------
2139
.PHONY: help
2240
help:
23-
@echo "lint Lint project files and repository"
41+
@echo "lint Lint project files and repository"
2442
@echo
25-
@echo "build Build Docker image"
26-
@echo "rebuild Build Docker image without cache"
43+
@echo "build [ARCH=...] [TAG=...] Build Docker image"
44+
@echo "rebuild [ARCH=...] [TAG=...] Build Docker image without cache"
45+
@echo "push [ARCH=...] [TAG=...] Push Docker image to Docker hub"
2746
@echo
28-
@echo "manifest-create Create multi-arch manifest"
29-
@echo "manifest-push Push multi-arch manifest"
47+
@echo "manifest-create [ARCHES=...] [TAG=...] Create multi-arch manifest"
48+
@echo "manifest-push [TAG=...] Push multi-arch manifest"
3049
@echo
31-
@echo "test Test built Docker image"
32-
@echo "update-readme Update README.md with PHP modules"
50+
@echo "test [ARCH=...] Test built Docker image"
3351
@echo
34-
@echo "tag [TAG=...] Retag Docker image"
35-
@echo "login USER=... PASS=... Login to Docker hub"
36-
@echo "push [TAG=...] Push Docker image to Docker hub"
37-
38-
39-
# -------------------------------------------------------------------------------------------------
40-
# Lint Targets
41-
# -------------------------------------------------------------------------------------------------
42-
.PHONY: lint
43-
lint: lint-workflow
44-
45-
.PHONY: lint-workflow
46-
lint-workflow:
47-
@\
48-
GIT_CURR_MAJOR="$$( git tag | sort -V | tail -1 | sed 's|\.[0-9]*$$||g' )"; \
49-
GIT_CURR_MINOR="$$( git tag | sort -V | tail -1 | sed 's|^[0-9]*\.||g' )"; \
50-
GIT_NEXT_TAG="$${GIT_CURR_MAJOR}.$$(( GIT_CURR_MINOR + 1 ))"; \
51-
grep 'refs:' -A 20 .github/workflows/nightly.yml \
52-
| grep '^ -' \
53-
| grep -v master \
54-
| while read -r i; do \
55-
if ! echo "$${i}" | grep -- "- '$${GIT_NEXT_TAG}'" >/dev/null; then \
56-
echo "[ERR] New Tag required in .github/workflows/nightly.yml: $${GIT_NEXT_TAG}"; \
57-
exit 1; \
58-
else \
59-
echo "[OK] Git Tag present in .github/workflows/nightly.yml: $${GIT_NEXT_TAG}"; \
60-
fi \
61-
done
6252

6353

6454
# -------------------------------------------------------------------------------------------------
65-
# Build Targets
55+
# Docker Targets
6656
# -------------------------------------------------------------------------------------------------
6757
.PHONY: build
68-
build:
69-
docker build --platform=$(ARCH) $(NO_CACHE) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR)
70-
./build/gen-readme.sh $(IMAGE) $(ARCH)
58+
build: ARGS=--build-arg ARCH=$(ARCH)
59+
build: docker-arch-build
7160

7261
.PHONY: rebuild
73-
rebuild: NO_CACHE=--no-cache
74-
rebuild: pull-base-image
75-
rebuild: build
62+
rebuild: ARGS=--build-arg ARCH=$(ARCH)
63+
rebuild: docker-arch-rebuild
64+
65+
.PHONY: push
66+
push: docker-arch-push
7667

7768

7869
# -------------------------------------------------------------------------------------------------
7970
# Manifest Targets
8071
# -------------------------------------------------------------------------------------------------
8172
.PHONY: manifest-create
82-
manifest-create:
83-
@echo "docker manifest create \
84-
$(IMAGE):$(TAG) \
85-
$$( echo $(ARCH) | sed 's/,/ /g' | sed 's|/|-|g' | xargs -n1 sh -c 'printf -- " --amend $(IMAGE):$(TAG)-manifest-$${1}"' -- )" \
86-
| sed 's/\s\s*/ /g' \
87-
| sed 's/--/\\\n --/g'
88-
@echo "docker manifest create \
89-
$(IMAGE):$(TAG) \
90-
$$( echo $(ARCH) | sed 's/,/ /g' | sed 's|/|-|g' | xargs -n1 sh -c 'printf -- " --amend $(IMAGE):$(TAG)-manifest-$${1}"' -- )" \
91-
| bash
73+
manifest-create: docker-manifest-create
9274

9375
.PHONY: manifest-push
94-
manifest-push:
95-
docker manifest push $(IMAGE):$(TAG)
76+
manifest-push: docker-manifest-push
9677

9778

9879
# -------------------------------------------------------------------------------------------------
9980
# Test Targets
10081
# -------------------------------------------------------------------------------------------------
10182
.PHONY: test
10283
test:
103-
./tests/start-ci.sh $(IMAGE) $(ARCH)
84+
./tests/start-ci.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH)
10485

10586
.PHONY: update-readme
106-
./build/gen-readme.sh $(IMAGE) $(ARCH)
107-
108-
# -------------------------------------------------------------------------------------------------
109-
# Deploy Targets
110-
# -------------------------------------------------------------------------------------------------
111-
.PHONY: tag
112-
tag:
113-
docker tag $(IMAGE) $(IMAGE):$(TAG)
114-
115-
.PHONY: login
116-
login:
117-
yes | docker login --username $(USER) --password $(PASS)
118-
119-
.PHONY: push
120-
push:
121-
@$(MAKE) tag TAG=$(TAG)
122-
docker push $(IMAGE):$(TAG)
123-
124-
.PHONY: push-arch
125-
push-arch:
126-
$(MAKE) tag TAG=$(TAG)-manifest-$(subst /,-,$(ARCH))
127-
docker push $(IMAGE):$(TAG)-manifest-$(subst /,-,$(ARCH))
128-
129-
130-
# -------------------------------------------------------------------------------------------------
131-
# Helper Targets
132-
# -------------------------------------------------------------------------------------------------
133-
.PHONY: enter
134-
enter:
135-
docker run --rm --platform=$(ARCH) -it --entrypoint=bash $(ARG) $(IMAGE)
136-
137-
.PHONY: pull-base-image
138-
pull-base-image:
139-
@docker pull $(shell grep FROM Dockerfile | sed 's/^FROM\s*//g';)
87+
./build/gen-readme.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH)

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ This Docker container adds a lot of injectables in order to customize it to your
152152
| MAIN_VHOST_SSL_TYPE | string | `plain` | <ul><li><code>plain</code> - only serve via http</li><li><code>ssl</code> - only serve via https</li><li><code>both</code> - serve via http and https</li><li><code>redir</code> - serve via https and redirect http to https</li></ul> |
153153
| MAIN_VHOST_SSL_GEN | bool | `0` | `0`: Do not generate an ssl certificate<br/> `1`: Generate self-signed certificate automatically |
154154
| MAIN_VHOST_SSL_CN | string | `localhost` | Comma separated list of CN names for SSL certificate generation (The domain names by which you want to reach the default server) |
155-
| MAIN_VHOST_DOCROOT | string | `htdocs`| This is the directory name appended to `/var/www/default/` from which the default virtual host will serve its files.<br/><strong>Default:</strong><br/>`/var/www/default/htdocs`<br/><strong>Example:</strong><br/>`MAIN_VHOST_DOCROOT=www`<br/>Doc root: `/var/www/default/www` |
155+
| MAIN_VHOST_DOCROOT | string | `htdocs`| This is the directory name appended to `/var/www/default/` from which the default virtual host will serve its files.<br/><strong>Default:</strong><br/>`/var/www/default/htdocs`<br/><strong>Example:</strong><br/>`MAIN_VHOST_DOCROOT=www`<br/>Doc root: `/var/www/default/www` |
156156
| MAIN_VHOST_TPL | string | `cfg` | Directory within th default vhost base path (`/var/www/default`) to look for templates to overwrite virtual host settings. See [vhost-gen](https://github.com/devilbox/vhost-gen/tree/master/etc/templates) for available template files.<br/><strong>Resulting default path:</strong><br/>`/var/www/default/cfg` |
157157
| MAIN_VHOST_STATUS_ENABLE | bool | `0` | Enable httpd status page. |
158158
| MAIN_VHOST_STATUS_ALIAS | string | `/httpd-status` | Set the alias under which the httpd server should serve its status page. |

‎build/gen-readme.sh

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ INFO="$( docker run --rm --platform "${ARCH}" --entrypoint=nginx "${IMAGE}" -v 2
1515

1616
echo "${INFO}"
1717
sed -i'' '/##[[:space:]]Version/q' "${CWD}/README.md"
18-
echo "" >> "${CWD}/README.md"
19-
echo '```' >> "${CWD}/README.md"
20-
echo "${INFO}" >> "${CWD}/README.md"
21-
echo '```' >> "${CWD}/README.md"
18+
{
19+
echo "";
20+
echo '```';
21+
echo "${INFO}";
22+
echo '```';
23+
} >> "${CWD}/README.md"

‎data/docker-entrypoint.d/01-uid-gid.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ set_uid() {
4444
local uid_varname="${1}"
4545
local username="${2}"
4646
local debug="${3}"
47-
local homedir
48-
homedir="$( _get_homedir_by_username "${username}" )"
47+
#local homedir
48+
#homedir="$( _get_homedir_by_username "${username}" )"
4949

5050
local uid= # new uid
5151
local spare_uid=9876 # spare uid to change another user to
@@ -83,8 +83,8 @@ set_gid() {
8383
local gid_varname="${1}"
8484
local groupname="${2}"
8585
local debug="${3}"
86-
local homedir
87-
homedir="$( _get_homedir_by_groupname "${groupname}" )"
86+
#local homedir
87+
#homedir="$( _get_homedir_by_groupname "${groupname}" )"
8888

8989
local gid= # new gid
9090
local spare_gid=9876 # spare gid to change another group to

‎data/docker-entrypoint.d/08-cert-gen.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ cert_gen_generate_ca() {
2020

2121
# Create directories
2222
if [ ! -d "$( dirname "${key}" )" ]; then
23-
run "mkdir -p $( dirname ${key} )" "${debug}"
23+
run "mkdir -p $( dirname "${key}" )" "${debug}"
2424
fi
2525
if [ ! -d "$( dirname "${crt}" )" ]; then
26-
run "mkdir -p $( dirname ${crt} )" "${debug}"
26+
run "mkdir -p $( dirname "${crt}" )" "${debug}"
2727
fi
2828

2929
# cert-gen verbosity
@@ -67,13 +67,13 @@ cert_gen_generate_cert() {
6767

6868
# Create directories
6969
if [ ! -d "$( dirname "${key}" )" ]; then
70-
run "mkdir -p $( dirname ${key} )" "${debug}"
70+
run "mkdir -p $( dirname "${key}" )" "${debug}"
7171
fi
7272
if [ ! -d "$( dirname "${csr}" )" ]; then
73-
run "mkdir -p $( dirname ${csr} )" "${debug}"
73+
run "mkdir -p $( dirname "${csr}" )" "${debug}"
7474
fi
7575
if [ ! -d "$( dirname "${crt}" )" ]; then
76-
run "mkdir -p $( dirname ${crt} )" "${debug}"
76+
run "mkdir -p $( dirname "${crt}" )" "${debug}"
7777
fi
7878

7979
# cert-gen verbosity

‎tests/.lib.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ function get_random_name() {
3131
local len="${#chr[@]}"
3232
local name=
3333

34+
# shellcheck disable=SC2034
3435
for i in {1..15}; do
35-
rand="$( shuf -i 0-${len} -n 1 )"
36+
rand="$( shuf -i "0-${len}" -n 1 )"
3637
rand=$(( rand - 1 ))
3738
name="${name}${chr[$rand]}"
38-
i="${i}" # simply to get rid of shellcheck complaints
3939
done
4040
echo "${name}"
4141
}

‎tests/00.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ set -u
55
set -o pipefail
66

77
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
8-
DOCKER_NAME="${1}"
9-
ARCH="${2}"
8+
9+
IMAGE="${1}"
10+
#NAME="${2}"
11+
#VERSION="${3}"
12+
TAG="${4}"
13+
ARCH="${5}"
1014

1115

1216
###
1317
### Load Library
1418
###
15-
# shellcheck disable=SC1090
16-
. ${CWD}/.lib.sh
19+
# shellcheck disable=SC1091
20+
. "${CWD}/.lib.sh"
1721

1822

1923

@@ -35,7 +39,7 @@ run "docker run -d --rm --platform ${ARCH} \
3539
-e DEBUG_RUNTIME=1 \
3640
-e NEW_UID=$( id -u ) \
3741
-e NEW_GID=$( id -g ) \
38-
--name ${RAND_NAME} ${DOCKER_NAME}"
42+
--name ${RAND_NAME} ${IMAGE}:${TAG}"
3943

4044

4145
###

‎tests/01.sh

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ set -u
55
set -o pipefail
66

77
CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
8-
DOCKER_NAME="${1}"
9-
ARCH="${2}"
8+
9+
IMAGE="${1}"
10+
#NAME="${2}"
11+
#VERSION="${3}"
12+
TAG="${4}"
13+
ARCH="${5}"
1014

1115

1216
###
1317
### Load Library
1418
###
15-
# shellcheck disable=SC1090
16-
. ${CWD}/.lib.sh
19+
# shellcheck disable=SC1091
20+
. "${CWD}/.lib.sh"
1721

1822

1923

@@ -45,7 +49,7 @@ run "docker run -d --rm --platform ${ARCH} \
4549
-e PHP_FPM_SERVER_ADDR=${RAND_NAME1} \
4650
-e PHP_FPM_SERVER_PORT=9000 \
4751
--link ${RAND_NAME1} \
48-
--name ${RAND_NAME2} ${DOCKER_NAME}"
52+
--name ${RAND_NAME2} ${IMAGE}:${TAG}"
4953

5054

5155
###

‎tests/start-ci.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ IFS=$'\n'
1313
# Current directory
1414
CWD="$( dirname "${0}" )"
1515
IMAGE="${1}"
16-
ARCH="${2:-linux/amd64}"
16+
NAME="${2}"
17+
VERSION="${3}"
18+
TAG="${4}"
19+
ARCH="${5}"
1720

1821
declare -a TESTS=()
1922

2023

24+
25+
2126
###
2227
### Run tests
2328
###
@@ -30,12 +35,14 @@ done
3035

3136
# Start a single test
3237
if [ "${#}" -eq "3" ]; then
33-
sh -c "${TESTS[${2}]} ${IMAGE} ${ARCH}"
38+
sh -c "${TESTS[${2}]} ${IMAGE} ${NAME} ${VERSION} ${TAG} ${ARCH}"
3439

3540
# Run all tests
3641
else
3742
for i in "${TESTS[@]}"; do
38-
echo "sh -c ${CWD}/${i} ${IMAGE} ${ARCH}"
39-
sh -c "${i} ${IMAGE} ${ARCH}"
43+
echo "################################################################################"
44+
echo "# [${CWD}/${i}] ${IMAGE}:${TAG} ${NAME}-${VERSION} (${ARCH})"
45+
echo "################################################################################"
46+
sh -c "${i} ${IMAGE} ${NAME} ${VERSION} ${TAG} ${ARCH}"
4047
done
4148
fi

0 commit comments

Comments
 (0)
Please sign in to comment.