ykl45 commited on
Commit
a167c68
1 Parent(s): 2910aef

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -0
Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用 Go 1.21 官方镜像作为构建环境
2
+ FROM golang:1.21 AS builder
3
+
4
+ # 禁用 CGO
5
+ ENV CGO_ENABLED=0
6
+
7
+ RUN apt-get update && apt-get install -y git
8
+ RUN git clone https://github.com/renqabs/g2a.git /app
9
+
10
+ # 设置工作目录
11
+ WORKDIR /app
12
+
13
+ # 复制 go.mod 和 go.sum 并下载依赖
14
+
15
+ RUN go mod download
16
+
17
+ # 复制源代码并构建应用
18
+ COPY . .
19
+ RUN go build -ldflags "-s -w" -o /app/groqai2api .
20
+
21
+ # 使用 Alpine Linux 作为最终镜像
22
+ FROM alpine:latest
23
+
24
+ # 设置工作目录
25
+ WORKDIR /app
26
+
27
+ # 从构建阶段复制编译好的应用和资源
28
+ COPY --from=builder /app/groqai2api /app/groqai2api
29
+
30
+ # 暴露端口
31
+ EXPOSE 8080
32
+
33
+ CMD ["/app/groqai2api"]