build docker images: static NGINX #21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 'build docker images: static NGINX' | |
| on: | |
| push: | |
| #branches: | |
| # - 'main' | |
| # - 'master' | |
| paths: | |
| - 'static-nginx.Dockerfile' | |
| - 'static-nginx.unprivileged.Dockerfile' | |
| - '.github/workflows/build_docker_images-static-nginx.yaml' | |
| workflow_dispatch: | |
| #schedule: | |
| # - cron: '30 5 23 * *' # At 05:30 on day-of-month 28. | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Shell-Script | |
| id: script | |
| run: | | |
| BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
| BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}" | |
| COMMIT_HASH=${GITHUB_SHA::7} | |
| GIT_URL=$(echo "${GITHUB_SERVER_URL}" | awk -F/ '{print $3}' | sed 's/\/*$//') | |
| GIT_URL=$(echo "$GIT_URL" | sed 's/github\.com/ghcr\.io/g') # GIT_URL switch to ghcr.io registry for GitHub | |
| GIT_REPO=${GITHUB_REPOSITORY,,} | |
| GIT_REPO_SHORT=${GIT_REPO#*/} | |
| GIT_REPO_SHORT=${GIT_REPO_SHORT#"docker-"} | |
| DOCKER_REPO=${{ secrets.DOCKER_USERNAME }}/${GIT_REPO_SHORT} | |
| REDHAT_QUAY_REPO=${{ secrets.REDHAT_QUAY_USERNAME }}/${GIT_REPO_SHORT} | |
| #echo "ENVs: BUILD_DATE=${BUILD_DATE}, BUILD_DATE_NUMERIC=${BUILD_DATE_NUMERIC}, COMMIT_HASH=${COMMIT_HASH}, GIT_URL=${GIT_URL}, GIT_REPO=${GIT_REPO}" | |
| # Set output parameters to action. | |
| echo "build_date=${BUILD_DATE}" >> "$GITHUB_OUTPUT" | |
| echo "build_date_numeric=${BUILD_DATE_NUMERIC}" >> "$GITHUB_OUTPUT" | |
| echo "commit_hash=${COMMIT_HASH}" >> "$GITHUB_OUTPUT" | |
| echo "git_url=${GIT_URL}" >> "$GITHUB_OUTPUT" | |
| echo "git_repo=${GIT_REPO}" >> "$GITHUB_OUTPUT" | |
| echo "docker_repo=${DOCKER_REPO}" >> "$GITHUB_OUTPUT" | |
| echo "redhat_quay_repo=${REDHAT_QUAY_REPO}" >> "$GITHUB_OUTPUT" | |
| # build Versions | |
| PCRE2_VERSION=$(curl -s https://api.github.com/repos/PCRE2Project/pcre2/releases/latest | grep 'tag_name' | cut -d\" -f4 | sed 's/^pcre2-//') | |
| ZLIB_VERSION=$(curl -s https://api.github.com/repos/madler/zlib/releases/latest | grep 'tag_name' | cut -d\" -f4 | sed 's/^v//') | |
| #OPENSSL_VERSION=$(curl -s https://api.github.com/repos/openssl/openssl/releases/latest | grep 'tag_name' | cut -d\" -f4 | sed 's/^openssl-//') | |
| #OPENSSL_VERSION=$(curl -s https://api.github.com/repos/openssl/openssl/tags | jq -r '.[].name' | grep -E '^openssl-[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^openssl-//' | sort -V -r | grep '^3\.5\.' | head -n1) | |
| OPENSSL_VERSION=$(curl -s https://api.github.com/repos/openssl/openssl/tags | grep name | grep 'openssl-[0-9]\+\.[0-9]\+\.[0-9]\+"' | sed -E 's/.*openssl-([0-9]+\.[0-9]+\.[0-9]+).*/\1/' | sort -Vr | grep '^3\.5\.' | head -n1) | |
| NGINX_VERSION=$(curl -s https://api.github.com/repos/nginx/nginx/releases/latest | grep 'tag_name' | cut -d\" -f4 | sed 's/^release-//') | |
| echo "pcre2_version=${PCRE2_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "zlib_version=${ZLIB_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "openssl_version=${OPENSSL_VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "nginx_version=${NGINX_VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Set up QEMU | |
| id: qemu | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| image: tonistiigi/binfmt:latest | |
| platforms: all | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GIT Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ steps.script.outputs.git_url }} | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to DockerHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Login to RED HAT Quay.io Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: quay.io | |
| username: ${{ secrets.REDHAT_QUAY_USERNAME }} | |
| password: ${{ secrets.REDHAT_QUAY_PASSWORD }} | |
| - name: Build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| builder: ${{ steps.buildx.outputs.name }} | |
| context: . | |
| file: ./static-nginx.Dockerfile | |
| platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
| push: true | |
| target: binary | |
| build-args: | | |
| BUILD_DATE=${{steps.script.outputs.build_date}} | |
| VCS_REF=${{steps.script.outputs.commit_hash}} | |
| PCRE2_VERSION=${{steps.script.outputs.pcre2_version}} | |
| ZLIB_VERSION=${{steps.script.outputs.zlib_version}} | |
| OPENSSL_VERSION=${{steps.script.outputs.openssl_version}} | |
| NGINX_VERSION=${{steps.script.outputs.nginx_version}} | |
| tags: | | |
| docker.io/${{steps.script.outputs.docker_repo}}:static-nginx | |
| docker.io/${{steps.script.outputs.docker_repo}}:static-nginx-${{steps.script.outputs.commit_hash}} | |
| docker.io/${{steps.script.outputs.docker_repo}}:static-nginx-${{steps.script.outputs.nginx_version}} | |
| quay.io/${{steps.script.outputs.redhat_quay_repo}}:static-nginx | |
| ${{steps.script.outputs.git_url}}/${{steps.script.outputs.git_repo}}:static-nginx | |
| - name: Build-unprivileged | |
| uses: docker/build-push-action@v6 | |
| with: | |
| builder: ${{ steps.buildx.outputs.name }} | |
| context: . | |
| file: ./static-nginx.unprivileged.Dockerfile | |
| platforms: linux/amd64,linux/arm64,linux/arm/v7 | |
| push: true | |
| target: binary | |
| build-args: | | |
| BUILD_DATE=${{steps.script.outputs.build_date}} | |
| VCS_REF=${{steps.script.outputs.commit_hash}} | |
| PCRE2_VERSION=${{steps.script.outputs.pcre2_version}} | |
| ZLIB_VERSION=${{steps.script.outputs.zlib_version}} | |
| OPENSSL_VERSION=${{steps.script.outputs.openssl_version}} | |
| NGINX_VERSION=${{steps.script.outputs.nginx_version}} | |
| tags: | | |
| docker.io/${{steps.script.outputs.docker_repo}}:static-nginx-unprivileged | |
| docker.io/${{steps.script.outputs.docker_repo}}:static-nginx-unprivileged-${{steps.script.outputs.commit_hash}} | |
| docker.io/${{steps.script.outputs.docker_repo}}:static-nginx-unprivileged-${{steps.script.outputs.nginx_version}} | |
| quay.io/${{steps.script.outputs.redhat_quay_repo}}:static-nginx-unprivileged | |
| ${{steps.script.outputs.git_url}}/${{steps.script.outputs.git_repo}}:static-nginx-unprivileged |