2026-06-21 20:42:44 +08:00
|
|
|
|
# Write Server Docker Compose Configuration
|
|
|
|
|
|
# 用于生产环境部署
|
|
|
|
|
|
|
|
|
|
|
|
version: '3.8'
|
|
|
|
|
|
|
|
|
|
|
|
services:
|
|
|
|
|
|
write-server:
|
|
|
|
|
|
build:
|
|
|
|
|
|
context: .
|
|
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
|
|
container_name: write-server
|
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
|
ports:
|
|
|
|
|
|
- "8016:8016"
|
|
|
|
|
|
volumes:
|
2026-06-21 22:28:14 +08:00
|
|
|
|
# Hugo 博客目录(必须)- 映射宿主机博客根目录到容器内 /blog
|
|
|
|
|
|
- ..:/blog
|
2026-06-21 20:42:44 +08:00
|
|
|
|
# 本地回收站目录
|
|
|
|
|
|
- ./recycle:/app/recycle
|
|
|
|
|
|
# 日志目录
|
|
|
|
|
|
- ./logs:/app/logs
|
|
|
|
|
|
# 备份目录
|
|
|
|
|
|
- ./backups:/app/backups
|
|
|
|
|
|
# 环境变量文件
|
|
|
|
|
|
- ./.env:/app/.env:ro
|
2026-06-22 15:18:55 +08:00
|
|
|
|
# 用户配置(可写,entrypoint 需要哈希密码)
|
|
|
|
|
|
- ./users.json:/app/users.json
|
2026-06-22 00:52:51 +08:00
|
|
|
|
# SSH 密钥(用于 git push)
|
2026-06-22 12:14:53 +08:00
|
|
|
|
- /root/.ssh:/home/nextjs/.ssh
|
2026-06-21 20:42:44 +08:00
|
|
|
|
environment:
|
|
|
|
|
|
- NODE_ENV=production
|
|
|
|
|
|
- PORT=8016
|
|
|
|
|
|
- BLOG_ROOT=/blog
|
|
|
|
|
|
- TZ=Asia/Shanghai
|
2026-06-22 00:41:05 +08:00
|
|
|
|
- HUGO_PREVIEW=http://127.0.0.1:1313
|
2026-06-21 20:42:44 +08:00
|
|
|
|
networks:
|
|
|
|
|
|
- write-network
|
|
|
|
|
|
healthcheck:
|
2026-06-21 22:03:30 +08:00
|
|
|
|
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8016/api/stats"]
|
2026-06-21 20:42:44 +08:00
|
|
|
|
interval: 30s
|
|
|
|
|
|
timeout: 10s
|
|
|
|
|
|
retries: 3
|
2026-06-21 22:03:30 +08:00
|
|
|
|
start_period: 60s
|
2026-06-21 20:42:44 +08:00
|
|
|
|
logging:
|
|
|
|
|
|
driver: "json-file"
|
|
|
|
|
|
options:
|
|
|
|
|
|
max-size: "10m"
|
|
|
|
|
|
max-file: "3"
|
|
|
|
|
|
|
|
|
|
|
|
# 可选:Nginx 反向代理
|
|
|
|
|
|
nginx:
|
|
|
|
|
|
image: nginx:alpine
|
|
|
|
|
|
container_name: write-nginx
|
|
|
|
|
|
restart: unless-stopped
|
|
|
|
|
|
ports:
|
|
|
|
|
|
- "80:80"
|
|
|
|
|
|
- "443:443"
|
2026-06-22 13:30:55 +08:00
|
|
|
|
- "1313:1313"
|
2026-06-21 20:42:44 +08:00
|
|
|
|
volumes:
|
|
|
|
|
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
|
|
|
|
- ./nginx/conf.d:/etc/nginx/conf.d:ro
|
|
|
|
|
|
- ./nginx/ssl:/etc/nginx/ssl:ro
|
2026-06-21 22:22:38 +08:00
|
|
|
|
- ./.htpasswd:/etc/nginx/.htpasswd:ro
|
2026-06-21 23:28:31 +08:00
|
|
|
|
- ./nginx/login.html:/etc/nginx/login.html:ro
|
|
|
|
|
|
- ./nginx/sw.js:/etc/nginx/sw.js:ro
|
2026-06-21 20:42:44 +08:00
|
|
|
|
- ./logs/nginx:/var/log/nginx
|
|
|
|
|
|
depends_on:
|
|
|
|
|
|
write-server:
|
2026-06-21 22:03:30 +08:00
|
|
|
|
condition: service_started
|
2026-06-21 20:42:44 +08:00
|
|
|
|
networks:
|
|
|
|
|
|
- write-network
|
|
|
|
|
|
|
|
|
|
|
|
# 可选:Redis 缓存
|
|
|
|
|
|
# redis:
|
|
|
|
|
|
# image: redis:7-alpine
|
|
|
|
|
|
# container_name: write-redis
|
|
|
|
|
|
# restart: unless-stopped
|
|
|
|
|
|
# ports:
|
|
|
|
|
|
# - "6379:6379"
|
|
|
|
|
|
# volumes:
|
|
|
|
|
|
# - redis-data:/data
|
|
|
|
|
|
# networks:
|
|
|
|
|
|
# - write-network
|
|
|
|
|
|
|
|
|
|
|
|
networks:
|
|
|
|
|
|
write-network:
|
|
|
|
|
|
driver: bridge
|
|
|
|
|
|
|
|
|
|
|
|
# volumes:
|
|
|
|
|
|
# redis-data:
|