This commit is contained in:
ljp 2025-06-23 11:38:18 +08:00
commit c5359742ae
Signed by: ljp
GPG Key ID: 72439F1F5C7BC795
4 changed files with 99 additions and 0 deletions

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
# Ghost 博客配置
GHOST_URL=https://kqjkcjh.com
NODE_ENV=production

3
Caddyfile Normal file
View File

@ -0,0 +1,3 @@
kqjkcjh.com {
reverse_proxy 127.0.0.1:2368
}

35
README.md Normal file
View File

@ -0,0 +1,35 @@
# Ghost 博客 Docker Compose 配置
使用 Ghost 5 + Caddy 反向代理的简化博客部署方案。
## 🚀 架构说明
- **Ghost 5**:博客主程序,使用内置 SQLite 数据库
- **Caddy**:现代化 Web 服务器和反向代理,支持自动 HTTPS
- **Host 网络模式**Caddy 使用 host 网络,直接暴露端口到主机
## 快速开始
### 1. 启动服务
```bash
docker-compose up -d
```
### 环境变量
| 变量名 | 默认值 | 描述 |
| ------------ | ---------------- | -------------------- |
| `GHOST_URL` | http://localhost | Ghost 博客的访问地址 |
| `NODE_ENV` | production | Ghost 运行环境 |
### 域名配置
如果您有自己的域名,可以:
1. 修改 `.env` 文件:
```env
GHOST_URL=https://example.com
NODE_ENV=production
```

58
docker-compose.yml Normal file
View File

@ -0,0 +1,58 @@
services:
# Ghost 博客
ghost:
image: ghost:5
container_name: ghost_blog
restart: unless-stopped
environment:
database__client: mysql
database__connection__host: mysql
database__connection__user: ${DB_USER:-ghost}
database__connection__password: ${DB_PASSWORD:-password}
database__connection__database: ${DB_NAME:-ghost}
# 基本配置
url: ${GHOST_URL:-http://localhost:2368}
NODE_ENV: ${NODE_ENV:-production}
volumes:
- ./data:/var/lib/ghost/content
ports:
- "127.0.0.1:${GHOST_PORT:-2368}:2368"
networks:
- ghost-network
depends_on:
- mysql
# MySQL 数据库
mysql:
image: mysql:8
container_name: ghost_mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
MYSQL_DATABASE: ${DB_NAME:-ghost}
MYSQL_USER: ${DB_USER:-ghost}
MYSQL_PASSWORD: ${DB_PASSWORD:-password}
volumes:
- ./mysql_data:/var/lib/mysql
networks:
- ghost-network
# Caddy 反向代理
caddy:
image: caddy:latest
container_name: caddy_proxy
restart: unless-stopped
network_mode: host
ports:
- "0.0.0.0:80:80"
- "0.0.0.0:443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
environment:
- GHOST_HOST=${GHOST_HOST:-localhost}
- GHOST_PORT=${GHOST_PORT:-2368}
# 网络定义
networks:
ghost-network:
driver: bridge