# Baskit Ops — production stack (Dokploy).
# App = the same production image (Dockerfile), Postgres in a named volume.
# Secrets/config are injected by Dokploy's Compose environment (${...}).
# Traefik routing is handled by Dokploy via the attached dokploy-network +
# the domain configured in the panel — no host ports are published.

services:
  db:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${DB_DATABASE}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - baskit_ops_pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE}"]
      interval: 5s
      timeout: 5s
      retries: 10

  app:
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    # Plain, shell-safe names (no dots): the entrypoint maps these to CI4's
    # dotted .env keys. Apache/mod_php does not reliably expose dotted env vars.
    environment:
      CI_ENVIRONMENT: production
      RUN_MIGRATIONS: "true"
      APP_BASEURL: ${APP_BASEURL}
      DB_HOST: db
      DB_NAME: ${DB_DATABASE}
      DB_USER: ${DB_USERNAME}
      DB_PASS: ${DB_PASSWORD}
      DB_DRIVER: Postgre
      DB_PORT: "5432"
      ENCRYPTION_KEY: ${ENCRYPTION_KEY}
      INGEST_SERVICE_KEY: ${INGEST_SERVICE_KEY}
      INGEST_ALLOWED_IPS: ${INGEST_ALLOWED_IPS:-}
      JWT_SECRET: ${JWT_SECRET}
      JWT_ACCESS_TTL: ${JWT_ACCESS_TTL:-900}
      JWT_REFRESH_TTL: ${JWT_REFRESH_TTL:-2592000}
      EMAIL_PROTOCOL: ${EMAIL_PROTOCOL:-smtp}
      SMTP_HOST: ${SMTP_HOST}
      SMTP_USER: ${SMTP_USER}
      SMTP_PASS: ${SMTP_PASS}
      SMTP_PORT: ${SMTP_PORT:-465}
      SMTP_TIMEOUT: ${SMTP_TIMEOUT:-15}
      SMTP_CRYPTO: ${SMTP_CRYPTO:-ssl}
      EMAIL_FROM: ${EMAIL_FROM}
      EMAIL_FROM_NAME: ${EMAIL_FROM_NAME:-Baskit Ops}
      ADMIN_EMAIL: ${ADMIN_EMAIL:-}
      ADMIN_NAME: ${ADMIN_NAME:-Owner}
      ADMIN_PASSWORD: ${ADMIN_PASSWORD:-}
      PIPELINE_ALERT_EMAIL: ${PIPELINE_ALERT_EMAIL:-}
      PIPELINE_ALERT_EMAIL_ENABLED: ${PIPELINE_ALERT_EMAIL_ENABLED:-true}
      PIPELINE_ALERT_WEBHOOK_URL: ${PIPELINE_ALERT_WEBHOOK_URL:-https://cursor.testworks.co.za/api/webhook.php}
      RUN_SEEDERS: ${RUN_SEEDERS:-false}
      ADS_SEED_SPECIALS: ${ADS_SEED_SPECIALS:-false}
      CATALOG_MAP_PRODUCTS: ${CATALOG_MAP_PRODUCTS:-false}
    expose:
      - "80"
    networks:
      - default
      - dokploy-network

networks:
  dokploy-network:
    external: true

volumes:
  baskit_ops_pgdata:
