Skip to content

Commit 3caa2bb

Browse files
authored
Update Dockerfile
1 parent 10bb74d commit 3caa2bb

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

Dockerfile

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
# 阶段一:构建静态站点
2-
FROM alpine:3.19 AS builder
1+
# 阶段一:构建静态站点(使用 Ubuntu 确保 glibc 环境)
2+
FROM ubuntu:22.04 AS builder
33

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/*
68

7-
# 2. 下载并安装 hugo
9+
# 下载并安装 Hugo extended
810
ARG TARGETARCH
911
RUN case ${TARGETARCH} in \
1012
"amd64") HUGO_ARCH="64bit" ;; \
@@ -16,17 +18,17 @@ RUN case ${TARGETARCH} in \
1618
mv /tmp/hugo /usr/local/bin/hugo && \
1719
chmod +x /usr/local/bin/hugo
1820

19-
# 3. 验证 hugo 可执行(现在应该能运行)
21+
# 验证 Hugo 可执行
2022
RUN hugo version
2123

22-
# 4. 创建空白站点
24+
# 创建空白站点
2325
RUN hugo new site /build --force
2426
WORKDIR /build
2527

26-
# 5. 克隆 FixIt 主题
28+
# 克隆 FixIt 主题(使用稳定版本 v0.4.5)
2729
RUN git clone --depth 1 --branch v0.4.5 https://github.com/hugo-fixit/FixIt.git themes/FixIt
2830

29-
# 6. 生成配置文件
31+
# 生成配置文件
3032
RUN cat > config.toml <<EOF
3133
baseURL = "https://example.org/"
3234
title = "My FixIt Site"
@@ -51,25 +53,25 @@ paginate = 10
5153
defaultTheme = "auto"
5254
EOF
5355

54-
# 7. 创建首页
56+
# 创建首页(必须)
5557
RUN cat > content/_index.md <<EOF
5658
---
5759
title: "Home"
5860
---
5961
Welcome to my FixIt site.
6062
EOF
6163

62-
# 8. 创建示例文章
64+
# 创建一篇示例文章
6365
RUN mkdir -p content/posts && \
6466
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
6567

66-
# 9. 构建静态文件
68+
# 构建静态文件
6769
RUN hugo --minify --destination /public
6870

69-
# 10. 验证 index.html 存在
71+
# 验证 index.html 存在
7072
RUN test -f /public/index.html || (echo "ERROR: index.html not generated" && exit 1)
7173

72-
# 阶段二:运行 Nginx
74+
# 阶段二:运行时(轻量 Nginx
7375
FROM nginx:stable-alpine
7476

7577
COPY --from=builder /build/public /usr/share/nginx/html

0 commit comments

Comments
 (0)