refactor: build Docker images once, retag on publish
- Preflight builds multi-arch images to staging tags on GHCR - Publish workflow just retags staging → final (no rebuild) - Reduces publish time from ~10min to ~1min
This commit is contained in:
parent
ea9a9e3a08
commit
eddc9356af
2 changed files with 75 additions and 76 deletions
60
.github/workflows/create-release.yml
vendored
60
.github/workflows/create-release.yml
vendored
|
|
@ -63,12 +63,14 @@ jobs:
|
||||||
echo "✓ VERSION file matches requested version ($REQUESTED_VERSION)"
|
echo "✓ VERSION file matches requested version ($REQUESTED_VERSION)"
|
||||||
|
|
||||||
preflight_tests:
|
preflight_tests:
|
||||||
needs: version_guard
|
needs:
|
||||||
|
- extract_version
|
||||||
|
- version_guard
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: read
|
packages: write
|
||||||
env:
|
env:
|
||||||
FRONTEND_DIST: frontend-modern/dist
|
FRONTEND_DIST: frontend-modern/dist
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -134,15 +136,51 @@ jobs:
|
||||||
- name: Build Pulse for integration tests
|
- name: Build Pulse for integration tests
|
||||||
run: make build
|
run: make build
|
||||||
|
|
||||||
- name: Log in to GHCR for build cache
|
- name: Set up QEMU
|
||||||
env:
|
uses: docker/setup-qemu-action@v3
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
- name: Set up Docker Buildx
|
||||||
if [ -z "${GH_TOKEN:-}" ]; then
|
uses: docker/setup-buildx-action@v3
|
||||||
echo "::error::GITHUB_TOKEN not available for GHCR login"
|
|
||||||
exit 1
|
- name: Log in to Docker Hub
|
||||||
fi
|
uses: docker/login-action@v3
|
||||||
echo "$GH_TOKEN" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Log in to GHCR
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push staging Docker images
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
target: runtime
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
provenance: false
|
||||||
|
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/pulse:buildcache
|
||||||
|
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/pulse:buildcache,mode=max
|
||||||
|
tags: |
|
||||||
|
ghcr.io/${{ github.repository_owner }}/pulse:staging-${{ needs.extract_version.outputs.tag }}
|
||||||
|
|
||||||
|
- name: Build and push staging Docker agent image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
target: agent_runtime
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
provenance: false
|
||||||
|
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:buildcache
|
||||||
|
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:buildcache,mode=max
|
||||||
|
tags: |
|
||||||
|
ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:staging-${{ needs.extract_version.outputs.tag }}
|
||||||
|
|
||||||
- name: Build Docker images for integration tests
|
- name: Build Docker images for integration tests
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
91
.github/workflows/publish-docker.yml
vendored
91
.github/workflows/publish-docker.yml
vendored
|
|
@ -11,7 +11,7 @@ concurrency:
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 60
|
timeout-minutes: 15
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
@ -26,17 +26,6 @@ jobs:
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
echo "Publishing Docker images for ${TAG}"
|
echo "Publishing Docker images for ${TAG}"
|
||||||
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event.release.tag_name }}
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
|
@ -50,60 +39,32 @@ jobs:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push Pulse server image
|
- name: Copy staging images to final tags
|
||||||
uses: docker/build-push-action@v6
|
run: |
|
||||||
with:
|
TAG="${{ steps.version.outputs.tag }}"
|
||||||
context: .
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
target: runtime
|
STAGING_TAG="staging-${TAG}"
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
provenance: false
|
|
||||||
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/pulse:buildcache
|
|
||||||
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/pulse:buildcache,mode=max
|
|
||||||
tags: |
|
|
||||||
rcourtman/pulse:${{ steps.version.outputs.tag }}
|
|
||||||
rcourtman/pulse:${{ steps.version.outputs.version }}
|
|
||||||
rcourtman/pulse:latest
|
|
||||||
ghcr.io/${{ github.repository_owner }}/pulse:${{ steps.version.outputs.tag }}
|
|
||||||
ghcr.io/${{ github.repository_owner }}/pulse:${{ steps.version.outputs.version }}
|
|
||||||
ghcr.io/${{ github.repository_owner }}/pulse:latest
|
|
||||||
labels: |
|
|
||||||
org.opencontainers.image.title=Pulse
|
|
||||||
org.opencontainers.image.description=Proxmox monitoring system
|
|
||||||
org.opencontainers.image.version=${{ steps.version.outputs.tag }}
|
|
||||||
org.opencontainers.image.created=${{ github.event.release.published_at }}
|
|
||||||
org.opencontainers.image.revision=${{ github.sha }}
|
|
||||||
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
||||||
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
|
|
||||||
org.opencontainers.image.licenses=MIT
|
|
||||||
|
|
||||||
- name: Build and push Docker agent image
|
echo "Copying pulse staging image to final tags..."
|
||||||
uses: docker/build-push-action@v6
|
# Pull the staging multi-arch manifest
|
||||||
with:
|
docker buildx imagetools create \
|
||||||
context: .
|
--tag rcourtman/pulse:${TAG} \
|
||||||
file: ./Dockerfile
|
--tag rcourtman/pulse:${VERSION} \
|
||||||
target: agent_runtime
|
--tag rcourtman/pulse:latest \
|
||||||
platforms: linux/amd64,linux/arm64
|
--tag ghcr.io/${{ github.repository_owner }}/pulse:${TAG} \
|
||||||
push: true
|
--tag ghcr.io/${{ github.repository_owner }}/pulse:${VERSION} \
|
||||||
provenance: false
|
--tag ghcr.io/${{ github.repository_owner }}/pulse:latest \
|
||||||
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:buildcache
|
ghcr.io/${{ github.repository_owner }}/pulse:${STAGING_TAG}
|
||||||
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:buildcache,mode=max
|
|
||||||
tags: |
|
echo "Copying pulse-docker-agent staging image to final tags..."
|
||||||
rcourtman/pulse-docker-agent:${{ steps.version.outputs.tag }}
|
docker buildx imagetools create \
|
||||||
rcourtman/pulse-docker-agent:${{ steps.version.outputs.version }}
|
--tag rcourtman/pulse-docker-agent:${TAG} \
|
||||||
rcourtman/pulse-docker-agent:latest
|
--tag rcourtman/pulse-docker-agent:${VERSION} \
|
||||||
ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:${{ steps.version.outputs.tag }}
|
--tag rcourtman/pulse-docker-agent:latest \
|
||||||
ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:${{ steps.version.outputs.version }}
|
--tag ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:${TAG} \
|
||||||
ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:latest
|
--tag ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:${VERSION} \
|
||||||
labels: |
|
--tag ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:latest \
|
||||||
org.opencontainers.image.title=Pulse Docker Agent
|
ghcr.io/${{ github.repository_owner }}/pulse-docker-agent:${STAGING_TAG}
|
||||||
org.opencontainers.image.description=Docker container monitoring agent for Pulse
|
|
||||||
org.opencontainers.image.version=${{ steps.version.outputs.tag }}
|
|
||||||
org.opencontainers.image.created=${{ github.event.release.published_at }}
|
|
||||||
org.opencontainers.image.revision=${{ github.sha }}
|
|
||||||
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
||||||
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
|
|
||||||
org.opencontainers.image.licenses=MIT
|
|
||||||
|
|
||||||
- name: Output image information
|
- name: Output image information
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue