35 lines
1.2 KiB
YAML
35 lines
1.2 KiB
YAML
services:
|
|
web:
|
|
build: { context: ., dockerfile: deploy/Dockerfile.web }
|
|
ports: ["8080:80"]
|
|
depends_on: [api]
|
|
api:
|
|
build: { context: ., dockerfile: deploy/Dockerfile.api }
|
|
environment:
|
|
DATABASE_URL: postgres://lib:lib@postgres:5432/lib?sslmode=disable
|
|
REDIS_URL: redis://redis:6379
|
|
JWT_SECRET: ${JWT_SECRET}
|
|
ADMIN_USER: ${ADMIN_USER}
|
|
ADMIN_PASSWORD: ${ADMIN_PASSWORD}
|
|
BOOKS_DIR: /data/books
|
|
CACHE_DIR: /data/cache
|
|
SCAN_INTERVAL_SEC: ${SCAN_INTERVAL_SEC:-60}
|
|
volumes:
|
|
- ./library:/data/books
|
|
- cache:/data/cache
|
|
depends_on:
|
|
postgres: { condition: service_healthy }
|
|
redis: { condition: service_started }
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment: { POSTGRES_USER: lib, POSTGRES_PASSWORD: lib, POSTGRES_DB: lib }
|
|
volumes: [pgdata:/var/lib/postgresql/data]
|
|
healthcheck: { test: ["CMD-SHELL", "pg_isready -U lib"], interval: 2s, timeout: 2s, retries: 30 }
|
|
redis:
|
|
image: redis:7-alpine
|
|
command: ["redis-server", "--maxmemory", "128mb", "--maxmemory-policy", "allkeys-lru"]
|
|
# 故意无 volume:redis 里全是可再生数据(spec §6.2)
|
|
volumes:
|
|
pgdata:
|
|
cache:
|