# Optional layer: compose.yaml + compose.full.yaml.
# Node example requires a real package.json/package-lock.json and dev/test scripts.
services:
  app:
    build:
      context: .
      dockerfile: Dockerfile.dev
      target: dev
      args:
        NODE_IMAGE: ${NODE_IMAGE:?Choose the application's supported Node image}
    init: true
    working_dir: /workspace
    command: ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
    environment:
      NODE_ENV: development
      DB_HOST: db
      DB_PORT: "5432"
      DB_NAME: ${POSTGRES_DB:-app}
      DB_USER: ${APP_DB_USER:?Provision the application's scoped database role}
      DB_PASSWORD: ${APP_DB_PASSWORD:?Set the private local application-role password}
      CACHE_HOST: cache
      CACHE_PORT: "6379"
    ports:
      - "127.0.0.1:${APP_HOST_PORT:-15173}:5173"
    volumes:
      - type: bind
        source: .
        target: /workspace
      - type: volume
        source: app_node_modules
        target: /workspace/node_modules
    depends_on:
      db:
        condition: service_healthy
      cache:
        condition: service_healthy
    stop_grace_period: 15s

volumes:
  app_node_modules:
