FROM golang:1.19.4 as builder

# 设置容器环境变量
ENV GOPROXY=https://goproxy.cn,direct
ENV GOOS=linux
ENV GOARCH=amd64
ENV CGO_ENABLED=0

COPY . /app

WORKDIR /app


RUN go build -ldflags="-s -w" -installsuffix cgo -o go_init

FROM alpine as prod

# 开放端口
EXPOSE 9000

# 创建一个目录
RUN mkdir -p /app/logs

RUN chmod 666 /app/logs

RUN mkdir -p /app/templates

RUN chmod 666 /app/templates

RUN ls /app

COPY --from=builder /app/go_init /app


# 启动
CMD ["/app/go_init"]

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐