This commit is contained in:
2026-01-16 01:55:32 +08:00
commit e9d29f9713
3 changed files with 336 additions and 0 deletions

22
Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
# 阶段一: 编译
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY main.go .
# 编译 Go 程序,使用 CGO_ENABLED=0 生成静态链接的可执行文件
RUN go build -ldflags "-s -w" -o api-proxy main.go
# 阶段二: 运行
FROM alpine:latest
WORKDIR /app
# 从编译阶段复制可执行文件
COPY --from=builder /app/api-proxy .
# 暴露您的程序监听端口 (假设您在 main.go 中设置为 8080)
EXPOSE 7890
# 定义容器启动命令
CMD ["./api-proxy"]