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
RUN apk add --no-cache git curl bash libstdc++ libc6-compat
4
+
RUN apk add --no-cache git curl bash
6
5
7
-
# 根据目标架构下载 Hugo extended 二进制
8
6
ARG TARGETARCH
9
7
RUN case ${TARGETARCH} in \
10
8
"amd64") HUGO_ARCH="64bit" ;; \
@@ -13,78 +11,44 @@ RUN case ${TARGETARCH} in \
13
11
esac && \
14
12
curl -L "https://github.com/gohugoio/hugo/releases/download/v0.156.0/hugo_extended_0.156.0_Linux-${HUGO_ARCH}.tar.gz" | tar -xz -C /usr/local/bin
15
13
16
-
# 验证 Hugo 版本
17
14
RUN hugo version
18
15
19
16
# 创建空白站点
20
17
RUN hugo new site /build --force
21
-
22
18
WORKDIR /build
23
19
24
-
# 克隆 FixIt 主题(使用 v0.4.5,稳定且包含完整布局)
20
+
# 克隆 FixIt 主题(使用 v0.4.5)
25
21
RUN git clone --depth 1 --branch v0.4.5 https://github.com/hugo-fixit/FixIt.git themes/FixIt
26
22
27
-
# 生成基础配置文件(符合 FixIt 主题要求)
28
-
RUN cat > config.toml <<EOF
29
-
baseURL = "https://example.org/"
30
-
title = "My FixIt Site"
31
-
theme = "FixIt"
32
-
defaultContentLanguage = "zh-cn"
33
-
enableRobotsTXT = true
34
-
paginate = 10
35
-
36
-
[markup]
37
-
_merge = "shallow"
38
-
39
-
[outputs]
40
-
_merge = "shallow"
41
-
42
-
[taxonomies]
43
-
_merge = "shallow"
44
-
45
-
[params]
46
-
version = "4.x"
47
-
description = "A site built with Hugo FixIt theme"
48
-
keywords = ["Hugo", "FixIt", "Blog"]
49
-
defaultTheme = "auto"
50
-
EOF
23
+
# 复制预先准备好的配置文件
24
+
COPY config.toml .
51
25
52
-
#创建首页内容(解决无 index.html 的问题)
26
+
#创建首页(必须)
53
27
RUN cat > content/_index.md <<EOF
54
28
---
55
29
title: "Home"
56
30
---
57
-
58
-
Welcome to my FixIt site!
31
+
Welcome to my FixIt site.
59
32
EOF
60
33
61
-
#创建一篇默认示例文章
34
+
#创建一篇示例文章
62
35
RUN mkdir -p content/posts && \
63
-
printf '%s\n''---''title: "Welcome to FixIt Docker"'"date: $(date +%Y-%m-%d)"'draft: false''---''''This is a default post from the Docker image. You can replace it by mounting your own content.''''Happy blogging!' > content/posts/welcome.md
36
+
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
64
37
65
-
# 构建静态文件(作为容器启动时的后备内容)
66
-
RUN hugo --minify --destination /default-public
38
+
# 构建静态文件
39
+
RUN hugo --minify --destination /public
67
40
68
-
# 注意:不再验证 index.html 是否存在,因为运行时 entrypoint 会重新生成
41
+
# 验证 index.html 存在(关键)
42
+
RUN test -f /public/index.html || (echo "index.html not generated" && exit 1)
69
43
70
-
#========== 阶段二:运行时镜像 ==========
44
+
# 阶段二:提供静态文件的 Nginx
71
45
FROM nginx:stable-alpine
72
46
73
-
RUN apk add --no-cache bash libstdc++ libc6-compat
0 commit comments