File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -114,6 +114,19 @@ We use a multi-stage Alpine-based build — keeps the final image around ~33MB:
114114docker build -f docker/Dockerfile -t louisho5/picobot:latest .
115115```
116116
117+ #### Multi-arch builds with BuildKit
118+
119+ Picobot's Dockerfile supports BuildKit/` buildx ` so you can push both AMD64 and ARM64 images in a single run:
120+
121+ ``` sh
122+ docker buildx build \
123+ --platform linux/amd64,linux/arm64 \
124+ --builder default \
125+ -t louisho5/picobot:latest .
126+ ```
127+
128+ Add ` --push ` to publish directly to a registry or ` --load ` to import one architecture into your local Docker engine.
129+
117130> ** Important:** Run this from the ** project root** , not from inside ` docker/ ` . The build context needs access to the whole codebase.
118131
119132### Test it locally
@@ -241,4 +254,4 @@ Try cleaning and re-downloading deps:
241254go clean -cache
242255go mod tidy
243256go build ./...
244- ```
257+ ```
Original file line number Diff line number Diff line change 1+ # syntax=docker/dockerfile:1.7
2+
13# ---- Build Stage ----
2- FROM golang:1.26-alpine AS builder
4+ ARG BUILDPLATFORM
5+ FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
6+
7+ ARG TARGETOS
8+ ARG TARGETARCH
9+ ARG TARGETVARIANT
310
411RUN apk add --no-cache git ca-certificates tzdata
512
@@ -8,7 +15,13 @@ COPY go.mod go.sum ./
815RUN go mod download
916
1017COPY . .
11- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
18+ RUN set -eux; \
19+ GOOS="${TARGETOS:-linux}" ; \
20+ GOARCH="${TARGETARCH:-amd64}" ; \
21+ if [ "$GOARCH" = "arm" ] && [ -n "${TARGETVARIANT}" ]; then \
22+ GOARM="${TARGETVARIANT#v}" ; \
23+ fi; \
24+ CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" ${GOARM:+GOARM=$GOARM} \
1225 go build -ldflags="-s -w" -o /picobot ./cmd/picobot
1326
1427# ---- Runtime Stage ----
You can’t perform that action at this time.
0 commit comments