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
+16-14Lines changed: 16 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
-
# 阶段一:构建静态站点
2
-
FROMalpine:3.19 AS builder
1
+
# 阶段一:构建静态站点(使用 Ubuntu 确保 glibc 环境)
2
+
FROMubuntu:22.04 AS builder
3
3
4
-
# 1. 安装基础工具和 glibc 兼容层(必须放在最前面)
5
-
RUN apk add --no-cache git curl bash libc6-compat
4
+
# 安装必要工具
5
+
RUN apt-get update && apt-get install -y --no-install-recommends \
6
+
git curl ca-certificates && \
7
+
rm -rf /var/lib/apt/lists/*
6
8
7
-
#2. 下载并安装 hugo
9
+
# 下载并安装 Hugo extended
8
10
ARG TARGETARCH
9
11
RUN case ${TARGETARCH} in \
10
12
"amd64") HUGO_ARCH="64bit" ;; \
@@ -16,17 +18,17 @@ RUN case ${TARGETARCH} in \
16
18
mv /tmp/hugo /usr/local/bin/hugo && \
17
19
chmod +x /usr/local/bin/hugo
18
20
19
-
#3. 验证 hugo 可执行(现在应该能运行)
21
+
# 验证 Hugo 可执行
20
22
RUN hugo version
21
23
22
-
#4. 创建空白站点
24
+
# 创建空白站点
23
25
RUN hugo new site /build --force
24
26
WORKDIR /build
25
27
26
-
#5. 克隆 FixIt 主题
28
+
# 克隆 FixIt 主题(使用稳定版本 v0.4.5)
27
29
RUN git clone --depth 1 --branch v0.4.5 https://github.com/hugo-fixit/FixIt.git themes/FixIt
28
30
29
-
#6. 生成配置文件
31
+
# 生成配置文件
30
32
RUN cat > config.toml <<EOF
31
33
baseURL = "https://example.org/"
32
34
title = "My FixIt Site"
@@ -51,25 +53,25 @@ paginate = 10
51
53
defaultTheme = "auto"
52
54
EOF
53
55
54
-
#7. 创建首页
56
+
# 创建首页(必须)
55
57
RUN cat > content/_index.md <<EOF
56
58
---
57
59
title: "Home"
58
60
---
59
61
Welcome to my FixIt site.
60
62
EOF
61
63
62
-
#8. 创建示例文章
64
+
#创建一篇示例文章
63
65
RUN mkdir -p content/posts && \
64
66
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
65
67
66
-
#9. 构建静态文件
68
+
# 构建静态文件
67
69
RUN hugo --minify --destination /public
68
70
69
-
#10. 验证 index.html 存在
71
+
# 验证 index.html 存在
70
72
RUN test -f /public/index.html || (echo "ERROR: index.html not generated" && exit 1)
0 commit comments