nakama
nakama copied to clipboard
Nakama ARM build should be published with the same docker version tag
It seems like the Nakama ARM images (https://hub.docker.com/r/heroiclabs/nakama/tags) is version tagged separately as vX.X.X-arm. This unfortunately makes it difficult to do downstream multi-platform builds as it would require a separate Dockerfile that imports different base image version tags.
The Docker best practice seems to be to publish different platform images under the same version tag and let docker buildx automatically select the correct image based on the platform. By doing it this way, you can do multi-platform builds using a single Dockerfile.
For example:
- Redis - Notice how a single version tag is used for multiple architectures.
It seems easy to accomplish if Docker images are built from GitHub.
If that's not the case it's not that hard anyway, just three steps:
- Choose an strategy to build the ARM64 containers
docker buildx build --platform linux/amd64,linux/arm64 -f ./build/Dockerfile $YOUR_DOCKER_BUILD_PARAMS_HEREdocker push $IMAGE_NAME
Here's a GitHub Actions workflow that does this.
It requires two secrets (the Docker hub login credentials).
It publishes a single multi-platform (linux/amd64 and linux/arm64) Docker image when a new release is created:
name: docker-image
on:
release:
types:
- created
env:
IMAGE_NAME: "heroiclabs/nakama"
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set env vars
run: |
echo "ARG_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "ARG_VERSION=$(echo -n ${{ github.event.release.name }} | cut -c2-)" >> $GITHUB_ENV
- name: Set up QEMU
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@v3
with:
# registry: "..." # if not using Docker Hub check https://github.com/docker/login-action?tab=readme-ov-file#usage
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
- name: Build and push
uses: docker/build-push-action@v6
with:
file: "build/Dockerfile"
build-args: |
commit=${{ env.ARG_COMMIT }}
version=${{ env.ARG_VERSION }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
EDIT (28/07/2024): Updated workflow.
Check changes to Dockerfile and Action results on my fork.
It is very important for MacBooks with Apple chips, changes it as soon as possible please. I feel #1160 likes this, and #1161 is fixing this.
We're taking a look at this for the next release, until then using the separate tag should work.
Made a working example, you can check the diff here.
Simpler approach than https://github.com/heroiclabs/nakama/pull/1161
The resulting multi-platform image is available in this public Docker Hub repo: https://hub.docker.com/r/toqueteos/nakama/tags
EDIT: Tried the image on Windows (11), Linux (Ubuntu 22.04) and OSX (Sonoma 14.5) hosts. The same approach works with the dsym and pluginbuilder Dockerfiles.
@zyro any status here? happy to help if you guys are having issues
@smsunarto It would be great to have a pull request to review if you have time 🙏
This issue is now resolved and we're publishing multi-platform builds starting with the Nakama v3.26.0 release. Just wanted to leave a note thanking those who contributed with PRs or suggestions, they've been useful even if they weren't directly merged. Also thanks @toqueteos for the GH Action examples, we've also taken inspiration from them.