forked from lin-snow/Ech0
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (42 loc) · 1.59 KB
/
Dockerfile
File metadata and controls
54 lines (42 loc) · 1.59 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# =================== 构建阶段 ===================
FROM alpine:latest AS builder
WORKDIR /app
ENV TZ=Asia/Shanghai
# 获取构建平台信息
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT
# 创建数据目录
RUN mkdir -p /app/data && \
mkdir -p /app/template && \
mkdir -p /app/config
# 将所有平台的 ech0 二进制和前端资源复制进镜像
COPY /backend-artifacts/* /tmp/
COPY /frontend-asset/frontend.tar.gz /tmp/
COPY /config/config.yaml /app/config/config.yaml
# 解压对应平台的 ech0 二进制
RUN mkdir -p /app/template && \
if [ "$TARGETOS" = "linux" ] && [ "$TARGETARCH" = "amd64" ]; then \
tar -xzf /tmp/ech0-linux-amd64.tar.gz -C /tmp && mv /tmp/ech0-linux-amd64 /app/ech0; \
elif [ "$TARGETOS" = "linux" ] && [ "$TARGETARCH" = "arm64" ]; then \
tar -xzf /tmp/ech0-linux-arm64.tar.gz -C /tmp && mv /tmp/ech0-linux-arm64 /app/ech0; \
elif [ "$TARGETOS" = "linux" ] && [ "$TARGETARCH" = "arm" ] && [ "$TARGETVARIANT" = "v7" ]; then \
tar -xzf /tmp/ech0-linux-armv7.tar.gz -C /tmp && mv /tmp/ech0-linux-armv7 /app/ech0; \
else \
echo "Unsupported platform: $TARGETOS/$TARGETARCH$TARGETVARIANT" && exit 1; \
fi && \
# 解压前端静态资源到 /app/template
tar -xzf /tmp/frontend.tar.gz -C /app/template && \
# 清理临时文件
rm -rf /tmp/*
# =================== 最终镜像 ===================
# FROM debian:bookworm-slim
FROM alpine:latest
WORKDIR /app
ENV TZ=Asia/Shanghai
COPY --from=builder /app /app
RUN ls -lh /app
# 设置 ech0 二进制文件的权限
RUN chmod +x /app/ech0
EXPOSE 6277
CMD ["/app/ech0"]