diff --git a/.github/workflows/docker-build-and-publish.yml b/.github/workflows/docker-build-and-publish-linux-amd64.yml similarity index 73% rename from .github/workflows/docker-build-and-publish.yml rename to .github/workflows/docker-build-and-publish-linux-amd64.yml index c6d17de..1561af3 100644 --- a/.github/workflows/docker-build-and-publish.yml +++ b/.github/workflows/docker-build-and-publish-linux-amd64.yml @@ -1,4 +1,4 @@ -name: Build and Publish Image +name: Build and Publish Linux AMD64 Image on: workflow_dispatch: # allows us to trigger runs manually in the GitHub UI @@ -7,7 +7,8 @@ on: jobs: docker: - runs-on: ubuntu-latest + if: ${{ github.ref == format('refs/heads/{0}', vars.NIGHTLY_BRANCH) }} + runs-on: ubuntu-24.04 steps: # See https://docs.docker.com/build/ci/github-actions/multi-platform/ - name: Login to DockerHub uses: docker/login-action@v3 @@ -15,15 +16,12 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push uses: docker/build-push-action@v6 with: - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 push: true - tags: nodejs/devcontainer:nightly + tags: ${{ vars.DOCKERHUB_IMAGE }}:nightly-linux-amd64 diff --git a/.github/workflows/docker-build-and-publish-linux-arm64.yml b/.github/workflows/docker-build-and-publish-linux-arm64.yml new file mode 100644 index 0000000..8115002 --- /dev/null +++ b/.github/workflows/docker-build-and-publish-linux-arm64.yml @@ -0,0 +1,27 @@ +name: Build and Publish Linux ARM64 Image + +on: + workflow_dispatch: # allows us to trigger runs manually in the GitHub UI + schedule: + - cron: '0 0 * * *' # runs nightly + +jobs: + docker: + if: ${{ github.ref == format('refs/heads/{0}', vars.NIGHTLY_BRANCH) }} + runs-on: ubuntu-24.04-arm + steps: # See https://docs.docker.com/build/ci/github-actions/multi-platform/ + - name: Login to DockerHub + uses: docker/login-action@v3 + with: # these are defined in the GitHub Secrets UI + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/arm64 + push: true + tags: ${{ vars.DOCKERHUB_IMAGE }}:nightly-linux-arm64 diff --git a/.github/workflows/docker-merge.yml b/.github/workflows/docker-merge.yml new file mode 100644 index 0000000..92652f4 --- /dev/null +++ b/.github/workflows/docker-merge.yml @@ -0,0 +1,46 @@ +name: Merge images + +on: + workflow_run: # Fires when any of the specified workflows complete + workflows: ["Build and Publish Linux ARM64 Image", "Build and Publish Linux AMD64 Image"] + types: [completed] + +env: + IMAGE: ${{ vars.DOCKERHUB_IMAGE }} + REGISTRY: docker.io + +concurrency: # ensure only one merge runs at a time + group: merge-manifest + cancel-in-progress: false + +jobs: + merge: + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == vars.NIGHTLY_BRANCH }} + runs-on: ubuntu-latest + steps: + - name: Login to DockerHub + uses: docker/login-action@v3 + with: # these are defined in the GitHub Secrets UI + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Merge the multiple architecture-specific images into a single multi-arch image. + # If images for other architectures do not exist in the registry yet, this step will fail. + # It will only succeed when at least one image for each architecture has been built and pushed. + # If images for other architectures are being built and the ones in the registry + # are old, it only updates the nightly tag for the architecture that triggered this + # workflow. When images for other architectures are built successfully later, they will + # trigger this workflow again and merge the updated images. + - name: Create multi-arch manifest + run: | + docker buildx imagetools create \ + -t ${REGISTRY}/${IMAGE}:nightly \ + ${REGISTRY}/${IMAGE}:nightly-linux-amd64 \ + ${REGISTRY}/${IMAGE}:nightly-linux-arm64 + + - name: Verify multi-arch manifest + run: | + docker buildx imagetools inspect ${REGISTRY}/${IMAGE}:nightly