默认 DEBIAN/ALPINE 源改为 mirrors.aliyun.com,compose 支持通过环境变量覆盖;构建时先装 ca-certificates,避免 slim 镜像换源后 HTTPS 校验失败。
94 lines
2.7 KiB
YAML
94 lines
2.7 KiB
YAML
x-json-log-rotation: &json-log-rotation
|
|
driver: json-file
|
|
options:
|
|
max-size: "20m"
|
|
max-file: "5"
|
|
|
|
services:
|
|
postgres:
|
|
image: docker.m.daocloud.io/library/postgres:16-bookworm
|
|
restart: unless-stopped
|
|
logging: *json-log-rotation
|
|
environment:
|
|
TZ: ${TZ:-Asia/Shanghai}
|
|
POSTGRES_DB: ${POSTGRES_DB:-order_site}
|
|
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
|
healthcheck:
|
|
test:
|
|
[
|
|
"CMD-SHELL",
|
|
"pg_isready -U ${POSTGRES_USER:-postgres} -d ${POSTGRES_DB:-order_site}",
|
|
]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
|
|
backend:
|
|
build:
|
|
context: .
|
|
dockerfile: deploy/docker/backend.Dockerfile
|
|
args:
|
|
# 默认阿里云公共源;阿里云 ECS 内网可设 DEBIAN_MIRROR=mirrors.cloud.aliyuncs.com
|
|
DEBIAN_MIRROR: ${DEBIAN_MIRROR:-mirrors.aliyun.com}
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-https://registry.npmmirror.com}
|
|
restart: unless-stopped
|
|
env_file:
|
|
- .env
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test:
|
|
["CMD-SHELL", "curl -fsS http://127.0.0.1:3000/health/ready || exit 1"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
start_period: 20s
|
|
environment:
|
|
TZ: ${TZ:-Asia/Shanghai}
|
|
PORT: ${BACKEND_PORT:-3000}
|
|
DATABASE_URL: ${DATABASE_URL:-postgres://postgres:postgres@postgres:5432/order_site}
|
|
DATABASE_SSL: ${DATABASE_SSL:-false}
|
|
DATABASE_MAX_CONNECTIONS: ${DATABASE_MAX_CONNECTIONS:-20}
|
|
DATA_ROOT: /app/data
|
|
LOG_RETENTION_DAYS: ${LOG_RETENTION_DAYS:-30}
|
|
CLAIM_BASE_URL: ${CLAIM_BASE_URL:-http://localhost/#/claim}
|
|
ADMIN_SESSION_SECRET: ${ADMIN_SESSION_SECRET}
|
|
ADMIN_DEFAULT_USERS_JSON: ${ADMIN_DEFAULT_USERS_JSON}
|
|
KUASHOU_INDUSTRY_RATE_LIMIT_MAX: ${KUASHOU_INDUSTRY_RATE_LIMIT_MAX:-120}
|
|
logging: *json-log-rotation
|
|
volumes:
|
|
- ./apps/backend/data:/app/data
|
|
|
|
web:
|
|
build:
|
|
context: .
|
|
dockerfile: deploy/docker/frontend.Dockerfile
|
|
args:
|
|
APP_DOMAIN: ${APP_DOMAIN:-localhost}
|
|
ALPINE_MIRROR: ${ALPINE_MIRROR:-mirrors.aliyun.com}
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-https://registry.npmmirror.com}
|
|
restart: unless-stopped
|
|
logging: *json-log-rotation
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
environment:
|
|
TZ: ${TZ:-Asia/Shanghai}
|
|
APP_DOMAIN: ${APP_DOMAIN:-localhost}
|
|
CADDY_SITE_ADDR: ${CADDY_SITE_ADDR:-http://localhost}
|
|
volumes:
|
|
- caddy_data:/data
|
|
- caddy_config:/config
|
|
|
|
volumes:
|
|
postgres_data:
|
|
caddy_data:
|
|
caddy_config:
|