name: Docker on: pull_request: paths: - Dockerfile - .dockerignore - .github/docker/** - .github/workflows/docker.yaml - docker-compose.example.yml - composer.json - composer.lock push: branches: - 1.0-develop - 2.0-develop release: types: - published env: IMAGE: ghcr.io/pterodactyl/panel PUBLISH: ${{ github.event_name != 'pull_request' && github.ref != 'refs/heads/2.0-develop' && !contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip') }} jobs: build: name: Build (${{ matrix.platform }}) runs-on: ${{ matrix.runner }} timeout-minutes: 20 permissions: contents: read packages: write strategy: fail-fast: false matrix: include: - platform: linux/amd64 runner: ubuntu-24.04 - platform: linux/arm64 runner: ubuntu-24.04-arm steps: - name: Code checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Update version if: "github.event_name == 'release' && github.event.action == 'published'" env: REF: ${{ github.event.release.tag_name }} run: | sed -i "s/ 'version' => 'canary',/ 'version' => '${REF:1}',/" config/app.php - name: Docker metadata id: docker_meta uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: images: ${{ env.IMAGE }} - name: Setup Docker buildx uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - name: Build production image uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 with: context: . platforms: ${{ matrix.platform }} load: true tags: panel:smoke labels: ${{ steps.docker_meta.outputs.labels }} cache-from: type=gha,scope=${{ matrix.runner }} cache-to: type=gha,mode=max,scope=${{ matrix.runner }} - name: Check Compose configuration run: docker compose -f docker-compose.example.yml config --quiet - name: Exercise production services run: bash .github/docker/smoke-test.sh panel:smoke - name: Login to GitHub Container Registry if: env.PUBLISH == 'true' uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Push image by digest id: push if: env.PUBLISH == 'true' uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 with: context: . platforms: ${{ matrix.platform }} labels: ${{ steps.docker_meta.outputs.labels }} outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true cache-from: type=gha,scope=${{ matrix.runner }} - name: Export digest if: env.PUBLISH == 'true' env: DIGEST: ${{ steps.push.outputs.digest }} run: | mkdir -p "$RUNNER_TEMP/digests" touch "$RUNNER_TEMP/digests/${DIGEST#sha256:}" - name: Upload digest if: env.PUBLISH == 'true' uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: digests-${{ matrix.runner }} path: ${{ runner.temp }}/digests/* if-no-files-found: error retention-days: 1 push: name: Push needs: build runs-on: ubuntu-24.04 if: "github.event_name != 'pull_request' && github.ref != 'refs/heads/2.0-develop' && !contains(github.event.head_commit.message, 'skip docker') && !contains(github.event.head_commit.message, 'docker skip')" permissions: contents: read packages: write steps: - name: Download digests uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: path: ${{ runner.temp }}/digests pattern: digests-* merge-multiple: true - name: Docker metadata id: docker_meta uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: images: ${{ env.IMAGE }} flavor: | latest=false tags: | type=raw,value=latest,enable=${{ github.event_name == 'release' && github.event.action == 'published' && github.event.release.prerelease == false }} type=ref,event=tag type=ref,event=branch - name: Setup Docker buildx uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 - name: Login to GitHub Container Registry uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Create multi-platform manifest working-directory: ${{ runner.temp }}/digests run: | docker buildx imagetools create \ $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ $(printf "$IMAGE@sha256:%s " *) - name: Inspect manifest run: docker buildx imagetools inspect "$IMAGE:$DOCKER_METADATA_OUTPUT_VERSION"