# Local full stack: PostgreSQL + the app built from the root Dockerfile.
# The compiled backend serves both the API and the built SPA on one port (8080).
# NODE_ENV=development keeps it usable over plain HTTP (no forced secure cookies).
# Run from this folder: `docker compose up --build`, then open http://localhost:8080
services:
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: app_local
      POSTGRES_USER: app_local
      POSTGRES_PASSWORD: app_local
    volumes:
      - ./data/db:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U app_local -d app_local"]
      interval: 5s
      timeout: 5s
      retries: 10
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  app:
    build:
      context: ..
      dockerfile: Dockerfile
    environment:
      NODE_ENV: development
      PORT: "8080"
      SECRET_KEY: local_dev_secret_change_me
      DB_HOST: db
      DB_PORT: "5432"
      DB_NAME: app_local
      DB_USER: app_local
      DB_PASS: app_local
      SEED_ADMIN_EMAIL: admin@example.com
      SEED_ADMIN_PASSWORD: localAdmin123!
      SEED_USER_PASSWORD: localUser123!
    ports:
      - "8080:8080"
    depends_on:
      db:
        condition: service_healthy
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
