FROM golang:1.20 as builder WORKDIR /app
COPY . . # 构建应用 #RUN go env -w GOPROXY=https://goproxy.cn,direct #RUN go mod tidy
RUN go env -w GO111MODULE=on
RUN go env -w GOPROXY=https://goproxy.cn
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/main /app/
# 暴露端口 EXPOSE 8000 # 运行应用 CMD ["./main"]
#docker build --network host -t small:gintext . 使用--network host来指定容器打包网络