From acec12d46a57c348a35b8bf4eb7598894f9db1cd Mon Sep 17 00:00:00 2001 From: Sung Date: Sun, 19 Oct 2025 13:44:54 -0700 Subject: [PATCH] Add multi-platform Docker support for ARM64, ARMv7, and 386 --- .github/workflows/release-server.yml | 12 +++++++++++- host/docker/Dockerfile | 28 +++++++++++++++++++++++----- scripts/server/build.sh | 2 ++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-server.yml b/.github/workflows/release-server.yml index f52e1508..a5f52933 100644 --- a/.github/workflows/release-server.yml +++ b/.github/workflows/release-server.yml @@ -55,10 +55,19 @@ jobs: ./scripts/generate-changelog.sh server "$TAG" "$PREV_TAG" > /tmp/changelog.txt cat /tmp/changelog.txt + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Prepare Docker build context run: | VERSION="${{ steps.version.outputs.version }}" cp build/server/dnote_server_${VERSION}_linux_amd64.tar.gz host/docker/ + cp build/server/dnote_server_${VERSION}_linux_arm64.tar.gz host/docker/ + cp build/server/dnote_server_${VERSION}_linux_arm.tar.gz host/docker/ + cp build/server/dnote_server_${VERSION}_linux_386.tar.gz host/docker/ - name: Login to Docker Hub uses: docker/login-action@v3 @@ -71,11 +80,12 @@ jobs: with: context: ./host/docker push: true + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 tags: | dnote/dnote:${{ steps.version.outputs.version }} dnote/dnote:latest build-args: | - tarballName=dnote_server_${{ steps.version.outputs.version }}_linux_amd64.tar.gz + version=${{ steps.version.outputs.version }} - name: Create GitHub release env: diff --git a/host/docker/Dockerfile b/host/docker/Dockerfile index 88681591..e67da318 100644 --- a/host/docker/Dockerfile +++ b/host/docker/Dockerfile @@ -1,12 +1,30 @@ FROM busybox:glibc -ARG tarballName -RUN test -n "$tarballName" +ARG TARGETPLATFORM +ARG version -WORKDIR dnote +RUN test -n "$TARGETPLATFORM" || (echo "TARGETPLATFORM is required" && exit 1) +RUN test -n "$version" || (echo "version is required" && exit 1) -COPY "$tarballName" . -RUN tar -xvzf "$tarballName" +WORKDIR /tmp/tarballs + +# Copy all architecture tarballs +COPY dnote_server_*.tar.gz ./ + +# Select and extract the correct tarball based on target platform +RUN case "$TARGETPLATFORM" in \ + "linux/amd64") ARCH="amd64" ;; \ + "linux/arm64") ARCH="arm64" ;; \ + "linux/arm/v7") ARCH="arm" ;; \ + "linux/386") ARCH="386" ;; \ + *) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \ + esac && \ + TARBALL="dnote_server_${version}_linux_${ARCH}.tar.gz" && \ + echo "Extracting $TARBALL for $TARGETPLATFORM" && \ + mkdir -p /dnote && \ + tar -xvzf "$TARBALL" -C /dnote + +WORKDIR /dnote COPY entrypoint.sh . ENTRYPOINT ["./entrypoint.sh"] diff --git a/scripts/server/build.sh b/scripts/server/build.sh index a4e24df5..d625d492 100755 --- a/scripts/server/build.sh +++ b/scripts/server/build.sh @@ -74,3 +74,5 @@ go install src.techknowlogick.com/xgo@latest build linux amd64 build linux arm64 +build linux arm +build linux 386