diff --git a/.github/workflows/workflow-docker-manual.yml b/.github/workflows/workflow-docker-manual.yml index c8b0f75..f18d091 100644 --- a/.github/workflows/workflow-docker-manual.yml +++ b/.github/workflows/workflow-docker-manual.yml @@ -13,6 +13,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Set up QEMU for multi-arch support + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -58,60 +62,24 @@ jobs: echo "[debug] Generated app name is '${app_name}'" echo "app_name=$app_name" >> $GITHUB_OUTPUT id: generate_app_name - - name: Build Docker image and tag - uses: nick-fields/retry@v2 + - name: Build amd64 image and export to Docker for testing + uses: docker/build-push-action@v5 with: - timeout_minutes: 60 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker build \ - --tag ${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }} \ - --tag ${{ github.repository }}:${{ github.event.inputs.tags }} \ - --tag quay.io/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }} \ - --tag quay.io/${{ github.repository }}:${{ github.event.inputs.tags }} \ - --tag ghcr.io/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }} \ - --tag ghcr.io/${{ github.repository }}:${{ github.event.inputs.tags }} \ - --tag registry.gitlab.com/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }} \ - --tag registry.gitlab.com/${{ github.repository }}:${{ github.event.inputs.tags }} \ - . - - name: Run Tests + context: . + load: true + tags: ${{ steps.generate_temporary_tag_name.outputs.test_tag }} + - name: Run tests using previously built image shell: bash run: | git_clone_scripts_dest="/tmp/scripts" git_clone_scripts_repo="https://github.com/binhex/scripts.git" - git clone "${git_clone_scripts_repo}" "${git_clone_scripts_dest}" "${git_clone_scripts_dest}/shell/arch/docker/testrunner.sh" --app-name ${{ steps.generate_app_name.outputs.app_name }} --image-name "ghcr.io/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }}" - - name: Push Docker image to Docker Hub - uses: nick-fields/retry@v2 - with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker push ${{ github.repository }}:${{ github.event.inputs.tags }} - - name: Push Docker image to Quay Container Registry - uses: nick-fields/retry@v2 - with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker push quay.io/${{ github.repository }}:${{ github.event.inputs.tags }} - - name: Push Docker image to GitHub Container Registry (GHCR) - uses: nick-fields/retry@v2 - with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker push ghcr.io/${{ github.repository }}:${{ github.event.inputs.tags }} - - name: Push Docker image to GitLab Container Registry (GCR) - uses: nick-fields/retry@v2 + # note this will re-use the internal cached amd64 image from the previous build + - name: Build multi-arch Docker image, tag and push to registries + uses: docker/build-push-action@v5 with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker push registry.gitlab.com/${{ github.repository }}:${{ github.event.inputs.tags }} \ No newline at end of file + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ github.repository }}:${{ github.event.inputs.tags }}, quay.io/${{ github.repository }}:${{ github.event.inputs.tags }}, ghcr.io/${{ github.repository }}:${{ github.event.inputs.tags }}, registry.gitlab.com/${{ github.repository }}:${{ github.event.inputs.tags }} diff --git a/.github/workflows/workflow-docker-release.yml b/.github/workflows/workflow-docker-release.yml index 28ef19a..7f07932 100644 --- a/.github/workflows/workflow-docker-release.yml +++ b/.github/workflows/workflow-docker-release.yml @@ -11,6 +11,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Set up QEMU for multi-arch support + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -76,77 +80,26 @@ jobs: echo "[debug] Generated app name is '${app_name}'" echo "app_name=$app_name" >> $GITHUB_OUTPUT id: generate_app_name - - name: Build Docker image and tag - uses: nick-fields/retry@v2 - with: - timeout_minutes: 60 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker build \ - --tag ${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }} \ - --tag ${{ github.repository }}:latest \ - --tag ${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} \ - --tag quay.io/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }} \ - --tag quay.io/${{ github.repository }}:latest \ - --tag quay.io/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} \ - --tag ghcr.io/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }} \ - --tag ghcr.io/${{ github.repository }}:latest \ - --tag ghcr.io/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} \ - --tag registry.gitlab.com/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }} \ - --tag registry.gitlab.com/${{ github.repository }}:latest \ - --tag registry.gitlab.com/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} \ - --build-arg release_tag_name=${{ steps.identify_github_release_tag_name.outputs.tag }} \ - . - - name: DEBUG Show built Docker Images - uses: nick-fields/retry@v2 + - name: Build amd64 image and export to Docker for testing + uses: docker/build-push-action@v5 with: - timeout_minutes: 5 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker images - - name: Run Tests + context: . + load: true + tags: ${{ steps.generate_temporary_tag_name.outputs.test_tag }} + - name: Run tests using previously built image shell: bash run: | git_clone_scripts_dest="/tmp/scripts" git_clone_scripts_repo="https://github.com/binhex/scripts.git" - git clone "${git_clone_scripts_repo}" "${git_clone_scripts_dest}" "${git_clone_scripts_dest}/shell/arch/docker/testrunner.sh" --app-name ${{ steps.generate_app_name.outputs.app_name }} --image-name "ghcr.io/${{ github.repository }}:${{ steps.generate_temporary_tag_name.outputs.test_tag }}" - - name: Push Docker image to Docker Hub - uses: nick-fields/retry@v2 - with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker push ${{ github.repository }}:latest - docker push ${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} - - name: Push Docker image to Quay Container Registry - uses: nick-fields/retry@v2 - with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker push quay.io/${{ github.repository }}:latest - docker push quay.io/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} - - name: Push Docker image to GitHub Container Registry (GHCR) - uses: nick-fields/retry@v2 + # note this will re-use the internal cached amd64 image from the previous build + - name: Build multi-arch Docker image, tag and push to registries + uses: docker/build-push-action@v5 with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker push ghcr.io/${{ github.repository }}:latest - docker push ghcr.io/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} - - name: Push Docker image to GitLab Container Registry (GCR) - uses: nick-fields/retry@v2 - with: - timeout_minutes: 30 - max_attempts: 3 - retry_wait_seconds: 120 - command: | - docker push registry.gitlab.com/${{ github.repository }}:latest - docker push registry.gitlab.com/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} \ No newline at end of file + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ github.repository }}:latest, ${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }}, quay.io/${{ github.repository }}:latest, quay.io/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }}, ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }}, registry.gitlab.com/${{ github.repository }}:latest, registry.gitlab.com/${{ github.repository }}:${{ steps.identify_github_release_tag_name.outputs.tag }} + build-args: | + release_tag_name=${{ steps.identify_github_release_tag_name.outputs.tag }}