mirror of
https://github.com/handsomezhuzhu/api-proxy.git
synced 2026-02-20 11:50:15 +00:00
init
This commit is contained in:
22
Dockerfile
Normal file
22
Dockerfile
Normal 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"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user