Files
OJ2/docker/compose.dev.yml
yuetsh 901906328d chore: 本机开发依赖 compose(postgres 16 + redis)
PostgreSQL 固定 16-alpine 与生产 16.10 对齐,首次启动自动灌入
docs/specs/schema.sql(仅结构)。端口错开为 5433 / 6380。

实测:34 张表与 schema.sql 逐一对应,差集 0,两个服务健康。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 20:32:48 -06:00

45 lines
1.4 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.
# 本机开发用的依赖服务。判题沙箱单独放,因为它要挂载测试用例目录。
#
# 起: docker compose -f docker/compose.dev.yml up -d
# 停: docker compose -f docker/compose.dev.yml down
# 清空docker compose -f docker/compose.dev.yml down -v ← 会删掉库里的数据
#
# PostgreSQL 固定 16与生产版本16.10)一致 —— 别图新换 17/18
# 开发环境用了生产不支持的特性,要到切换那天才炸。
services:
postgres:
image: postgres:16-alpine
container_name: oj2-postgres
restart: unless-stopped
environment:
POSTGRES_DB: onlinejudge
POSTGRES_USER: onlinejudge
POSTGRES_PASSWORD: onlinejudge
ports:
- "5433:5432" # 5433 避开可能存在的本机 5432
volumes:
- oj2-pgdata:/var/lib/postgresql/data
# 首次启动时自动灌入生产库结构(仅结构,无数据)
- ../docs/specs/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U onlinejudge -d onlinejudge"]
interval: 5s
timeout: 3s
retries: 10
redis:
image: redis:7-alpine
container_name: oj2-redis
restart: unless-stopped
ports:
- "6380:6379" # 6380 避开可能存在的本机 6379
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
volumes:
oj2-pgdata: