Skip to content

Commit fded580

Browse files
authored
Update Dockerfile
1 parent a0d92c6 commit fded580

1 file changed

Lines changed: 44 additions & 17 deletions

File tree

Dockerfile

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,54 @@ RUN case ${TARGETARCH} in \
1616
# 验证 Hugo 版本
1717
RUN hugo version
1818

19-
WORKDIR /build
19+
# 创建空白站点
20+
RUN hugo new site /build --force
2021

21-
# 克隆完整的 FixIt 仓库(包含主题源码和 apps/demo)
22-
RUN git clone --depth 1 --branch v0.3.6 https://github.com/hugo-fixit/FixIt.git repo
22+
WORKDIR /build
2323

24-
# 复制示例站点到当前工作目录
25-
RUN cp -r repo/apps/demo/* .
24+
# 克隆 FixIt 主题(使用稳定标签 v0.3.6,确保存在)
25+
RUN git clone --depth 1 --branch v0.3.6 https://github.com/hugo-fixit/FixIt.git /tmp/fixit-repo
2626

27-
# 将主题源码复制到 themes/FixIt 目录
27+
# 将主题核心文件复制到 themes/FixIt
2828
RUN mkdir -p themes/FixIt && \
29-
cp -r repo/layouts repo/assets repo/i18n repo/data repo/archetypes repo/static repo/theme.toml themes/FixIt/
30-
31-
# 修正 demo 站点配置:确保主题名称正确,并设置 baseURL
32-
RUN sed -i 's|^theme = .*|theme = "FixIt"|' hugo.toml && \
33-
sed -i 's|^baseURL = .*|baseURL = "https://example.org/"|' hugo.toml
34-
35-
# 确保至少有一篇文章(如果 demo 中没有 posts)
36-
RUN if [ ! -d content/posts ]; then mkdir -p content/posts; fi && \
37-
if [ ! -f content/posts/welcome.md ]; then \
38-
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; \
39-
fi
29+
cp -r /tmp/fixit-repo/layouts \
30+
/tmp/fixit-repo/assets \
31+
/tmp/fixit-repo/i18n \
32+
/tmp/fixit-repo/data \
33+
/tmp/fixit-repo/archetypes \
34+
/tmp/fixit-repo/static \
35+
/tmp/fixit-repo/theme.toml \
36+
themes/FixIt/
37+
38+
# 生成基础配置文件(符合 FixIt 主题要求)
39+
RUN cat > config.toml <<EOF
40+
baseURL = "https://example.org/"
41+
title = "My FixIt Site"
42+
theme = "FixIt"
43+
defaultContentLanguage = "zh-cn"
44+
enableRobotsTXT = true
45+
paginate = 10
46+
summaryLength = 70
47+
48+
[markup]
49+
_merge = "shallow"
50+
51+
[outputs]
52+
_merge = "shallow"
53+
54+
[taxonomies]
55+
_merge = "shallow"
56+
57+
[params]
58+
version = "4.x"
59+
description = "A site built with Hugo FixIt theme"
60+
keywords = ["Hugo", "FixIt", "Blog"]
61+
defaultTheme = "auto"
62+
EOF
63+
64+
# 创建一篇默认示例文章(确保站点有内容)
65+
RUN mkdir -p content/posts && \
66+
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
4067

4168
# 构建静态文件(作为容器启动时的后备内容)
4269
RUN hugo --minify --destination /default-public

0 commit comments

Comments
 (0)