From b82c14892e5dc69d90aec4c0723d8e7b4fa87591 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 4 Feb 2025 21:02:44 +0000 Subject: [PATCH] Arm builds (#1615) * fix: matrix build * fix: trigger build * fix: trigger wrong name * fix: runner name * fix: manifest fix * fix: yaml error * fix: manifest build * fix: build error * feat: multi arch containers --- .github/workflows/ci.yml | 79 ++++++++++++++++-- .github/workflows/cife.yml | 80 +++++++++++++++++-- .github/workflows/docker-develop-build.yml | 79 +++++++++++++----- .github/workflows/docker-develop-fe-build.yml | 69 ++++++++++++++-- 4 files changed, 267 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 090a69db..67ebe0dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,20 +5,33 @@ on: types: [published] jobs: - deploy: + build: if: github.repository == 'arc53/DocsGPT' - runs-on: ubuntu-latest + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + suffix: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + suffix: arm64 + runs-on: ${{ matrix.runner }} permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - - name: Set up QEMU + - name: Set up QEMU # Only needed for emulation, not for native arm64 builds + if: matrix.platform == 'linux/arm64' uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + install: true - name: Login to DockerHub uses: docker/login-action@v3 @@ -33,15 +46,67 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker images to docker.io and ghcr.io + - name: Build and push platform-specific images uses: docker/build-push-action@v6 with: file: './application/Dockerfile' - platforms: linux/amd64 + platforms: ${{ matrix.platform }} context: ./application push: true tags: | - ${{ secrets.DOCKER_USERNAME }}/docsgpt:${{ github.event.release.tag_name }},${{ secrets.DOCKER_USERNAME }}/docsgpt:latest - ghcr.io/${{ github.repository_owner }}/docsgpt:${{ github.event.release.tag_name }},ghcr.io/${{ github.repository_owner }}/docsgpt:latest + ${{ secrets.DOCKER_USERNAME }}/docsgpt:${{ github.event.release.tag_name }}-${{ matrix.suffix }} + ghcr.io/${{ github.repository_owner }}/docsgpt:${{ github.event.release.tag_name }}-${{ matrix.suffix }} + provenance: false + sbom: false cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/docsgpt:latest cache-to: type=inline + + manifest: + if: github.repository == 'arc53/DocsGPT' + needs: build + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + install: true + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and push manifest for DockerHub + run: | + set -e + docker manifest create ${{ secrets.DOCKER_USERNAME }}/docsgpt:${{ github.event.release.tag_name }} \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt:${{ github.event.release.tag_name }}-amd64 \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt:${{ github.event.release.tag_name }}-arm64 + docker manifest push ${{ secrets.DOCKER_USERNAME }}/docsgpt:${{ github.event.release.tag_name }} + docker manifest create ${{ secrets.DOCKER_USERNAME }}/docsgpt:latest \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt:${{ github.event.release.tag_name }}-amd64 \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt:${{ github.event.release.tag_name }}-arm64 + docker manifest push ${{ secrets.DOCKER_USERNAME }}/docsgpt:latest + + - name: Create and push manifest for ghcr.io + run: | + set -e + docker manifest create ghcr.io/${{ github.repository_owner }}/docsgpt:${{ github.event.release.tag_name }} \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt:${{ github.event.release.tag_name }}-amd64 \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt:${{ github.event.release.tag_name }}-arm64 + docker manifest push ghcr.io/${{ github.repository_owner }}/docsgpt:${{ github.event.release.tag_name }} + docker manifest create ghcr.io/${{ github.repository_owner }}/docsgpt:latest \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt:${{ github.event.release.tag_name }}-amd64 \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt:${{ github.event.release.tag_name }}-arm64 + docker manifest push ghcr.io/${{ github.repository_owner }}/docsgpt:latest \ No newline at end of file diff --git a/.github/workflows/cife.yml b/.github/workflows/cife.yml index 711cab29..1118723f 100644 --- a/.github/workflows/cife.yml +++ b/.github/workflows/cife.yml @@ -5,20 +5,33 @@ on: types: [published] jobs: - deploy: + build: if: github.repository == 'arc53/DocsGPT' - runs-on: ubuntu-latest + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + suffix: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + suffix: arm64 + runs-on: ${{ matrix.runner }} permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - - name: Set up QEMU + - name: Set up QEMU # Only needed for emulation, not for native arm64 builds + if: matrix.platform == 'linux/arm64' uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + install: true - name: Login to DockerHub uses: docker/login-action@v3 @@ -33,16 +46,67 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - # Runs a single command using the runners shell - - name: Build and push Docker images to docker.io and ghcr.io + - name: Build and push platform-specific images uses: docker/build-push-action@v6 with: file: './frontend/Dockerfile' - platforms: linux/amd64, linux/arm64 + platforms: ${{ matrix.platform }} context: ./frontend push: true tags: | - ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:${{ github.event.release.tag_name }},${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:latest - ghcr.io/${{ github.repository_owner }}/docsgpt-fe:${{ github.event.release.tag_name }},ghcr.io/${{ github.repository_owner }}/docsgpt-fe:latest + ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:${{ github.event.release.tag_name }}-${{ matrix.suffix }} + ghcr.io/${{ github.repository_owner }}/docsgpt-fe:${{ github.event.release.tag_name }}-${{ matrix.suffix }} + provenance: false + sbom: false cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:latest cache-to: type=inline + + manifest: + if: github.repository == 'arc53/DocsGPT' + needs: build + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + install: true + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and push manifest for DockerHub + run: | + set -e + docker manifest create ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:${{ github.event.release.tag_name }} \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:${{ github.event.release.tag_name }}-amd64 \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:${{ github.event.release.tag_name }}-arm64 + docker manifest push ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:${{ github.event.release.tag_name }} + docker manifest create ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:latest \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:${{ github.event.release.tag_name }}-amd64 \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:${{ github.event.release.tag_name }}-arm64 + docker manifest push ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:latest + + - name: Create and push manifest for ghcr.io + run: | + set -e + docker manifest create ghcr.io/${{ github.repository_owner }}/docsgpt-fe:${{ github.event.release.tag_name }} \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt-fe:${{ github.event.release.tag_name }}-amd64 \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt-fe:${{ github.event.release.tag_name }}-arm64 + docker manifest push ghcr.io/${{ github.repository_owner }}/docsgpt-fe:${{ github.event.release.tag_name }} + docker manifest create ghcr.io/${{ github.repository_owner }}/docsgpt-fe:latest \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt-fe:${{ github.event.release.tag_name }}-amd64 \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt-fe:${{ github.event.release.tag_name }}-arm64 + docker manifest push ghcr.io/${{ github.repository_owner }}/docsgpt-fe:latest \ No newline at end of file diff --git a/.github/workflows/docker-develop-build.yml b/.github/workflows/docker-develop-build.yml index 736ac615..b0045934 100644 --- a/.github/workflows/docker-develop-build.yml +++ b/.github/workflows/docker-develop-build.yml @@ -1,4 +1,4 @@ -name: Build and push DocsGPT Docker image for development +name: Build and push multi-arch DocsGPT Docker image on: workflow_dispatch: @@ -7,20 +7,29 @@ on: - main jobs: - deploy: + build: if: github.repository == 'arc53/DocsGPT' - runs-on: ubuntu-latest + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + suffix: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + suffix: arm64 + runs-on: ${{ matrix.runner }} permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + install: true - name: Login to DockerHub uses: docker/login-action@v3 @@ -28,22 +37,56 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push platform-specific images + uses: docker/build-push-action@v6 + with: + file: './application/Dockerfile' + platforms: ${{ matrix.platform }} + context: ./application + push: true + tags: | + ${{ secrets.DOCKER_USERNAME }}/docsgpt:develop-${{ matrix.suffix }} + provenance: false + sbom: false + cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/docsgpt:develop + cache-to: type=inline + + manifest: + if: github.repository == 'arc53/DocsGPT' + needs: build + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + install: true + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Login to ghcr.io uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and push manifest for DockerHub + run: | + docker manifest create ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop-amd64 \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop-arm64 + docker manifest push ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop - - name: Build and push Docker images to docker.io and ghcr.io - uses: docker/build-push-action@v6 - with: - file: './application/Dockerfile' - platforms: linux/amd64,linux/arm64 - context: ./application - push: true - tags: | - ${{ secrets.DOCKER_USERNAME }}/docsgpt:develop - ghcr.io/${{ github.repository_owner }}/docsgpt:develop - cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/docsgpt:develop - cache-to: type=inline + - name: Create and push manifest for ghcr.io + run: | + docker manifest create ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop-amd64 \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop-arm64 + docker manifest push ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop \ No newline at end of file diff --git a/.github/workflows/docker-develop-fe-build.yml b/.github/workflows/docker-develop-fe-build.yml index 317635bd..df7bdac6 100644 --- a/.github/workflows/docker-develop-fe-build.yml +++ b/.github/workflows/docker-develop-fe-build.yml @@ -7,20 +7,33 @@ on: - main jobs: - deploy: + build: if: github.repository == 'arc53/DocsGPT' - runs-on: ubuntu-latest + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + suffix: amd64 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + suffix: arm64 + runs-on: ${{ matrix.runner }} permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - - name: Set up QEMU + - name: Set up QEMU # Only needed for emulation, not for native arm64 builds + if: matrix.platform == 'linux/arm64' uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + install: true - name: Login to DockerHub uses: docker/login-action@v3 @@ -35,15 +48,57 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker images to docker.io and ghcr.io + - name: Build and push platform-specific images uses: docker/build-push-action@v6 with: file: './frontend/Dockerfile' - platforms: linux/amd64 + platforms: ${{ matrix.platform }} context: ./frontend push: true tags: | - ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop - ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop + ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop-${{ matrix.suffix }} + ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop-${{ matrix.suffix }} + provenance: false + sbom: false cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop cache-to: type=inline + + manifest: + if: github.repository == 'arc53/DocsGPT' + needs: build + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + install: true + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and push manifest for DockerHub + run: | + docker manifest create ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop-amd64 \ + --amend ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop-arm64 + docker manifest push ${{ secrets.DOCKER_USERNAME }}/docsgpt-fe:develop + + - name: Create and push manifest for ghcr.io + run: | + docker manifest create ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop-amd64 \ + --amend ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop-arm64 + docker manifest push ghcr.io/${{ github.repository_owner }}/docsgpt-fe:develop \ No newline at end of file