Files
perler-lab/perler-lab-server/docker-compose.yml
T

65 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.
# =============================================================================
# PERLER LAB — 全栈 Docker Compose
# 启动命令:
# docker compose up -d --build
# 访问 http://localhost:8080 查看前端
# 后端 API 反向代理于 http://localhost:8080/api/
# =============================================================================
services:
# ── 后端 API 服务 ──
server:
build:
context: .
dockerfile: Dockerfile
container_name: perler-lab-server
restart: unless-stopped
environment:
# 端口(代码中默认 8788)
PORT: "8788"
# 色号表 API 数据目录(/api/color-chart/:brand 读取品牌色板 JSON)。
# 镜像内路径固定为 /app/palettes(见 Dockerfile `COPY palettes ./palettes`),
# 如需改为卷挂载,可在此改为宿主机映射路径。
PALETTES_DIR: "/app/palettes"
# 可选:NODE_ENV 已在 Dockerfile 中设为 production
# 可选:数据库路径可通过 DB_PATH 环境变量覆盖(默认 /app/data/perler-lab.db)
# DB_PATH: "/app/data/perler-lab.db"
volumes:
# SQLite 数据持久化——WAL 模式会生成 -wal 和 -shm 文件,均在 /app/data 下
- db-data:/app/data
healthcheck:
test: ["CMD", "node", "-e", "fetch('http://localhost:8788/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]
interval: 30s
timeout: 5s
retries: 3
start_period: 15s
networks:
- perler-net
# ── 前端 Nginx 服务 ──
frontend:
build:
context: ../perler-lab
dockerfile: Dockerfile
container_name: perler-lab-frontend
restart: unless-stopped
ports:
# 对外暴露 8080 端口,映射到容器内 nginx 80 端口
- "8080:80"
depends_on:
server:
condition: service_healthy
networks:
- perler-net
# ── 持久化卷 ──
volumes:
db-data:
# 命名卷,数据存储在 Docker 管理的卷目录中
# 查看路径:docker volume inspect perler-lab-server_db-data
# 备份方法:docker run --rm -v perler-lab-server_db-data:/data -v $(pwd):/backup alpine tar czf /backup/perler-db-backup.tar.gz -C /data .
# ── 网络 ──
networks:
perler-net:
driver: bridge