Soft-Blog
发布于 2026-11-15

Linux 下 Docker 一键部署与 Cloudflare Pages 免费托管指南

在空白 Linux 服务器上无需安装 Node.js,一条 Docker 命令即可完成打包上线,也支持免费托管到 Cloudflare Pages。

本博客基于 Astro 构建,最终输出纯粹的静态 HTML/CSS/JS(在 dist/ 目录),非常适合在 Linux 服务器上用 Docker 一键部署。

方式一:Linux + Docker 一键部署(推荐)

宿主机无需安装 Node.js 或 npm。如果服务器还没装 Docker,先执行安装命令:

# 安装 Docker 与 Docker Compose(国内服务器可加 --mirror Aliyun)
curl -fsSL https://get.docker.com | sh
systemctl enable --now docker

装好后,拉取仓库并一键启动:

git clone https://github.com/se-tang/astro-soft-blog.git
cd astro-soft-blog
docker compose up -d --build

容器内部会自动完成打包并启动轻量 Nginx,访问 http://你的服务器IP:8080 即可查看。

方式二:Linux 本地预览(需 Node.js 20+)

chmod +x start-linux.sh
./start-linux.sh

方式三:Cloudflare Pages 免费托管

将仓库关联到 Cloudflare Pages(构建命令 npm run build,输出目录 dist),即可免费获得全球 CDN 加速与 HTTPS 域名。

返回文章列表