Skip to content

Commit

Permalink
fix: golang 的 docker 镜像改为分阶段构建
Browse files Browse the repository at this point in the history
  • Loading branch information
CaoMeiYouRen committed Dec 8, 2023
1 parent ef9cd39 commit 502c03e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion templates/golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
FROM golang:alpine as builder

WORKDIR /home/app

COPY . /home/app

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go

FROM scratch

WORKDIR /home/app

COPY ./main /home/app
COPY --from=builder /home/app/main .

EXPOSE 8080

Expand Down

0 comments on commit 502c03e

Please sign in to comment.