Skip to content

Commit 4cb4390

Browse files
Multi Platform Support (#18)
* Add multi-platform Docker image support (amd64 + arm64) Enable native arm64 support for Apple Silicon users by building multi-architecture images via buildx. Uses TARGETARCH for explicit Go cross-compilation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update README.md with tag v0.0.7 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add QEMU setup for multi-platform Docker builds Required for arm64 emulation on amd64 runners. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Use cross-compilation for multi-platform Docker builds Replace QEMU emulation with native cross-compilation by adding --platform=$BUILDPLATFORM to the build stage. Go cross-compiles to the target architecture natively, eliminating slow emulation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update GitHub Actions to latest versions and add image output - actions/checkout v4 → v6 - actions/setup-go v4 → v6 (caching now enabled by default) - golangci/golangci-lint-action v8 → v9 - Add step to output pushed image registry path Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3d03efe commit 4cb4390

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

.github/workflows/go.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,22 @@ jobs:
1212
runs-on: ubuntu-latest
1313
name: Test and Build
1414
steps:
15-
- uses: actions/checkout@v4
16-
- uses: actions/setup-go@v4
15+
- uses: actions/checkout@v6
16+
- uses: actions/setup-go@v6
1717
with:
1818
go-version: '1.26'
19-
cache: true
2019
- name: Test
2120
run: go test ./...
2221

2322
code_quality:
2423
name: Code Quality🎖️
2524
runs-on: ubuntu-latest
2625
steps:
27-
- uses: actions/checkout@v4
28-
- uses: actions/setup-go@v4
26+
- uses: actions/checkout@v6
27+
- uses: actions/setup-go@v6
2928
with:
3029
go-version: '1.26'
31-
cache: true
32-
- uses: golangci/golangci-lint-action@v8
30+
- uses: golangci/golangci-lint-action@v9
3331
with:
3432
version: v2.10.1
3533
args: --timeout 9m0s
@@ -67,7 +65,7 @@ jobs:
6765
contents: read
6866
packages: write
6967
steps:
70-
- uses: actions/checkout@v4
68+
- uses: actions/checkout@v6
7169

7270
- uses: docker/setup-buildx-action@v3
7371

@@ -84,9 +82,13 @@ jobs:
8482
push: true
8583
context: .
8684
file: Dockerfile
85+
platforms: linux/amd64,linux/arm64
8786
provenance: true
8887
sbom: true
8988
cache-from: type=gha
9089
cache-to: type=gha,mode=max
9190
tags: |
9291
${{ vars.DOCKER_REGISTRY_TARGET }}:${{ env.RELEASE_VERSION }}
92+
93+
- name: Output Image Path
94+
run: echo "Image pushed to ${{ vars.DOCKER_REGISTRY_TARGET }}:${{ env.RELEASE_VERSION }}"

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Build stage
2-
FROM golang:1.26 AS build
1+
# Build stage - runs on native platform, cross-compiles to target
2+
FROM --platform=$BUILDPLATFORM golang:1.26 AS build
33

44
WORKDIR /src
55

@@ -9,7 +9,9 @@ RUN go mod download
99

1010
# Copy source code (this layer changes frequently)
1111
COPY . .
12-
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/main main.go
12+
13+
ARG TARGETARCH
14+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-s -w" -o /app/main main.go
1315

1416
# Final stage - distroless
1517
FROM gcr.io/distroless/static-debian12

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To deploy the server, you need to build a Docker image using the provided `Docke
2222
```dockerfile
2323
# Use the official static-server image as the base image
2424
# This will pull the prebuilt version of the static-server to run your static website
25-
FROM zopdev/static-server:v0.0.6
25+
FROM zopdev/static-server:v0.0.7
2626

2727
# Copy static files into the container
2828
# The 'COPY' directive moves your static files (in this case, located at '/app/out') into the '/website' directory

0 commit comments

Comments
 (0)