Spaces:
Running
Running
| # 构建阶段 | |
| FROM golang:1.24-alpine AS builder | |
| # 设置Go环境变量 | |
| ENV GOPROXY=https://goproxy.cn,direct | |
| ENV GO111MODULE=on | |
| ENV CGO_ENABLED=0 | |
| # 安装 git | |
| RUN apk add --no-cache git | |
| WORKDIR /app | |
| # 克隆源代码 | |
| RUN git clone --depth 1 https://github.com/coderZoe/scira2api.git . | |
| # 下载 Go 模块依赖 | |
| RUN go mod download | |
| # 编译应用 | |
| RUN GOOS=linux go build -a -installsuffix cgo -ldflags="-s -w" -o scira2api . | |
| # --- 运行阶段 --- | |
| FROM alpine:3.18 | |
| # 安装核心运行时依赖 | |
| RUN apk --no-cache add ca-certificates | |
| WORKDIR /app | |
| # 从构建阶段复制编译好的二进制文件 | |
| COPY --from=builder /app/scira2api . | |
| # 暴露端口 | |
| EXPOSE 8080 | |
| # 启动命令 | |
| CMD ["./scira2api"] |