Skip to content

Commit

Permalink
feat(docker): faster multi-platform builds
Browse files Browse the repository at this point in the history
  • Loading branch information
WaterLemons2k authored Jan 28, 2023
1 parent 3adfc85 commit 4067132
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# build stage
FROM golang:1.19 AS builder
FROM --platform=$BUILDPLATFORM golang:1.19-alpine AS builder

WORKDIR /app
COPY . .
RUN go env -w GO111MODULE=on \
ARG TARGETOS TARGETARCH
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk add git make tzdata \
&& go env -w GO111MODULE=on \
&& go env -w GOPROXY=https://goproxy.cn,direct \
&& make clean build
&& GOOS=$TARGETOS GOARCH=$TARGETARCH make clean build

# final stage
FROM alpine
LABEL name=ddns-go
LABEL url=https://github.com/jeessy2/ddns-go

WORKDIR /app
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk add --no-cache tzdata
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
ENV TZ=Asia/Shanghai
COPY --from=builder /app/ddns-go /app/ddns-go
EXPOSE 9876
Expand Down

0 comments on commit 4067132

Please sign in to comment.