Files
blog/write-server/docker-compose.yml
T
2026-06-22 15:18:55 +08:00

91 lines
2.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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:
# Hugo 博客目录(必须)- 映射宿主机博客根目录到容器内 /blog
- ..:/blog
# 本地回收站目录
- ./recycle:/app/recycle
# 日志目录
- ./logs:/app/logs
# 备份目录
- ./backups:/app/backups
# 环境变量文件
- ./.env:/app/.env:ro
# 用户配置(可写,entrypoint 需要哈希密码)
- ./users.json:/app/users.json
# SSH 密钥(用于 git push)
- /root/.ssh:/home/nextjs/.ssh
environment:
- NODE_ENV=production
- PORT=8016
- BLOG_ROOT=/blog
- TZ=Asia/Shanghai
- HUGO_PREVIEW=http://127.0.0.1:1313
networks:
- write-network
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:8016/api/stats"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
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"
- "1313:1313"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/conf.d:/etc/nginx/conf.d:ro
- ./nginx/ssl:/etc/nginx/ssl:ro
- ./.htpasswd:/etc/nginx/.htpasswd:ro
- ./nginx/login.html:/etc/nginx/login.html:ro
- ./nginx/sw.js:/etc/nginx/sw.js:ro
- ./logs/nginx:/var/log/nginx
depends_on:
write-server:
condition: service_started
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: