File size: 709 Bytes
dae928a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 构建阶段
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"]