Skip to content

Commit

Permalink
support build multi-arch image (#175)
Browse files Browse the repository at this point in the history
Signed-off-by: Ping Yu <yuping@pingcap.com>
  • Loading branch information
pingyu committed Mar 8, 2024
1 parent 6c9e603 commit c395f5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the go-tpc binary
FROM golang:1.18 as builder
FROM golang:1.21 as builder

WORKDIR /workspace
COPY go.mod go.mod
Expand All @@ -12,9 +12,10 @@ RUN go mod download
COPY . .

# Build
RUN GOOS=linux GOARCH=amd64 make build
ARG TARGETOS TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make build

FROM pingcap/alpine-glibc:3.10
FROM alpine

RUN apk add --no-cache \
dumb-init \
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GOBUILD=$(GO) build -ldflags '$(LDFLAGS)'

# Image URL to use all building/pushing image targets
IMG ?= go-tpc:latest
PLATFORM ?= linux/amd64,linux/arm64

all: format test build

Expand Down Expand Up @@ -42,3 +43,8 @@ docker-build: test

docker-push: docker-build
docker push ${IMG}

# Create multiarch driver if not exists:
# docker buildx create --name multiarch --driver docker-container --use
docker-multiarch: test
docker buildx build --platform ${PLATFORM} . -t ${IMG} --push

0 comments on commit c395f5d

Please sign in to comment.