services:
  app:
    image: node:22-alpine
    working_dir: /app
    volumes:
      - ~/git/bizmatch-project/bizmatch-server:/app
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - DB_HOST=postgres
      - DB_PORT=5432
      - DB_NAME=${POSTGRES_DB}
      - DB_USER=${POSTGRES_USER}
      - DB_PASSWORD=${POSTGRES_PASSWORD}
    command: sh -c "npm install && npm install @nestjs/cli && npm run build --omit=dev && node dist/src/main.js"
    restart: unless-stopped
    depends_on:
      - postgres
    networks:
      - bizmatch

  postgres:
    container_name: bizmatchdb
    image: postgres:latest
    restart: always
    volumes:
      - ${PWD}/bizmatchdb-data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - "5432:5432"
    networks:
      - bizmatch

networks:
  bizmatch:
    external: true