Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ‘· Faster cross-arch Docker compilation

Alicia Sykesb3455afb4984
diff --git a/.github/workflows/docker-build-publish.yml b/.github/workflows/docker-build-publish.yml
deleted file mode 100644
index 22757c22..00000000
--- a/.github/workflows/docker-build-publish.yml
+++ /dev/null
@@ -1,84 +0,0 @@
-name: 🐳 Build + Publish Multi-Platform Image
-
-on:
- workflow_dispatch:
- push:
- tags: ['*.*.*']
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-permissions:
- packages: write
-
-env:
- DH_IMAGE: ${{ secrets.DOCKER_REPO }}
- GH_IMAGE: ${{ github.repository_owner }}/${{ github.event.repository.name }}
-
-jobs:
- docker:
- runs-on: ubuntu-latest
- permissions: { contents: read, packages: write }
-
- steps:
- - name: πŸ›ŽοΈ Checkout Repo
- uses: actions/checkout@v6
-
- - name: πŸ—‚οΈ Make Docker Meta
- id: meta
- uses: docker/metadata-action@v6
- with:
- images: |
- ${{ env.DH_IMAGE }}
- ghcr.io/${{ env.GH_IMAGE }}
- tags: |
- type=ref,event=tag
- type=semver,pattern={{major}}.{{minor}}
- type=semver,pattern={{major}}.x
- type=raw,value=latest
- flavor: |
- latest=false
-
- - name: ⏱️ Capture Build Timestamp
- id: timestamp
- run: echo "iso=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"
-
- - name: πŸ”§ Set up QEMU
- uses: docker/setup-qemu-action@v4
- with:
- platforms: linux/amd64,linux/arm64,linux/arm/v7
-
- - name: πŸ”§ Set up Docker Buildx
- uses: docker/setup-buildx-action@v4
-
- - name: πŸ”‘ Login to DockerHub
- uses: docker/login-action@v4
- with:
- username: ${{ secrets.DOCKER_USERNAME }}
- password: ${{ secrets.DOCKER_PASSWORD }}
-
- - name: πŸ”‘ Login to GitHub Container Registry
- uses: docker/login-action@v4
- with:
- registry: ghcr.io
- username: ${{ github.repository_owner }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: 🚦 Check Registry Status
- uses: crazy-max/ghaction-docker-status@v4
-
- - name: βš’οΈ Build and Push
- uses: docker/build-push-action@v7
- with:
- context: .
- file: ./Dockerfile
- platforms: linux/amd64,linux/arm64,linux/arm/v7
- tags: ${{ steps.meta.outputs.tags }}
- build-args: |
- VERSION=${{ steps.meta.outputs.version }}
- REVISION=${{ github.sha }}
- CREATED=${{ steps.timestamp.outputs.iso }}
- cache-from: type=gha
- cache-to: type=gha,mode=max
- push: true
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644
index 00000000..66d9c080
--- /dev/null
+++ b/.github/workflows/docker.yml
@@ -0,0 +1,305 @@
+# Builds and publishes the multi-arch Docker image
+#
+# Triggered by:
+# - On git tag push, publishes to :X.Y.Z, :X.Y, and :latest
+# - On manual dispatch from master, rebuilds and updates :latest
+# - On weekly cron, rebuilds :latest from master for upstream patches
+#
+# The workflow will:
+# - Builds multi-arch (amd64, arm64, armv7) in parallel on native runners
+# - Trivy scans + reports security issues, and fails on CRITICAL CVEs
+# - Publishes to GHCR, and to Docker Hub if creds are configured
+# - Attests both the build provenance and SBOM and publishes to GHCR
+# - Uploads digest, SBOM and outputs as artifact, and shows MD summary
+
+name: 🐳 Build + Publish Multi-Platform Image
+
+on:
+ workflow_dispatch:
+ inputs:
+ tag:
+ description: 'Existing git tag to build. Empty = build current ref as :latest.'
+ required: false
+ default: ''
+ push:
+ tags: ['*.*.*']
+ schedule:
+ - cron: '0 4 * * 0'
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.tag }}
+ cancel-in-progress: false
+
+permissions:
+ contents: read
+
+env:
+ DH_IMAGE: ${{ secrets.DOCKER_REPO }}
+ GH_IMAGE: ghcr.io/${{ github.repository }}
+
+jobs:
+ build:
+ name: πŸ”¨ Build (${{ matrix.arch }})
+ timeout-minutes: 30
+ permissions:
+ contents: read
+ packages: write
+ security-events: write
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - platform: linux/amd64
+ runner: ubuntu-latest
+ arch: amd64
+ - platform: linux/arm64
+ runner: ubuntu-24.04-arm
+ arch: arm64
+ - platform: linux/arm/v7
+ runner: ubuntu-latest
+ arch: armv7
+ runs-on: ${{ matrix.runner }}
+ steps:
+ - name: πŸ›ŽοΈ Checkout
+ uses: actions/checkout@v6
+ with:
+ ref: ${{ inputs.tag || github.ref }}
+
+ - name: 🏷️ Resolve build version
+ id: version
+ env:
+ INPUT_TAG: ${{ inputs.tag }}
+ EVENT_NAME: ${{ github.event_name }}
+ REF_NAME: ${{ github.ref_name }}
+ run: |
+ set -euo pipefail
+ if [ -n "$INPUT_TAG" ]; then
+ v="$INPUT_TAG"
+ elif [ "$EVENT_NAME" = "push" ]; then
+ v="$REF_NAME"
+ else
+ v="latest"
+ fi
+ echo "value=$v" >> "$GITHUB_OUTPUT"
+
+ - name: πŸ”§ Set up QEMU
+ if: matrix.arch == 'armv7'
+ uses: docker/setup-qemu-action@v4
+ with:
+ platforms: linux/arm/v7
+
+ - name: πŸ”§ Set up Buildx
+ uses: docker/setup-buildx-action@v4
+
+ - name: πŸ”‘ Login to GHCR
+ uses: docker/login-action@v4
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: ⏱️ Capture build timestamp
+ id: timestamp
+ run: echo "iso=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"
+
+ - name: πŸ”¨ Build image (load for scan)
+ uses: docker/build-push-action@v7
+ with:
+ context: .
+ file: ./Dockerfile
+ platforms: ${{ matrix.platform }}
+ cache-from: type=gha,scope=${{ matrix.arch }}
+ cache-to: type=gha,scope=${{ matrix.arch }},mode=max
+ load: true
+ tags: dashy-scan:${{ matrix.arch }}
+ provenance: false
+ build-args: |
+ VERSION=${{ steps.version.outputs.value }}
+ REVISION=${{ github.sha }}
+ CREATED=${{ steps.timestamp.outputs.iso }}
+
+ - name: πŸ›‘οΈ Trivy vulnerability scan
+ uses: aquasecurity/[email protected]
+ env:
+ TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db:2
+ TRIVY_JAVA_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-java-db:1
+ with:
+ image-ref: dashy-scan:${{ matrix.arch }}
+ severity: CRITICAL
+ ignore-unfixed: true
+ exit-code: ${{ github.event_name == 'schedule' && '1' || '0' }}
+ vuln-type: 'os,library'
+ format: 'sarif'
+ output: 'trivy-${{ matrix.arch }}.sarif'
+ timeout: '10m'
+
+ - name: πŸ“€ Upload Trivy SARIF
+ if: always() && hashFiles(format('trivy-{0}.sarif', matrix.arch)) != ''
+ uses: github/codeql-action/upload-sarif@v3
+ with:
+ sarif_file: trivy-${{ matrix.arch }}.sarif
+ category: trivy-${{ matrix.arch }}
+
+ - name: πŸš€ Push by digest
+ id: push
+ uses: docker/build-push-action@v7
+ with:
+ context: .
+ file: ./Dockerfile
+ platforms: ${{ matrix.platform }}
+ cache-from: type=gha,scope=${{ matrix.arch }}
+ outputs: type=image,name=${{ env.GH_IMAGE }},push-by-digest=true,name-canonical=true,push=true
+ provenance: false
+ build-args: |
+ VERSION=${{ steps.version.outputs.value }}
+ REVISION=${{ github.sha }}
+ CREATED=${{ steps.timestamp.outputs.iso }}
+
+ - name: 🧬 Write digest
+ run: |
+ mkdir -p "${{ runner.temp }}/digests"
+ echo "${{ steps.push.outputs.digest }}" > "${{ runner.temp }}/digests/${{ matrix.arch }}"
+
+ - name: πŸ“€ Upload digest
+ uses: actions/upload-artifact@v7
+ with:
+ name: digest-${{ matrix.arch }}
+ path: ${{ runner.temp }}/digests/${{ matrix.arch }}
+ if-no-files-found: error
+ retention-days: 1
+
+ merge:
+ name: 🧩 Merge & Push Manifests
+ needs: build
+ timeout-minutes: 30
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+ id-token: write
+ attestations: write
+ env:
+ HAS_DH: ${{ secrets.DOCKER_USERNAME != '' && secrets.DOCKER_PASSWORD != '' && secrets.DOCKER_REPO != '' }}
+ SEMVER_VALUE: ${{ inputs.tag || github.ref_name }}
+ SEMVER_ENABLE: ${{ github.event_name == 'push' || inputs.tag != '' }}
+ LATEST_ENABLE: ${{ inputs.tag == '' }}
+ steps:
+ - name: πŸ“₯ Download digests
+ uses: actions/download-artifact@v7
+ with:
+ path: ${{ runner.temp }}/digests
+ pattern: digest-*
+ merge-multiple: true
+
+ - name: πŸ”§ Set up Buildx
+ uses: docker/setup-buildx-action@v4
+
+ - name: πŸ”‘ Login to GHCR
+ uses: docker/login-action@v4
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: πŸ”‘ Login to Docker Hub
+ if: env.HAS_DH == 'true'
+ uses: docker/login-action@v4
+ with:
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+
+ - name: πŸ—‚οΈ Generate tags
+ id: meta
+ uses: docker/metadata-action@v6
+ with:
+ images: |
+ ${{ env.GH_IMAGE }}
+ ${{ env.HAS_DH == 'true' && env.DH_IMAGE || '' }}
+ tags: |
+ type=raw,value=latest,enable=${{ env.LATEST_ENABLE }}
+ type=semver,pattern={{version}},value=${{ env.SEMVER_VALUE }},enable=${{ env.SEMVER_ENABLE }}
+ type=semver,pattern={{major}}.{{minor}},value=${{ env.SEMVER_VALUE }},enable=${{ env.SEMVER_ENABLE }}
+ type=semver,pattern={{major}}.x,value=${{ env.SEMVER_VALUE }},enable=${{ env.SEMVER_ENABLE }}
+ flavor: |
+ latest=false
+
+ - name: 🧩 Create & push manifest
+ id: manifest
+ working-directory: ${{ runner.temp }}/digests
+ run: |
+ set -euo pipefail
+ TAGS=()
+ while IFS= read -r tag; do TAGS+=(-t "$tag"); done \
+ < <(jq -r '.tags[]' <<< "$DOCKER_METADATA_OUTPUT_JSON")
+ SOURCES=()
+ for f in *; do SOURCES+=("${GH_IMAGE}@$(cat "$f")"); done
+ docker buildx imagetools create "${TAGS[@]}" "${SOURCES[@]}"
+ PRIMARY=$(jq -r --arg img "$GH_IMAGE" \
+ '.tags[] | select(startswith($img + ":"))' \
+ <<< "$DOCKER_METADATA_OUTPUT_JSON" | head -1)
+ DIGEST=$(docker buildx imagetools inspect "$PRIMARY" --format '{{.Manifest.Digest}}')
+ echo "primary_tag=$PRIMARY" >> "$GITHUB_OUTPUT"
+ echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
+
+ - name: πŸ” Generate SBOM (SPDX)
+ uses: anchore/[email protected]
+ with:
+ image: ${{ steps.manifest.outputs.primary_tag }}
+ format: spdx-json
+ output-file: sbom.spdx.json
+ upload-artifact: false
+
+ - name: πŸͺͺ Attest SBOM
+ id: attest_sbom
+ uses: actions/attest-sbom@v4
+ continue-on-error: true
+ with:
+ subject-name: ${{ env.GH_IMAGE }}
+ subject-digest: ${{ steps.manifest.outputs.digest }}
+ sbom-path: sbom.spdx.json
+ push-to-registry: true
+
+ - name: πŸ›‘οΈ Attest build provenance
+ id: attest_provenance
+ uses: actions/attest-build-provenance@v4
+ continue-on-error: true
+ with:
+ subject-name: ${{ env.GH_IMAGE }}
+ subject-digest: ${{ steps.manifest.outputs.digest }}
+ push-to-registry: true
+
+ - name: πŸ“‹ Summary
+ if: always()
+ env:
+ SBOM_OUTCOME: ${{ steps.attest_sbom.outcome }}
+ SBOM_URL: ${{ steps.attest_sbom.outputs.attestation-url }}
+ PROV_OUTCOME: ${{ steps.attest_provenance.outcome }}
+ PROV_URL: ${{ steps.attest_provenance.outputs.attestation-url }}
+ DIGEST: ${{ steps.manifest.outputs.digest }}
+ TAGS_JSON: ${{ steps.meta.outputs.json }}
+ run: |
+ set -euo pipefail
+ attest() {
+ case "$2" in
+ success)
+ if [ -n "$3" ]; then
+ echo "- βœ… $1 attested ([view]($3))"
+ else
+ echo "- βœ… $1 attested"
+ fi ;;
+ failure) echo "- ⚠️ $1 attestation failed (image pushed without attest)" ;;
+ *) echo "- ⏭️ $1 attestation \`$2\`" ;;
+ esac
+ }
+ {
+ if [ -n "$DIGEST" ]; then
+ echo "## 🐳 Docker Image"
+ echo "**Manifest:** \`$DIGEST\`"
+ echo '```bash'
+ jq -r '.tags[] | "docker pull \(.)"' <<< "$TAGS_JSON"
+ echo '```'
+ fi
+ echo "## πŸͺͺ Attestations"
+ attest "SBOM" "$SBOM_OUTCOME" "$SBOM_URL"
+ attest "Build provenance" "$PROV_OUTCOME" "$PROV_URL"
+ } >> "$GITHUB_STEP_SUMMARY"