You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Dockerfile
+14-15Lines changed: 14 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
1
# 阶段一:构建静态站点
2
2
FROM alpine:3.19 AS builder
3
3
4
-
RUN apk add --no-cache git curl bash
4
+
# 1. 安装基础工具和 glibc 兼容层(必须放在最前面)
5
+
RUN apk add --no-cache git curl bash libc6-compat
5
6
7
+
# 2. 下载并安装 hugo
6
8
ARG TARGETARCH
7
9
RUN case ${TARGETARCH} in \
8
10
"amd64") HUGO_ARCH="64bit" ;; \
@@ -14,16 +16,17 @@ RUN case ${TARGETARCH} in \
14
16
mv /tmp/hugo /usr/local/bin/hugo && \
15
17
chmod +x /usr/local/bin/hugo
16
18
19
+
# 3. 验证 hugo 可执行(现在应该能运行)
17
20
RUN hugo version
18
21
19
-
# 创建空白站点
22
+
#4. 创建空白站点
20
23
RUN hugo new site /build --force
21
24
WORKDIR /build
22
25
23
-
# 克隆 FixIt 主题(使用 v0.4.5)
26
+
#5. 克隆 FixIt 主题
24
27
RUN git clone --depth 1 --branch v0.4.5 https://github.com/hugo-fixit/FixIt.git themes/FixIt
25
28
26
-
# 生成配置文件
29
+
#6. 生成配置文件
27
30
RUN cat > config.toml <<EOF
28
31
baseURL = "https://example.org/"
29
32
title = "My FixIt Site"
@@ -48,32 +51,28 @@ paginate = 10
48
51
defaultTheme = "auto"
49
52
EOF
50
53
51
-
# 创建首页
54
+
#7. 创建首页
52
55
RUN cat > content/_index.md <<EOF
53
56
---
54
57
title: "Home"
55
58
---
56
59
Welcome to my FixIt site.
57
60
EOF
58
61
59
-
# 创建示例文章
62
+
#8. 创建示例文章
60
63
RUN mkdir -p content/posts && \
61
64
printf '%s\n''---''title: "Welcome to FixIt Docker"'"date: $(date +%Y-%m-%d)"'draft: false''---''''This is a default post. You can replace it by mounting your own content.' > content/posts/welcome.md
62
65
63
-
# 构建静态文件
66
+
#9. 构建静态文件
64
67
RUN hugo --minify --destination /public
65
68
66
-
# 验证 index.html 存在
67
-
RUN test -f /public/index.html || (echo "index.html not generated" && exit 1)
69
+
#10. 验证 index.html 存在
70
+
RUN test -f /public/index.html || (echo "ERROR: index.html not generated" && exit 1)
0 commit comments