Skip to content

Commit 10bb74d

Browse files
authored
Update Dockerfile
1 parent 4761ec2 commit 10bb74d

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

Dockerfile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# 阶段一:构建静态站点
22
FROM alpine:3.19 AS builder
33

4-
RUN apk add --no-cache git curl bash
4+
# 1. 安装基础工具和 glibc 兼容层(必须放在最前面)
5+
RUN apk add --no-cache git curl bash libc6-compat
56

7+
# 2. 下载并安装 hugo
68
ARG TARGETARCH
79
RUN case ${TARGETARCH} in \
810
"amd64") HUGO_ARCH="64bit" ;; \
@@ -14,16 +16,17 @@ RUN case ${TARGETARCH} in \
1416
mv /tmp/hugo /usr/local/bin/hugo && \
1517
chmod +x /usr/local/bin/hugo
1618

19+
# 3. 验证 hugo 可执行(现在应该能运行)
1720
RUN hugo version
1821

19-
# 创建空白站点
22+
# 4. 创建空白站点
2023
RUN hugo new site /build --force
2124
WORKDIR /build
2225

23-
# 克隆 FixIt 主题(使用 v0.4.5)
26+
# 5. 克隆 FixIt 主题
2427
RUN git clone --depth 1 --branch v0.4.5 https://github.com/hugo-fixit/FixIt.git themes/FixIt
2528

26-
# 生成配置文件
29+
# 6. 生成配置文件
2730
RUN cat > config.toml <<EOF
2831
baseURL = "https://example.org/"
2932
title = "My FixIt Site"
@@ -48,32 +51,28 @@ paginate = 10
4851
defaultTheme = "auto"
4952
EOF
5053

51-
# 创建首页
54+
# 7. 创建首页
5255
RUN cat > content/_index.md <<EOF
5356
---
5457
title: "Home"
5558
---
5659
Welcome to my FixIt site.
5760
EOF
5861

59-
# 创建示例文章
62+
# 8. 创建示例文章
6063
RUN mkdir -p content/posts && \
6164
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
6265

63-
# 构建静态文件
66+
# 9. 构建静态文件
6467
RUN hugo --minify --destination /public
6568

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

69-
# 阶段二:提供静态文件的 Nginx
72+
# 阶段二:运行 Nginx
7073
FROM nginx:stable-alpine
7174

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

74-
RUN echo '#!/bin/sh' > /docker-entrypoint.sh && \
75-
echo 'nginx -g "daemon off;"' >> /docker-entrypoint.sh && \
76-
chmod +x /docker-entrypoint.sh
77-
7877
EXPOSE 80
79-
ENTRYPOINT ["/docker-entrypoint.sh"]
78+
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)