Files
pterodactyl-panel/.github/workflows/docker.yaml
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

160 lines
4.8 KiB
YAML

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
release:
types:
- published
env:
IMAGE: ghcr.io/pterodactyl/panel
PUBLISH: ${{ github.event_name != 'pull_request' && !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@v4
- 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@v5
with:
images: ${{ env.IMAGE }}
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build production image
uses: docker/build-push-action@v6
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@v3
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@v6
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@v4
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' && !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@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Docker metadata
id: docker_meta
uses: docker/metadata-action@v5
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@v3
- 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 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"