redirect server pages to the overview while the server is in a confli… #81
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: Docker | |
| on: | |
| push: | |
| branches: | |
| - main | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| # ghcr requires lowercase repository names so we cannot use github.repository | |
| # directly which preserves the original casing of Rotten-Division. | |
| IMAGE_NAME: rotten-division/panel | |
| jobs: | |
| build-php-base: | |
| name: Build PHP base image on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| arch: amd64 | |
| platform: linux/amd64 | |
| - os: ubuntu-24.04-arm | |
| arch: arm64 | |
| platform: linux/arm64 | |
| steps: | |
| - name: Code checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Docker buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build the base PHP image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile.base | |
| push: false | |
| load: true | |
| platforms: ${{ matrix.platform }} | |
| tags: base-php:${{ matrix.arch }} | |
| cache-from: type=gha,scope=base-php-${{ matrix.arch }} | |
| cache-to: type=gha,scope=base-php-${{ matrix.arch }} | |
| - name: Export image to file | |
| run: docker save -o base-php-${{ matrix.arch }}.tar base-php:${{ matrix.arch }} | |
| - name: Push the docker build to the artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: base-php-${{ matrix.arch }}.tar | |
| path: base-php-${{ matrix.arch }}.tar | |
| retention-days: 7 | |
| # build the final image once per native arch so we never run yarn or | |
| # composer through qemu, then merge the per arch digests into a single | |
| # multi arch manifest in the merge job below. | |
| build-and-push: | |
| name: Build and Push (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.os }} | |
| needs: build-php-base | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| arch: amd64 | |
| platform: linux/amd64 | |
| - os: ubuntu-24.04-arm | |
| arch: arm64 | |
| platform: linux/arm64 | |
| services: | |
| registry: | |
| image: registry:2 | |
| ports: | |
| - 5000:5000 | |
| if: "github.ref != 'refs/heads/main' || (!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip'))" | |
| steps: | |
| - name: Code checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Docker buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver-opts: network=host | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Build Information | |
| id: build_info | |
| run: | | |
| echo "version_tag=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT | |
| echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Download the per arch base PHP image | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: base-php-${{ matrix.arch }}.tar | |
| - name: Load base image into the local registry | |
| run: | | |
| docker load -i base-php-${{ matrix.arch }}.tar | |
| docker tag base-php:${{ matrix.arch }} localhost:5000/base-php:${{ matrix.arch }} | |
| docker push localhost:5000/base-php:${{ matrix.arch }} | |
| rm base-php-${{ matrix.arch }}.tar | |
| - name: Build and Push by digest (tag) | |
| uses: docker/build-push-action@v6 | |
| id: build_tag | |
| if: "github.event_name == 'release' && github.event.action == 'published'" | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: ${{ matrix.platform }} | |
| build-args: | | |
| APP_VERSION=${{ steps.build_info.outputs.version_tag }} | |
| outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true | |
| cache-from: type=gha,scope=tagged-${{ matrix.arch }} | |
| cache-to: type=gha,scope=tagged-${{ matrix.arch }},mode=max | |
| - name: Build and Push by digest (main) | |
| uses: docker/build-push-action@v6 | |
| id: build_main | |
| if: "(github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'" | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: ${{ matrix.platform }} | |
| build-args: | | |
| APP_VERSION=canary-${{ steps.build_info.outputs.short_sha }} | |
| outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true | |
| cache-from: type=gha,scope=main-${{ matrix.arch }} | |
| cache-to: type=gha,scope=main-${{ matrix.arch }},mode=max | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build_tag.outputs.digest || steps.build_main.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ matrix.arch }} | |
| path: /tmp/digests/* | |
| retention-days: 1 | |
| if-no-files-found: error | |
| merge: | |
| name: Merge per arch digests into the multi arch manifest | |
| runs-on: ubuntu-24.04 | |
| needs: build-and-push | |
| permissions: | |
| contents: read | |
| packages: write | |
| if: "github.ref != 'refs/heads/main' || (!contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip'))" | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| - name: Setup Docker buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Docker metadata | |
| id: docker_meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| flavor: | | |
| latest=false | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.action == 'published' && github.event.release.prerelease == false }} | |
| type=raw,value=prod,enable=${{ github.event_name == 'release' && github.event.action == 'published' && github.event.release.prerelease == false }} | |
| type=ref,event=tag | |
| type=ref,event=branch | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create the multi arch manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) | |
| - name: Inspect the published manifest | |
| run: | | |
| for tag in $(jq -cr '.tags | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON"); do | |
| echo "tag: $tag" | |
| docker buildx imagetools inspect "$tag" | |
| done |