services:
  app:
    image: node:22-alpine
    container_name: bizmatch-app-prod  # Neu: Unterscheide Namen
    working_dir: /app
    volumes:
      - ~/git/bizmatch-project-prod/bizmatch-server:/app  # Verwende Prod-Checkout
    ports:
      - "3001:3000"  # Neu: Host-Port 3001, Container-Port bleibt 3000
    env_file:
      - path: ./env.prod  # Neu: Separate Env-File für Prod
        required: true
    environment:
      - NODE_ENV=development  # Neu: Production-Modus (für Nest.js-Config)
      - DB_HOST=postgres-prod  # Neu: Passe an neuen Service-Namen
      - DB_PORT=5432
      - DB_NAME=${POSTGRES_DB}  # Neu: Separate DB-Name aus Env-File
      - DB_USER=${POSTGRES_USER}
      - DB_PASSWORD=${POSTGRES_PASSWORD}
    command: sh -c "npm install && npm run build && node dist/src/main.js"  # Entferne --omit=dev für Prod
    restart: unless-stopped
    depends_on:
      - postgres-prod
    networks:
      - bizmatch-prod  # Neu: Separates Network für Isolation

  postgres-prod:  # Neu: Umbenannt für Unterscheidung
    container_name: bizmatchdb-prod
    image: postgres:latest
    restart: always
    volumes:
      - ${PWD}/bizmatchdb-data-prod:/var/lib/postgresql/data  # Neu: Separates Daten-Volume
    env_file:
      - path: ./env.prod  # Neu: Separate Env-File für Prod
        required: true
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - "5433:5432"  # Neu: Host-Port 5433, Container-Port bleibt 5432
    networks:
      - bizmatch-prod

networks:
  bizmatch-prod:
    external: true  # Neu: Erstelle es mit `docker network create bizmatch-prod`