Selinore commited on
Commit
e9ac7f1
·
verified ·
1 Parent(s): c2e9772

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +36 -0
Dockerfile ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用官方Golang镜像
2
+ FROM golang:1.23-alpine AS build
3
+
4
+ # 安装git
5
+ RUN apk add --no-cache git
6
+
7
+ # 设置工作目录
8
+ WORKDIR /app
9
+
10
+ # 克隆项目仓库
11
+ RUN git clone https://github.com/jianglinzhang/gemini-antiblock-go.git .
12
+
13
+ # Copy go.mod and go.sum files first for better caching
14
+ # COPY go.mod go.sum* ./
15
+
16
+
17
+ # 下载依赖
18
+ RUN go mod download
19
+
20
+ # 构建应用
21
+ RUN CGO_ENABLED=0 GOOS=linux go build -o main ./main.go
22
+
23
+ # 创建最小化生产镜像
24
+ FROM alpine:latest
25
+
26
+ # 创建app目录
27
+ WORKDIR /app
28
+
29
+ # 从构建阶段复制二进制文件
30
+ COPY --from=build /app/main .
31
+
32
+ # 暴露端口
33
+ EXPOSE 8080
34
+
35
+ # 运行可执行文件
36
+ CMD ["./main"]