---

services:
  tasknote-web:
    container_name: tasknote-web
    image: node:22.14-bookworm-slim
    user: ${UID:-1000}:${GID:-1000}
    ports: 
      - "5000:5000"
    entrypoint: sh -c "npm i --no-update-notifier && export NGROK=1 && npm start"
    environment:
      VITE_BACKEND_SERVER: "/api"
      VITE_BUILD: nightly
      NGROK: 1
      BACKEND_HOST: tasknote-api
    volumes: 
      - "./client:/app"
    working_dir: /app
    healthcheck:
      test: timeout 10s bash -c 'true > /dev/tcp/127.0.0.1/5000'
      interval: 1m30s
      timeout: 15s
      retries: 3
      start_period: 10s
    networks:
      - tasknote

  tasknote-api:
    container_name: tasknote-api
    depends_on:
      tasknote-db:
        condition: service_started
    user: ${UID:-1000}:${GID:-1000}
    environment:
      POSTGRES_DB: tasknote
      POSTGRES_HOST: tasknote-db
      POSTGRES_USER: tasknoteuser
      POSTGRES_PASSWORD: default
      POSTGRES_PORT: 5432
      CORS_ALLOWED_ORIGINS: http://localhost:5000,http://tasknote-web:5000,https://flattop-depth-dropper.ngrok-free.dev
      SERVER_SERVLET_CONTEXT_PATH: /
      TARGET_ENV: development
      SECURITY_KEY: this-is-a-very-long-security-key-for-dev
      MAILGUN_APIKEY: invalid-api-key-only-placeholder
    ports:
      - "8585:8585"
      - "5005:5005"
    image: maven:3.9.12-eclipse-temurin-25
    entrypoint: './mvnw -ntp spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005" -Dmaven.plugin.validation=VERBOSE'
    working_dir: /app
    volumes:
      - "./server:/app"
    healthcheck:
      test: curl -f http://localhost:8585/health | grep '"status":"UP"'
      interval: 1m30s
      timeout: 15s
      retries: 3
      start_period: 10s
    networks:
      - tasknote

  schemaspy:
    container_name: schemaspy
    profiles: ["schemaspy"]
    image: schemaspy/schemaspy:7.0.2
    user: ${UID:-1000}:${GID:-1000}
    volumes:
      - "./schemaspy/output:/output"
      - "./schemaspy/postgres.properties:/schemaspy.properties"
    depends_on:
      tasknote-db:
        condition: service_healthy
      tasknote-api:
        condition: service_healthy

  tasknote-db:
    container_name: tasknote-db
    image: postgres:15.8-bookworm
    environment:
      POSTGRES_DB: tasknote
      POSTGRES_USER: tasknoteuser
      POSTGRES_PASSWORD: default
    ports:
      - "5432:5432"
    healthcheck:
      test: psql -q -U $${POSTGRES_USER} -d $${POSTGRES_DB} -c 'SELECT 1'
      interval: 1m30s
      timeout: 15s
      retries: 3
      start_period: 10s
    networks:
      - tasknote

networks:
  tasknote:
