Skip to content

Commit 8178169

Browse files
authored
Update Dockerfile
1 parent 04399ba commit 8178169

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

Dockerfile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,29 @@ RUN case ${TARGETARCH} in \
1818

1919
RUN hugo version
2020

21-
# 克隆 starter 模板(包含主题和静态资源)
2221
RUN git clone --depth 1 https://github.com/hugo-fixit/hugo-fixit-starter.git /build
2322
WORKDIR /build
2423

25-
# 构建静态文件,baseURL 设为根路径
2624
RUN hugo --minify --baseURL "/" --destination /public
2725

28-
# 修正所有 HTML 中残留的 /hugo-fixit-starter/ 子路径
26+
# 修复 HTML 中的子路径残留
2927
RUN find /public -type f -name "*.html" -exec sed -i 's|/hugo-fixit-starter/|/|g' {} \;
3028

31-
# 复制缺失的图标文件(从源 static 目录复制到 public 根目录)
32-
RUN cp /build/static/apple-touch-icon.png /public/ 2>/dev/null || true
33-
RUN cp /build/static/favicon-32x32.png /public/ 2>/dev/null || true
34-
RUN cp /build/static/favicon-16x16.png /public/ 2>/dev/null || true
35-
RUN cp /build/static/favicon.ico /public/ 2>/dev/null || true
36-
RUN cp /build/static/safari-pinned-tab.svg /public/ 2>/dev/null || true
37-
RUN cp /build/static/site.webmanifest /public/ 2>/dev/null || true
29+
# 复制所有静态资源(包括缺失的图标)
30+
RUN cp -r /build/static/* /public/ 2>/dev/null || true
31+
32+
# 如果仍缺少特定图标,创建简单占位(避免 404)
33+
RUN for icon in apple-touch-icon.png favicon-32x32.png favicon-16x16.png; do \
34+
if [ ! -f "/public/$icon" ]; then \
35+
echo "Creating placeholder $icon"; \
36+
convert -size 32x32 xc:transparent /public/$icon 2>/dev/null || \
37+
touch /public/$icon; \
38+
fi; \
39+
done
3840

3941
# 验证首页存在
4042
RUN test -f /public/index.html
4143

42-
# 阶段二:Nginx 服务
4344
FROM nginx:stable-alpine
4445
COPY --from=builder /public /usr/share/nginx/html
4546
EXPOSE 80

0 commit comments

Comments
 (0)