version: '3.8'
services:
  university_service:
    build:
      context: ./university_service
    depends_on:
      - university_db
    environment:
      - FLASK_APP=app.py
    expose:
      - 8081

  faculty_service:
    build:
      context: ./faculty_service
    depends_on:
      - faculty_db
    environment:
      - FLASK_APP=app.py
    expose:
      - 8082

  university_db:
    image: postgres
    environment:
      POSTGRES_USER: university_user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: universitydb
    ports:
      - "5433:5432"
    volumes:
      - ./university_service/init.sql:/docker-entrypoint-initdb.d/init.sql

  faculty_db:
    image: postgres
    environment:
      POSTGRES_USER: faculty_user
      POSTGRES_PASSWORD: password
      POSTGRES_DB: facultydb
    ports:
      - "5434:5432"
    volumes:
      - ./faculty_service/init.sql:/docker-entrypoint-initdb.d/init.sql

  nginx:
    image: nginx
    ports:
      - 8086:8086
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    depends_on:
      - university_service
      - faculty_service