services:
  # --- FRONTEND ---
  bizmatch-ssr:
    build:
      context: .                   # Pfad zum Angular Ordner
      dockerfile: bizmatch/Dockerfile
    image: bizmatch-ssr
    container_name: bizmatch-ssr
    extra_hosts:
      - "localhost:host-gateway"    
    restart: unless-stopped
    ports:
      - '4200:4000'                # Extern 4200 -> Intern 4000 (SSR)
    environment:
      NODE_ENV: production
    volumes:
      - ./bizmatch-server/pictures:/app/pictures

  # --- BACKEND ---
  app:
    build:
      context: ./bizmatch-server   # Pfad zum NestJS Ordner
      dockerfile: Dockerfile
    image: bizmatch-server:latest
    container_name: bizmatch-app
    restart: unless-stopped
    ports:
      - '3001:3001'
    env_file:
      - ./bizmatch-server/.env     # Pfad zur .env Datei
    depends_on:
      - postgres
    networks:
      - bizmatch
    # WICHTIG: Kein Volume Mapping für node_modules im Prod-Modus!
    # Das Image bringt alles fertig mit.

  # --- DATABASE ---
  postgres:
    container_name: bizmatchdb
    image: postgres:17-alpine
    restart: unless-stopped
    volumes:
      - bizmatch-db-data:/var/lib/postgresql/data
    env_file:
      - ./bizmatch-server/.env
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - '5434:5432'
    networks:
      - bizmatch

volumes:
  bizmatch-db-data:
    driver: local

networks:
  bizmatch:
    external: false  # Oder true, falls du es manuell erstellt hast