Frp/Dockerfile
2024-12-27 19:59:41 +08:00

30 lines
581 B
Docker

# 使用官方Go镜像作为构建环境
FROM golang:1.23-alpine AS builder
# 设置工作目录
WORKDIR /app
# 复制源代码
COPY . .
# 设置GOPROXY 阿里云
RUN go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
# 下载依赖
RUN go mod download
# 构建应用
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
# 使用轻量级的alpine作为运行环境
FROM alpine:latest
WORKDIR /root/
# 从builder阶段复制编译好的应用
COPY --from=builder /app/main .
# 暴露应用端口(根据实际需要修改)
EXPOSE 8080
# 运行应用
CMD ["./main"]