From fe7410600c9b46d99a99958839a10f86d0b6426d Mon Sep 17 00:00:00 2001 From: cytopia Date: Tue, 8 Mar 2022 15:53:58 +0100 Subject: [PATCH 1/3] New project structure --- .github/dependabot.yml | 1 + .github/labels.yml | 12 ++ .github/release-drafter.yml | 33 ++++ .github/workflows/action_branch.yml | 34 +++++ .github/workflows/action_pull_request.yml | 36 +++++ .github/workflows/action_schedule.yml | 36 +++++ .github/workflows/build.yml | 166 -------------------- .github/workflows/contributor.yml | 86 ----------- .github/workflows/lint.yml | 19 +-- .github/workflows/nightly.yml | 175 ---------------------- .github/workflows/params.yml | 85 +++++++++++ .github/workflows/release-drafter.yml | 19 +++ .github/workflows/repository.yml | 25 ++++ .gitignore | 88 +---------- .yamllint | 13 ++ Makefile | 140 ++++++----------- README.md | 2 +- build/gen-readme.sh | 10 +- data/docker-entrypoint.d/01-uid-gid.sh | 8 +- data/docker-entrypoint.d/08-cert-gen.sh | 10 +- tests/.lib.sh | 4 +- tests/00.sh | 14 +- tests/01.sh | 14 +- tests/start-ci.sh | 15 +- 24 files changed, 388 insertions(+), 657 deletions(-) create mode 100644 .github/labels.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/action_branch.yml create mode 100644 .github/workflows/action_pull_request.yml create mode 100644 .github/workflows/action_schedule.yml delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/contributor.yml delete mode 100644 .github/workflows/nightly.yml create mode 100644 .github/workflows/params.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/repository.yml create mode 100644 .yamllint diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2c7d170..8e85703 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,4 @@ +--- version: 2 updates: # Maintain dependencies for GitHub Actions diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..9a507e8 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,12 @@ +# The labels in this file are automatically synced with the repository +# using the micnncim/action-label-syncer action. +--- +- name: C-dependency + color: 1abc9c + description: "Category: Dependency" +- name: PR-block + color: 3498db + description: "Pull Request: Do not merge" +- name: PR-merge + color: 3498db + description: "Pull Request: Merge when ready" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..03439b4 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,33 @@ +--- +name-template: '$RESOLVED_VERSION 🌈' +tag-template: '$RESOLVED_VERSION' +version-template: '$MAJOR.$MINOR' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: minor +template: | + ## Changes + + $CHANGES diff --git a/.github/workflows/action_branch.yml b/.github/workflows/action_branch.yml new file mode 100644 index 0000000..b102724 --- /dev/null +++ b/.github/workflows/action_branch.yml @@ -0,0 +1,34 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: build + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + push: + + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master + with: + enabled: true + can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} + name: ${{ needs.params.outputs.name }} + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.github/workflows/action_pull_request.yml b/.github/workflows/action_pull_request.yml new file mode 100644 index 0000000..a4e3e96 --- /dev/null +++ b/.github/workflows/action_pull_request.yml @@ -0,0 +1,36 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: build + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + pull_request: + + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + # Only run for forks (contributor) + if: github.event.pull_request.head.repo.fork + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master + with: + enabled: true + can_deploy: false + name: ${{ needs.params.outputs.name }} + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: "" + dockerhub_password: "" diff --git a/.github/workflows/action_schedule.yml b/.github/workflows/action_schedule.yml new file mode 100644 index 0000000..80d3d38 --- /dev/null +++ b/.github/workflows/action_schedule.yml @@ -0,0 +1,36 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: nightly + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + # Runs daily + schedule: + - cron: '0 0 * * *' + + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-arch.yml@master + with: + enabled: true + can_deploy: true + name: ${{ needs.params.outputs.name }} + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 7a6341b..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,166 +0,0 @@ ---- - -# ------------------------------------------------------------------------------------------------- -# Job Name -# ------------------------------------------------------------------------------------------------- -name: build - - -# ------------------------------------------------------------------------------------------------- -# When to run -# ------------------------------------------------------------------------------------------------- -on: - # Runs on Push - push: - - -jobs: - - # ----------------------------------------------------------------------------------------------- - # Job (1/2): BUILD - # ----------------------------------------------------------------------------------------------- - build: - name: "[ ${{ matrix.version }} (${{ matrix.arch }}) ]" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - 'Apache 2.4' - arch: - - 'linux/amd64' - - 'linux/arm64' - - 'linux/386' - - 'linux/arm/v7' - - 'linux/arm/v6' - steps: - - # ------------------------------------------------------------ - # Setup repository - # ------------------------------------------------------------ - - name: "[SETUP] Checkout repository" - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: "[SETUP] Setup QEMU environment" - uses: docker/setup-qemu-action@v1 - with: - image: tonistiigi/binfmt:latest - platforms: all - - - name: "[SETUP] Determine Docker tag" - id: tag - uses: cytopia/docker-tag@v0.3 - - # ------------------------------------------------------------ - # Build - # ------------------------------------------------------------ - - name: Build - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make build ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - - # ------------------------------------------------------------ - # Test - # ------------------------------------------------------------ - - name: "[TEST] Docker Image" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make test ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - - - name: "[TEST] Update README" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make update-readme ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - - # ------------------------------------------------------------ - # Deploy - # ------------------------------------------------------------ - - name: "[DEPLOY] Login" - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: "[DEPLOY] Publish architecture image (only repo owner)" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions - if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id - && ( - (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) - || - (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) - || - (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) - ) - - # ----------------------------------------------------------------------------------------------- - # Job (2/2): DEPLOY - # ----------------------------------------------------------------------------------------------- - deploy: - needs: [build] - name: Deploy - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - 'Apache 2.4' - steps: - - # ------------------------------------------------------------ - # Setup repository - # ------------------------------------------------------------ - - name: "[SETUP] Checkout repository" - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: "[SETUP] Determine Docker tag" - id: tag - uses: cytopia/docker-tag@v0.3 - - # ------------------------------------------------------------ - # Deploy - # ------------------------------------------------------------ - - name: "[DEPLOY] Login" - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: "[DEPLOY] Create Docker manifest" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6" - - - name: "[DEPLOY] Publish Docker manifest (only repo owner)" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make manifest-push TAG=${{ steps.tag.outputs.docker-tag }} - # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions - if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id - && ( - (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) - || - (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) - || - (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) - ) diff --git a/.github/workflows/contributor.yml b/.github/workflows/contributor.yml deleted file mode 100644 index cd568c4..0000000 --- a/.github/workflows/contributor.yml +++ /dev/null @@ -1,86 +0,0 @@ ---- - -# ------------------------------------------------------------------------------------------------- -# Job Name -# ------------------------------------------------------------------------------------------------- -name: build - - -# ------------------------------------------------------------------------------------------------- -# When to run -# ------------------------------------------------------------------------------------------------- -on: - # Runs on Pull Requests - pull_request: - - -jobs: - - # ----------------------------------------------------------------------------------------------- - # Job (1/2): BUILD - # ----------------------------------------------------------------------------------------------- - build: - name: "[ ${{ matrix.version }} (${{ matrix.arch }}) ]" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - 'Apache 2.4' - arch: - - 'linux/amd64' - - 'linux/arm64' - - 'linux/386' - - 'linux/arm/v7' - - 'linux/arm/v6' - # Only run for forks (contributor) - if: ${{ github.event.pull_request.head.repo.fork }} - steps: - - # ------------------------------------------------------------ - # Setup repository - # ------------------------------------------------------------ - - name: "[SETUP] Checkout repository" - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: "[SETUP] Setup QEMU environment" - uses: docker/setup-qemu-action@v1 - with: - image: tonistiigi/binfmt:latest - platforms: all - - - name: "[SETUP] Determine Docker tag" - id: tag - uses: cytopia/docker-tag@v0.3 - - # ------------------------------------------------------------ - # Build - # ------------------------------------------------------------ - - name: Build - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make build ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - - # ------------------------------------------------------------ - # Test - # ------------------------------------------------------------ - - name: "[TEST] Docker Image" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make test ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - - - name: "[TEST] Update README" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make update-readme ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 57a401b..f83d099 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,21 +19,4 @@ on: # ------------------------------------------------------------------------------------------------- jobs: lint: - name: "Lint" - runs-on: ubuntu-latest - steps: - # ------------------------------------------------------------ - # Setup repository - # ------------------------------------------------------------ - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - # ------------------------------------------------------------ - # Lint repository - # ------------------------------------------------------------ - - name: Lint workflow - id: vars - run: | - make lint-workflow + uses: devilbox/github-actions/.github/workflows/lint-generic.yml@master diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml deleted file mode 100644 index 8690e45..0000000 --- a/.github/workflows/nightly.yml +++ /dev/null @@ -1,175 +0,0 @@ ---- - -# ------------------------------------------------------------------------------------------------- -# Job Name -# ------------------------------------------------------------------------------------------------- -name: nightly - - -# ------------------------------------------------------------------------------------------------- -# When to run -# ------------------------------------------------------------------------------------------------- -on: - # Runs daily - schedule: - - cron: '0 0 * * *' - - -jobs: - - # ----------------------------------------------------------------------------------------------- - # Job: BUILD - # ----------------------------------------------------------------------------------------------- - build: - name: "[ ${{ matrix.version }} (${{ matrix.arch }}) ] (ref: ${{ matrix.refs }})" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - 'Apache 2.4' - arch: - - 'linux/amd64' - - 'linux/arm64' - - 'linux/386' - - 'linux/arm/v7' - - 'linux/arm/v6' - refs: - - 'master' - - '0.41' - steps: - - # ------------------------------------------------------------ - # Setup repository - # ------------------------------------------------------------ - - name: "[SETUP] Checkout repository" - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: ${{ matrix.refs }} - - - name: "[SETUP] Setup QEMU environment" - uses: docker/setup-qemu-action@v1 - with: - image: tonistiigi/binfmt:latest - platforms: all - - - name: "[SETUP] Determine Docker tag" - id: tag - uses: cytopia/docker-tag@v0.3 - - # ------------------------------------------------------------ - # Build - # ------------------------------------------------------------ - - name: Build - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make build ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - - # ------------------------------------------------------------ - # Test - # ------------------------------------------------------------ - - name: "[TEST] Docker Image" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make test ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - - - name: "[TEST] Update README" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make update-readme ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - - # ------------------------------------------------------------ - # Deploy - # ------------------------------------------------------------ - - name: "[DEPLOY] Login" - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: "[DEPLOY] Publish architecture image (only repo owner)" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make push-arch TAG=${{ steps.tag.outputs.docker-tag }} ARCH=${ARCH} - env: - ARCH: ${{ matrix.arch }} - # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions - if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id - && ( - (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) - || - (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) - || - (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) - ) - - # ----------------------------------------------------------------------------------------------- - # Job (2/2): DEPLOY - # ----------------------------------------------------------------------------------------------- - deploy: - needs: [build] - name: "[ Deploy (ref: ${{ matrix.refs }})" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - 'Apache 2.4' - refs: - - 'master' - - '0.41' - steps: - - # ------------------------------------------------------------ - # Setup repository - # ------------------------------------------------------------ - - name: "[SETUP] Checkout repository" - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: ${{ matrix.refs }} - - - name: "[SETUP] Determine Docker tag" - id: tag - uses: cytopia/docker-tag@v0.3 - - # ------------------------------------------------------------ - # Deploy - # ------------------------------------------------------------ - - name: "[DEPLOY] Login" - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: "[DEPLOY] Create Docker manifest" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make manifest-create TAG=${{ steps.tag.outputs.docker-tag }} ARCH="linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6" - - - name: "[DEPLOY] Publish Docker manifest (only repo owner)" - uses: cytopia/shell-command-retry-action@v0.1 - with: - command: | - make manifest-push TAG=${{ steps.tag.outputs.docker-tag }} - # https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions - if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id - && ( - (github.event_name == 'schedule' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) - || - (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))) - || - (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release-')) - ) diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml new file mode 100644 index 0000000..447e4cd --- /dev/null +++ b/.github/workflows/params.yml @@ -0,0 +1,85 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: params + + +# ------------------------------------------------------------------------------------------------- +# Custom Variables +# ------------------------------------------------------------------------------------------------- +env: + NAME: PHP + MATRIX: >- + [ + { + "NAME": "Apache", + "VERSION": ["2.4"], + "ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"] + + } + ] + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + workflow_call: + outputs: + name: + description: "The project name" + value: ${{ jobs.params.outputs.name }} + matrix: + description: "The determined version matrix" + value: ${{ jobs.params.outputs.matrix }} + refs: + description: "The determined git ref matrix (only during scheduled run)" + value: ${{ jobs.params.outputs.refs }} + +jobs: + params: + runs-on: ubuntu-latest + + outputs: + name: ${{ steps.set-name.outputs.name }} + matrix: ${{ steps.set-matrix.outputs.matrix }} + refs: ${{ steps.set-refs.outputs.matrix }} + + steps: + - name: "Set Name" + id: set-name + run: | + echo '::set-output name=name::${{ env.NAME }}' + + - name: "[Set-Output] Matrix" + id: set-matrix + run: | + echo "::set-output name=matrix::$( echo '${{ env.MATRIX }}' | jq -M -c )" + + - name: "[Set-Output] Matrix 'Refs' (master branch and latest tag)" + id: set-refs + uses: cytopia/git-ref-matrix-action@v0.1.2 + with: + repository_default_branch: master + branches: master + num_latest_tags: 1 + if: github.event_name == 'schedule' + + - name: "[DEBUG] Show settings'" + run: | + echo 'Name' + echo '--------------------' + echo '${{ steps.set-name.outputs.name }}' + echo + + echo 'Matrix' + echo '--------------------' + echo '${{ steps.set-matrix.outputs.matrix }}' + echo + + echo 'Matrix: Refs' + echo '--------------------' + echo '${{ steps.set-matrix-refs.outputs.matrix }}' + echo diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..1a63d7e --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,19 @@ +--- +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + publish: true + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_DRAFTER_TOKEN }} diff --git a/.github/workflows/repository.yml b/.github/workflows/repository.yml new file mode 100644 index 0000000..ca21e7d --- /dev/null +++ b/.github/workflows/repository.yml @@ -0,0 +1,25 @@ +--- +name: Repository + +on: + push: + branches: + - master + paths: + - .github/labels.yml + +jobs: + labels: + name: Labels + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Sync labels + uses: micnncim/action-label-syncer@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + manifest: .github/labels.yml diff --git a/.gitignore b/.gitignore index cc3a8c2..7457dff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,86 +1,2 @@ -# Note: -# To effectively apply the changes you will have -# to re-index the git index (if there are already -# commited files) -# -# $ git rm -r --cached . -# $ git add . -# $ git commit -m ".gitignore index rebuild" -# - - -###################################### -# CUSTOM -###################################### - - -###################################### -# GENERIC -###################################### - -###### std ###### -.lock -*.log - -###### patches/diffs ###### -*.patch -*.diff -*.orig -*.rej - - -###################################### -# Operating Systems -###################################### - -###### OSX ###### -._* -.DS* -.Spotlight-V100 -.Trashes - -###### Windows ###### -Thumbs.db -ehthumbs.db -Desktop.ini -$RECYCLE.BIN/ -*.lnk -*.shortcut - -###################################### -# Editors -###################################### - -###### Sublime ###### -*.sublime-workspace -*.sublime-project - -###### Eclipse ###### -.classpath -.buildpath -.project -.settings/ - -###### Netbeans ###### -/nbproject/ - -###### Intellij IDE ###### -.idea/ -.idea_modules/ - -###### vim ###### -*.swp -*.swo -*.swn -*.swm -*~ - -###### TextMate ###### -.tm_properties -*.tmproj - -###### BBEdit ###### -*.bbprojectd -*.bbproject - -.vagrant +Makefile.docker +Makefile.lint diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..07e4861 --- /dev/null +++ b/.yamllint @@ -0,0 +1,13 @@ +--- +extends: default + +ignore: | + .yamllint + + +rules: + truthy: + allowed-values: ['true', 'false', 'yes', 'no'] + check-keys: False + level: error + line-length: disable diff --git a/Makefile b/Makefile index 6b17ef4..6d24b8b 100644 --- a/Makefile +++ b/Makefile @@ -2,17 +2,35 @@ ifneq (,) .error This Makefile requires GNU Make. endif +# Ensure additional Makefiles are present +MAKEFILES = Makefile.docker Makefile.lint +$(MAKEFILES): URL=https://raw.githubusercontent.com/devilbox/makefiles/master/$(@) +$(MAKEFILES): + @if ! (curl --fail -sS -o $(@) $(URL) || wget -O $(@) $(URL)); then \ + echo "Error, curl or wget required."; \ + echo "Exiting."; \ + false; \ + fi +include $(MAKEFILES) + +# Set default Target +.DEFAULT_GOAL := help + # ------------------------------------------------------------------------------------------------- -# Docker configuration +# Default configuration # ------------------------------------------------------------------------------------------------- +# Own vars +TAG = latest -DIR = . -FILE = Dockerfile -IMAGE = devilbox/apache-2.4 -TAG = latest -ARCH = linux/amd64 -NO_CACHE = +# Makefile.docker overwrites +NAME = Apache +VERSION = 2.4 +IMAGE = devilbox/apache-2.4 +DIR = . +FILE = Dockerfile +DOCKER_TAG = $(TAG) +ARCH = linux/amd64 # ------------------------------------------------------------------------------------------------- @@ -20,79 +38,42 @@ NO_CACHE = # ------------------------------------------------------------------------------------------------- .PHONY: help help: - @echo "lint Lint project files and repository" + @echo "lint Lint project files and repository" @echo - @echo "build Build Docker image" - @echo "rebuild Build Docker image without cache" + @echo "build [ARCH=...] [TAG=...] Build Docker image" + @echo "rebuild [ARCH=...] [TAG=...] Build Docker image without cache" + @echo "push [ARCH=...] [TAG=...] Push Docker image to Docker hub" @echo - @echo "manifest-create Create multi-arch manifest" - @echo "manifest-push Push multi-arch manifest" + @echo "manifest-create [ARCHES=...] [TAG=...] Create multi-arch manifest" + @echo "manifest-push [TAG=...] Push multi-arch manifest" @echo - @echo "test Test built Docker image" - @echo "update-readme Update README.md with PHP modules" + @echo "test [ARCH=...] Test built Docker image" @echo - @echo "tag [TAG=...] Retag Docker image" - @echo "login USER=... PASS=... Login to Docker hub" - @echo "push [TAG=...] Push Docker image to Docker hub" - - -# ------------------------------------------------------------------------------------------------- -# Lint Targets -# ------------------------------------------------------------------------------------------------- -.PHONY: lint -lint: lint-workflow - -.PHONY: lint-workflow -lint-workflow: - @\ - GIT_CURR_MAJOR="$$( git tag | sort -V | tail -1 | sed 's|\.[0-9]*$$||g' )"; \ - GIT_CURR_MINOR="$$( git tag | sort -V | tail -1 | sed 's|^[0-9]*\.||g' )"; \ - GIT_NEXT_TAG="$${GIT_CURR_MAJOR}.$$(( GIT_CURR_MINOR + 1 ))"; \ - grep 'refs:' -A 20 .github/workflows/nightly.yml \ - | grep '^ -' \ - | grep -v master \ - | while read -r i; do \ - if ! echo "$${i}" | grep -- "- '$${GIT_NEXT_TAG}'" >/dev/null; then \ - echo "[ERR] New Tag required in .github/workflows/nightly.yml: $${GIT_NEXT_TAG}"; \ - exit 1; \ - else \ - echo "[OK] Git Tag present in .github/workflows/nightly.yml: $${GIT_NEXT_TAG}"; \ - fi \ - done # ------------------------------------------------------------------------------------------------- -# Build Targets +# Docker Targets # ------------------------------------------------------------------------------------------------- .PHONY: build -build: - docker build --platform=$(ARCH) $(NO_CACHE) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) - ./build/gen-readme.sh $(IMAGE) $(ARCH) +build: ARGS=--build-arg ARCH=$(ARCH) +build: docker-arch-build .PHONY: rebuild -rebuild: NO_CACHE=--no-cache -rebuild: pull-base-image -rebuild: build +rebuild: ARGS=--build-arg ARCH=$(ARCH) +rebuild: docker-arch-rebuild + +.PHONY: push +push: docker-arch-push # ------------------------------------------------------------------------------------------------- # Manifest Targets # ------------------------------------------------------------------------------------------------- .PHONY: manifest-create -manifest-create: - @echo "docker manifest create \ - $(IMAGE):$(TAG) \ - $$( echo $(ARCH) | sed 's/,/ /g' | sed 's|/|-|g' | xargs -n1 sh -c 'printf -- " --amend $(IMAGE):$(TAG)-manifest-$${1}"' -- )" \ - | sed 's/\s\s*/ /g' \ - | sed 's/--/\\\n --/g' - @echo "docker manifest create \ - $(IMAGE):$(TAG) \ - $$( echo $(ARCH) | sed 's/,/ /g' | sed 's|/|-|g' | xargs -n1 sh -c 'printf -- " --amend $(IMAGE):$(TAG)-manifest-$${1}"' -- )" \ - | bash +manifest-create: docker-manifest-create .PHONY: manifest-push -manifest-push: - docker manifest push $(IMAGE):$(TAG) +manifest-push: docker-manifest-push # ------------------------------------------------------------------------------------------------- @@ -100,40 +81,7 @@ manifest-push: # ------------------------------------------------------------------------------------------------- .PHONY: test test: - ./tests/start-ci.sh $(IMAGE) $(ARCH) + ./tests/start-ci.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH) .PHONY: update-readme - ./build/gen-readme.sh $(IMAGE) $(ARCH) - -# ------------------------------------------------------------------------------------------------- -# Deploy Targets -# ------------------------------------------------------------------------------------------------- -.PHONY: tag -tag: - docker tag $(IMAGE) $(IMAGE):$(TAG) - -.PHONY: login -login: - yes | docker login --username $(USER) --password $(PASS) - -.PHONY: push -push: - @$(MAKE) tag TAG=$(TAG) - docker push $(IMAGE):$(TAG) - -.PHONY: push-arch -push-arch: - $(MAKE) tag TAG=$(TAG)-manifest-$(subst /,-,$(ARCH)) - docker push $(IMAGE):$(TAG)-manifest-$(subst /,-,$(ARCH)) - - -# ------------------------------------------------------------------------------------------------- -# Helper Targets -# ------------------------------------------------------------------------------------------------- -.PHONY: enter -enter: - docker run --rm --platform=$(ARCH) -it --entrypoint=bash $(ARG) $(IMAGE) - -.PHONY: pull-base-image -pull-base-image: - @docker pull $(shell grep FROM Dockerfile | sed 's/^FROM\s*//g';) + ./build/gen-readme.sh $(IMAGE) $(NAME) $(VERSION) $(DOCKER_TAG) $(ARCH) diff --git a/README.md b/README.md index 6588e1f..cae85dd 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ This Docker container adds a lot of injectables in order to customize it to your | MAIN_VHOST_SSL_TYPE | string | `plain` | | | MAIN_VHOST_SSL_GEN | bool | `0` | `0`: Do not generate an ssl certificate
`1`: Generate self-signed certificate automatically | | 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) | -| 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.
Default:
`/var/www/default/htdocs`
Example:
`MAIN_VHOST_DOCROOT=www`
Doc root: `/var/www/default/www` | +| 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.
Default:
`/var/www/default/htdocs`
Example:
`MAIN_VHOST_DOCROOT=www`
Doc root: `/var/www/default/www` | | 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.
Resulting default path:
`/var/www/default/cfg` | | MAIN_VHOST_STATUS_ENABLE | bool | `0` | Enable httpd status page. | | MAIN_VHOST_STATUS_ALIAS | string | `/httpd-status` | Set the alias under which the httpd server should serve its status page. | diff --git a/build/gen-readme.sh b/build/gen-readme.sh index ed5660b..d35acdb 100755 --- a/build/gen-readme.sh +++ b/build/gen-readme.sh @@ -15,7 +15,9 @@ INFO="$( docker run --rm --platform "${ARCH}" --entrypoint=httpd "${IMAGE}" -V 2 echo "${INFO}" sed -i'' '/##[[:space:]]Version/q' "${CWD}/README.md" -echo "" >> "${CWD}/README.md" -echo '```' >> "${CWD}/README.md" -echo "${INFO}" >> "${CWD}/README.md" -echo '```' >> "${CWD}/README.md" +{ + echo ""; + echo '```'; + echo "${INFO}"; + echo '```'; +} >> "${CWD}/README.md" diff --git a/data/docker-entrypoint.d/01-uid-gid.sh b/data/docker-entrypoint.d/01-uid-gid.sh index 8159f2b..d95aeef 100755 --- a/data/docker-entrypoint.d/01-uid-gid.sh +++ b/data/docker-entrypoint.d/01-uid-gid.sh @@ -44,8 +44,8 @@ set_uid() { local uid_varname="${1}" local username="${2}" local debug="${3}" - local homedir - homedir="$( _get_homedir_by_username "${username}" )" + #local homedir + #homedir="$( _get_homedir_by_username "${username}" )" local uid= # new uid local spare_uid=9876 # spare uid to change another user to @@ -83,8 +83,8 @@ set_gid() { local gid_varname="${1}" local groupname="${2}" local debug="${3}" - local homedir - homedir="$( _get_homedir_by_groupname "${groupname}" )" + #local homedir + #homedir="$( _get_homedir_by_groupname "${groupname}" )" local gid= # new gid local spare_gid=9876 # spare gid to change another group to diff --git a/data/docker-entrypoint.d/08-cert-gen.sh b/data/docker-entrypoint.d/08-cert-gen.sh index 845091c..65e1095 100755 --- a/data/docker-entrypoint.d/08-cert-gen.sh +++ b/data/docker-entrypoint.d/08-cert-gen.sh @@ -20,10 +20,10 @@ cert_gen_generate_ca() { # Create directories if [ ! -d "$( dirname "${key}" )" ]; then - run "mkdir -p $( dirname ${key} )" "${debug}" + run "mkdir -p $( dirname "${key}" )" "${debug}" fi if [ ! -d "$( dirname "${crt}" )" ]; then - run "mkdir -p $( dirname ${crt} )" "${debug}" + run "mkdir -p $( dirname "${crt}" )" "${debug}" fi # cert-gen verbosity @@ -67,13 +67,13 @@ cert_gen_generate_cert() { # Create directories if [ ! -d "$( dirname "${key}" )" ]; then - run "mkdir -p $( dirname ${key} )" "${debug}" + run "mkdir -p $( dirname "${key}" )" "${debug}" fi if [ ! -d "$( dirname "${csr}" )" ]; then - run "mkdir -p $( dirname ${csr} )" "${debug}" + run "mkdir -p $( dirname "${csr}" )" "${debug}" fi if [ ! -d "$( dirname "${crt}" )" ]; then - run "mkdir -p $( dirname ${crt} )" "${debug}" + run "mkdir -p $( dirname "${crt}" )" "${debug}" fi # cert-gen verbosity diff --git a/tests/.lib.sh b/tests/.lib.sh index 0371aaa..42138a4 100755 --- a/tests/.lib.sh +++ b/tests/.lib.sh @@ -31,11 +31,11 @@ function get_random_name() { local len="${#chr[@]}" local name= + # shellcheck disable=SC2034 for i in {1..15}; do - rand="$( shuf -i 0-${len} -n 1 )" + rand="$( shuf -i "0-${len}" -n 1 )" rand=$(( rand - 1 )) name="${name}${chr[$rand]}" - i="${i}" # simply to get rid of shellcheck complaints done echo "${name}" } diff --git a/tests/00.sh b/tests/00.sh index f3692d0..d9ab1c9 100755 --- a/tests/00.sh +++ b/tests/00.sh @@ -5,15 +5,19 @@ set -u set -o pipefail CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" -DOCKER_NAME="${1}" -ARCH="${2}" + +IMAGE="${1}" +#NAME="${2}" +#VERSION="${3}" +TAG="${4}" +ARCH="${5}" ### ### Load Library ### -# shellcheck disable=SC1090 -. ${CWD}/.lib.sh +# shellcheck disable=SC1091 +. "${CWD}/.lib.sh" @@ -35,7 +39,7 @@ run "docker run -d --rm --platform ${ARCH} \ -e DEBUG_RUNTIME=1 \ -e NEW_UID=$( id -u ) \ -e NEW_GID=$( id -g ) \ - --name ${RAND_NAME} ${DOCKER_NAME}" + --name ${RAND_NAME} ${IMAGE}:${TAG}" ### diff --git a/tests/01.sh b/tests/01.sh index 463d5e0..1470141 100755 --- a/tests/01.sh +++ b/tests/01.sh @@ -5,15 +5,19 @@ set -u set -o pipefail CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" -DOCKER_NAME="${1}" -ARCH="${2}" + +IMAGE="${1}" +#NAME="${2}" +#VERSION="${3}" +TAG="${4}" +ARCH="${5}" ### ### Load Library ### -# shellcheck disable=SC1090 -. ${CWD}/.lib.sh +# shellcheck disable=SC1091 +. "${CWD}/.lib.sh" @@ -45,7 +49,7 @@ run "docker run -d --rm --platform ${ARCH} \ -e PHP_FPM_SERVER_ADDR=${RAND_NAME1} \ -e PHP_FPM_SERVER_PORT=9000 \ --link ${RAND_NAME1} \ - --name ${RAND_NAME2} ${DOCKER_NAME}" + --name ${RAND_NAME2} ${IMAGE}:${TAG}" ### diff --git a/tests/start-ci.sh b/tests/start-ci.sh index 959fbcf..1777030 100755 --- a/tests/start-ci.sh +++ b/tests/start-ci.sh @@ -13,11 +13,16 @@ IFS=$'\n' # Current directory CWD="$( dirname "${0}" )" IMAGE="${1}" -ARCH="${2:-linux/amd64}" +NAME="${2}" +VERSION="${3}" +TAG="${4}" +ARCH="${5}" declare -a TESTS=() + + ### ### Run tests ### @@ -30,12 +35,14 @@ done # Start a single test if [ "${#}" -eq "3" ]; then - sh -c "${TESTS[${2}]} ${IMAGE} ${ARCH}" + sh -c "${TESTS[${2}]} ${IMAGE} ${NAME} ${VERSION} ${TAG} ${ARCH}" # Run all tests else for i in "${TESTS[@]}"; do - echo "sh -c ${CWD}/${i} ${IMAGE} ${ARCH}" - sh -c "${i} ${IMAGE} ${ARCH}" + echo "################################################################################" + echo "# [${CWD}/${i}] ${IMAGE}:${TAG} ${NAME}-${VERSION} (${ARCH})" + echo "################################################################################" + sh -c "${i} ${IMAGE} ${NAME} ${VERSION} ${TAG} ${ARCH}" done fi From b8b6498c6f3fd8bdddc8e7a171cb593fedf803ba Mon Sep 17 00:00:00 2001 From: cytopia Date: Tue, 8 Mar 2022 20:23:24 +0100 Subject: [PATCH 2/3] Adjust params --- .github/workflows/params.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml index 447e4cd..bf6edfa 100644 --- a/.github/workflows/params.yml +++ b/.github/workflows/params.yml @@ -10,7 +10,7 @@ name: params # Custom Variables # ------------------------------------------------------------------------------------------------- env: - NAME: PHP + NAME: Apache MATRIX: >- [ { From 993d52bbc1aaf068c272473068b02f5bbd9ffaf9 Mon Sep 17 00:00:00 2001 From: cytopia Date: Tue, 8 Mar 2022 20:44:37 +0100 Subject: [PATCH 3/3] Make tests re-runnable --- tests/00.sh | 10 ++++++++-- tests/01.sh | 13 ++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/00.sh b/tests/00.sh index d9ab1c9..8b16b08 100755 --- a/tests/00.sh +++ b/tests/00.sh @@ -48,8 +48,14 @@ run "docker run -d --rm --platform ${ARCH} \ run "sleep 20" # Startup-time is longer on cross-platform run "docker ps" run "docker logs ${RAND_NAME}" -run "curl -sS localhost/index.html" -run "curl -sS localhost/index.html | grep 'hello world'" +if ! run "curl -sS localhost/index.html"; then + run "docker stop ${RAND_NAME}" + exit 1 +fi +if ! run "curl -sS localhost/index.html | grep 'hello world'"; then + run "docker stop ${RAND_NAME}" + exit 1 +fi ### diff --git a/tests/01.sh b/tests/01.sh index 1470141..3d9e3e5 100755 --- a/tests/01.sh +++ b/tests/01.sh @@ -59,9 +59,16 @@ run "sleep 20" # Startup-time is longer on cross-platform run "docker ps" run "docker logs ${RAND_NAME1}" run "docker logs ${RAND_NAME2}" -run "curl localhost" -run "curl localhost | grep 'hello world php'" - +if ! run "curl localhost"; then + run "docker stop ${RAND_NAME1}" + run "docker stop ${RAND_NAME2}" + exit 1 +fi +if ! run "curl localhost | grep 'hello world php'"; then + run "docker stop ${RAND_NAME1}" + run "docker stop ${RAND_NAME2}" + exit 1 +fi ### ### Cleanup