services:
  postgres:
    image: postgres:latest
    container_name: postgres
    environment:
      POSTGRES_USERNAME: postgres
      POSTGRES_PASSWORD: postgres
      PGDATA: "/var/lib/postgresql/data/pgdata"
    ports:
      - "5432:5432"
    volumes:
      - ./postgres_data:/var/lib/postgresql/data/
      - ./init-database.sh:/docker-entrypoint-initdb.d/init-database.sh
  room:
    build: ./room-service
    container_name: room
    depends_on:
      - postgres
    environment:
      SERVER_PORT: 8080
      DB_URL: jdbc:postgresql://postgres:5432/room
      DB_USERNAME: postgres
      DB_PASSWORD: postgres
  computer:
    build: ./computer-service
    container_name: computer
    depends_on:
      - postgres
    environment:
      SERVER_PORT: 8080
      DB_URL: jdbc:postgresql://postgres:5432/computer
      DB_USERNAME: postgres
      DB_PASSWORD: postgres
      ROOM_URL: http://nginx/
  nginx:
    image: nginx
    depends_on:
      - computer
      - room
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    ports:
      - 80:80