Spaces:
Runtime error
Runtime error
Upload Dockerfile
#1
by
suertang
- opened
- Dockerfile +33 -1
Dockerfile
CHANGED
@@ -1 +1,33 @@
|
|
1 |
-
FROM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM alpine:latest as git
|
2 |
+
WORKDIR /app
|
3 |
+
RUN apk add git && git clone https://github.com/aurora-develop/aurora ./
|
4 |
+
|
5 |
+
# 使用 Go 1.21 官方镜像作为构建环境
|
6 |
+
FROM golang:1.21 AS builder
|
7 |
+
|
8 |
+
# 禁用 CGO
|
9 |
+
ENV CGO_ENABLED=0
|
10 |
+
|
11 |
+
# 设置工作目录
|
12 |
+
WORKDIR /app
|
13 |
+
|
14 |
+
# 复制 go.mod 和 go.sum 并下载依赖
|
15 |
+
COPY --from=git /app /app
|
16 |
+
RUN go mod download
|
17 |
+
|
18 |
+
# 复制源代码并构建应用
|
19 |
+
RUN go build -ldflags "-s -w" -o /app/aurora .
|
20 |
+
|
21 |
+
# 使用 Alpine Linux 作为最终镜像
|
22 |
+
FROM alpine:latest
|
23 |
+
ENV PORT=7680
|
24 |
+
# 设置工作目录
|
25 |
+
WORKDIR /app
|
26 |
+
|
27 |
+
# 从构建阶段复制编译好的应用和资源
|
28 |
+
COPY --from=builder /app/aurora /app/aurora
|
29 |
+
|
30 |
+
# 暴露端口
|
31 |
+
EXPOSE 7680
|
32 |
+
|
33 |
+
CMD ["/app/aurora"]
|