services:
  app:
    image: node:22-alpine
    container_name: bizmatch-app
    working_dir: /app
    volumes:
      - ./:/app
      - node_modules:/app/node_modules
    ports:
      - '3001:3001'
    env_file:
      - .env
    environment:
      - NODE_ENV=development
      - DATABASE_URL
    command: sh -c "if [ ! -f node_modules/.installed ]; then npm ci && touch node_modules/.installed; fi && npm run build && node dist/src/main.js"
    restart: unless-stopped
    depends_on:
      - postgres
    networks:
      - bizmatch

  postgres:
    container_name: bizmatchdb
    image: postgres:17-alpine
    restart: unless-stopped
    volumes:
      - bizmatch-db-data:/var/lib/postgresql/data
    env_file:
      - .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
  node_modules:
    driver: local

networks:
  bizmatch:
    external: true
