services:
  iwanttoheal:
    command: sh -lc "npm ci && npm run db:init && npm run build && npm start"
    depends_on:
      iwanttoheal-db:
        condition: service_healthy
    environment:
      AUTH_ISSUER: https://auth.phenomrom.com
      COOKIE_SECURE: '1'
      CORS_ORIGINS: >-
        http://localhost,https://localhost,capacitor://localhost,https://iwanttoheal.phenomrom.com,https://auth.phenomrom.com
      DATABASE_URL: postgres://iwanttoheal:${POSTGRES_PASSWORD:-change-me-iwanttoheal2}@iwanttoheal-db:5432/iwanttoheal
      HOST: 0.0.0.0
      PORT: '4173'
      TRUST_PROXY: '1'
    image: node:24-bookworm-slim
    ports:
      - '4173:4173'
    restart: unless-stopped
    volumes:
      - /mnt/usbssds/apps/iwanttoheal2/app:/app
      - /mnt/usbssds/apps/iwanttoheal2/data:/app/data
    working_dir: /app

  iwanttoheal-db:
    environment:
      POSTGRES_DB: iwanttoheal
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-change-me-iwanttoheal2}
      POSTGRES_USER: iwanttoheal
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U iwanttoheal -d iwanttoheal"]
      interval: 10s
      timeout: 5s
      retries: 10
    image: postgres:17-bookworm
    restart: unless-stopped
    volumes:
      - /mnt/usbssds/apps/iwanttoheal2/db:/var/lib/postgresql/data
