Skip to content

Commit

Permalink
build: support multi-platform image
Browse files Browse the repository at this point in the history
  • Loading branch information
xvrzhao committed Jan 13, 2025
1 parent e5c98ad commit 99d2c8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM golang:1.23-alpine3.20@sha256:9dd2625a1ff2859b8d8b01d8f7822c0f528942fe56cfe7a1e7c38d3b8d72d679 AS builder
FROM golang:1.23-alpine AS builder
RUN go env -w GO111MODULE=on GOPROXY=https://goproxy.cn,direct
WORKDIR /app
COPY ./go.mod ./go.sum ./
RUN go mod download
COPY ./ ./
RUN CGO_ENABLED=0 go build -o ./target/http ./cmd/http && CGO_ENABLED=0 go build -o ./target/cron ./cmd/cron

FROM alpine:3.20@sha256:beefdbd8a1da6d2915566fde36db9db0b524eb737fc57cd1367effd16dc0d06d
FROM alpine
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk add --no-cache tzdata && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ registry = my.registry.host/my_repo_name
project = my_project_name
image = ${registry}/${project}

version ?=
version ?= latest
env ?= production
arch = amd64
tag = ${version}-${env}-${arch}
tag = ${version}-${env}

table ?=
model ?=
Expand All @@ -25,7 +24,7 @@ endif
@echo image tag: ${tag}

image: check
docker buildx build --platform=linux/amd64 --build-arg PUBLISH_MODE=${env} -t ${image}:${tag} .
docker buildx build --platform linux/amd64,linux/arm64 --build-arg PUBLISH_MODE=${env} -t ${image}:${tag} .

push: check
docker push ${image}:${tag}
Expand Down

0 comments on commit 99d2c8d

Please sign in to comment.