You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
436 B
Docker

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

FROM golang:1.18 as builder
# 启用go module
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct
WORKDIR /builder
COPY . .
RUN go mod download && go build -o app && upx -9 app
RUN ls -lh && chmod +x ./app
COPY . .
# 指定OS等并go build
RUN GOOS=linux GOARCH=amd64 go build .
# 运行阶段指定scratch作为基础镜像
FROM alpine
WORKDIR /app
COPY --from=builder /builder/app ./app
CMD ./app
ENTRYPOINT ["./app"]