com.snow.auto_monitor/Dockerfile

35 lines
764 B
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# # 使用官方Go镜像作为构建环境
# FROM golang AS builder
# # 设置工作目录
# WORKDIR /app
# # 复制项目源码
# COPY . .
# # 复制go模块依赖文件
# COPY go.mod go.sum ./
# # 安装go模块依赖
# RUN go env -w GOPROXY=https://goproxy.cn,direct
# RUN go mod tidy
# # 编译Go应用程序生成静态链接的二进制文件
# RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o server .
# 创建最终镜像用于运行编译后的Go程序
FROM alpine
ENV server = "admin"
# 设置工作目录
WORKDIR /app
# 将编译好的二进制文件从构建阶段复制到运行阶段
COPY /server .
#COPY --from=builder /app/server .
COPY .env .
# 设置容器启动时运行的命令
ENTRYPOINT ["/app/server", "-a", "$server"]