Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ARM64 for built container image #52

Closed
spwoodcock opened this issue Jun 6, 2024 · 1 comment · Fixed by #53
Closed

Add support for ARM64 for built container image #52

spwoodcock opened this issue Jun 6, 2024 · 1 comment · Fixed by #53

Comments

@spwoodcock
Copy link
Contributor

Issue

  • Currently the image only builds for AMD64, which is by far the most prevalent architecture.
  • ARM64 support for container images becoming more important over time, as infrastructure starts to use a mix of the two.
  • As the workflow here: https://github.com/getodk/pyxform-http/blob/master/.github/workflows/publish.yml already uses the docker/build-push-action (which has multi-arch support), it would be nice to also build for ARM64.

Solution

Update the workflow publish.yml to include three extra things:

  • QEMU setup stage
  • Buildx setup stage
  • Add the platform key to the docker/build-push-action, with linux/amd64,linux/arm64 specified.

Full modified workflow:

name: Publish

on: push

env:
    # Use docker.io for Docker Hub if empty
    REGISTRY: ghcr.io
    # github.repository as <account>/<repo>
    IMAGE_NAME: ${{ github.repository }}

jobs:
    build:
        runs-on: ubuntu-latest
        permissions:
            contents: read
            packages: write

        steps:
            - name: Checkout repository
              uses: actions/checkout@v4

            # Login against a Docker registry
            # https://github.com/docker/login-action
            - name: Log into registry ${{ env.REGISTRY }}
              uses: docker/login-action@v3
              with:
                  registry: ${{ env.REGISTRY }}
                  username: ${{ github.actor }}
                  password: ${{ secrets.GITHUB_TOKEN }}

            # Extract metadata (tags, labels) for Docker
            # https://github.com/docker/metadata-action
            - name: Extract Docker metadata
              id: meta
              uses: docker/metadata-action@v5
              with:
                  images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

            # Setup QEMU emulator to build multi-arch images
            # https://github.com/docker/setup-qemu-action
            - name: Set up QEMU
              uses: docker/setup-qemu-action@v3

            # Configure Buildx for Docker build
            # https://github.com/docker/setup-buildx-action
            - name: Set up Buildx
              uses: docker/setup-buildx-action@v3

            # Build and push Docker image with Buildx
            # https://github.com/docker/build-push-action
            - name: Build and push Docker image
              uses: docker/build-push-action@v5
              with:
                  context: .
                  push: true
                  tags: ${{ steps.meta.outputs.tags }}
                  labels: ${{ steps.meta.outputs.labels }}
                  platforms: 'linux/amd64,linux/arm64'

Additional considerations

  • This is a small part of marking ODK Central compatible with ARM64, when providing pre-built images from Build Docker images in GitHub Actions central#546 (users can already build ODK Central ARM64 themselves).
  • @lognaturel we already discussed that there is no need for ARM64 support until a user requests it. I actually had a developer wishing to contribute to a tool I maintain that uses pyxform-http as part of the docker-compose stack, using a Macbook M1 for development. They were blocked from doing so by no ARM64 for this image. I don't see much downside to at least having support on pyxform-http only for now 😄
@lognaturel
Copy link
Member

Sounds good if you want to make it so, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants