alcex commited on
Commit
6549611
·
verified ·
1 Parent(s): c2bc9a1

Create Dockerfile

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