Replace hardcoded port literals with env-driven variables so a single change in .env reconfigures the full stack consistently. Defaults are unchanged (DB 5432, app 8765), so existing setups need no .env changes. - DB_PORT (default 5432): drives the db host<->container port mapping, Postgres PGPORT (so it listens on the chosen port), and the app's DATABASE_PORT connection setting. Lets deployers avoid a host port conflict (e.g. another local Postgres) by setting DB_PORT once. - SERVER_PORT (default 8765): drives the app host<->container mapping, the SERVER_PORT the app listens on, and the healthcheck target URL. - Applied to both the base (docker-compose.yml) and the dev override (docker-compose.dev.yml, tests service) so dev and prod stay in sync.
84 lines
2.7 KiB
YAML
84 lines
2.7 KiB
YAML
services:
|
|
# PostgreSQL Database
|
|
db:
|
|
image: postgres:15-alpine
|
|
container_name: bookhoard_db
|
|
environment:
|
|
POSTGRES_DB: bookhoard
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: ${DBPASS}
|
|
# PGPORT makes Postgres listen on DB_PORT (kept in sync with the host mapping + app's DATABASE_PORT)
|
|
PGPORT: ${DB_PORT:-5432}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./database/schema:/docker-entrypoint-initdb.d
|
|
# Make other volumes as needed
|
|
- ./uploads:/app/uploads
|
|
ports:
|
|
- "${DB_PORT:-5432}:${DB_PORT:-5432}"
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
env_file:
|
|
- .env
|
|
|
|
# Bookhoard Application
|
|
# In production this image is pulled from the Gitea container registry.
|
|
# Override IMAGE_TAG in .env to pin or rollback a specific version (defaults to "latest").
|
|
app:
|
|
image: git.linuxhg.com/bookhoard/bookhoard:${IMAGE_TAG:-latest}
|
|
container_name: bookhoard
|
|
environment:
|
|
# Database Configuration
|
|
DATABASE_HOST: db
|
|
DATABASE_PORT: ${DB_PORT:-5432}
|
|
DATABASE_USER: postgres
|
|
DATABASE_PASSWORD: ${DBPASS}
|
|
DATABASE_NAME: bookhoard
|
|
|
|
# Application Configuration
|
|
JWT_SECRET: ${JWT_SECRET}
|
|
SERVER_PORT: ${SERVER_PORT:-8765}
|
|
# IMPORTANT: Device sync requires full URL with protocol
|
|
# Local: http://localhost:8765
|
|
# Local network: http://192.168.1.X:8765
|
|
# Domain: https://bookhoard.example.com
|
|
BASE_URL: ${BASE_URL:-http://localhost:8765}
|
|
# Mark session cookies Secure; set true behind a TLS-terminating reverse proxy (Caddy/nginx/traefik)
|
|
COOKIE_SECURE: ${COOKIE_SECURE:-false}
|
|
|
|
# Rate Limiting Configuration
|
|
TEST_MODE: ${TEST_MODE:-false}
|
|
RATE_LIMIT_ENABLED: ${RATE_LIMIT_ENABLED:-true}
|
|
REQUESTS_PER_MINUTE: ${REQUESTS_PER_MINUTE:-10}
|
|
|
|
# Conversion Service Configuration
|
|
BOOKHOARD_CONVERSION_CACHE_DIR: ${BOOKHOARD_CONVERSION_CACHE_DIR:-/app/cache/kepub}
|
|
BOOKHOARD_CONVERSION_TOOL: ${BOOKHOARD_CONVERSION_TOOL:-/usr/bin/kepubify}
|
|
BOOKHOARD_CONVERSION_CACHE_TTL: ${BOOKHOARD_CONVERSION_CACHE_TTL:-24h}
|
|
|
|
# System timezone (fallback for server-side time operations)
|
|
TZ: ${TZ:-UTC}
|
|
ports:
|
|
- "${SERVER_PORT:-8765}:${SERVER_PORT:-8765}"
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./uploads:/app/uploads
|
|
- bookhoard_conversion_cache:/app/cache/kepub
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl -f http://localhost:${SERVER_PORT:-8765}/health || exit 1"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
|
|
# Named Volumes
|
|
volumes:
|
|
postgres_data:
|
|
bookhoard_conversion_cache:
|