forked from dengxiwang/gotab-personal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (41 loc) · 1.13 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (41 loc) · 1.13 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
55
56
57
# 构建阶段
FROM --platform=$BUILDPLATFORM alpine AS builder
ARG TARGETOS
ARG TARGETARCH
ARG SERVER_PORT=8080 # 构建阶段默认值
WORKDIR /app
COPY gotab-server-${TARGETOS}-${TARGETARCH} gotab-server
RUN chmod +x gotab-server
COPY web ./web/
# =============================
# 最终运行环境
# =============================
FROM alpine
WORKDIR /app
COPY --from=builder /app/gotab-server .
COPY --from=builder /app/web ./web/
# 定义运行时环境变量
ENV SERVER_PORT=8080
EXPOSE ${SERVER_PORT}
CMD ["sh", "-c", "echo Running server on port $SERVER_PORT && ./gotab-server -port=$SERVER_PORT"]
# 多平台构建
# 第一步:
# docker buildx create --name mybuilder --use
# 第二步(本地测试):
# VERSION=1.6.1.6
# docker buildx build \
# --platform linux/arm64 \
# -t doxwant/gotab:${VERSION} \
# -t doxwant/gotab:latest \
# --load \
# --no-cache \
# .
# 第三步(多平台构建推送):
# VERSION=1.6.1.6
# docker buildx build \
# --platform linux/amd64,linux/arm64 \
# -t doxwant/gotab:${VERSION} \
# -t doxwant/gotab:latest \
# --push \
# --no-cache \
# .