后台
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: inquiry
|
||||
# utf8mb4 + UTC(容器内 MySQL 一律按 UTC 存,应用层负责显示侧时区)
|
||||
command: >
|
||||
--max_allowed_packet=128M
|
||||
--character-set-server=utf8mb4
|
||||
--default-time-zone=+00:00
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"]
|
||||
interval: 5s
|
||||
retries: 20
|
||||
backend:
|
||||
build: .
|
||||
environment:
|
||||
# timezone=Z 让 mysql2 driver 也按 UTC 解释时间,避免 JS Date 双重偏移
|
||||
DATABASE_URL: mysql://root:root@mysql:3306/inquiry?timezone=Z
|
||||
INGEST_TOKEN: dev-ingest-token-1234
|
||||
JWT_SECRET: dev-jwt-secret-1234
|
||||
ADMIN_USERNAME: admin
|
||||
ADMIN_PASSWORD: admin-password-1234
|
||||
NODE_ENV: production
|
||||
PORT: "8080"
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "8080:8080"
|
||||
# nginx: serves the Vue3 frontend (built from ../frontend) on :80 and
|
||||
# reverse-proxies /api/* -> http://backend:8080 (joins the default network so
|
||||
# it resolves the `backend` service by name). Task 8.
|
||||
# 启动: docker compose up -d nginx
|
||||
nginx:
|
||||
build:
|
||||
context: ../frontend
|
||||
dockerfile: Dockerfile
|
||||
depends_on:
|
||||
- backend
|
||||
ports:
|
||||
- "8088:80"
|
||||
# 一次性备份服务;默认不启动,手动触发:
|
||||
# docker compose --profile backup run --rm backup
|
||||
# 或宿主 crontab:0 3 * * * cd /path && docker compose --profile backup run --rm backup
|
||||
backup:
|
||||
image: mysql:8
|
||||
profiles: ["backup"]
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
MYSQL_PWD: root
|
||||
volumes:
|
||||
- ./backups:/backup
|
||||
- ./scripts/backup.sh:/backup.sh:ro
|
||||
entrypoint: ["/bin/sh", "/backup.sh"]
|
||||
volumes:
|
||||
mysql_data: {}
|
||||
Reference in New Issue
Block a user