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
  company:
    build: ./company-service
    container_name: company
    depends_on:
      - postgres
    environment:
      SERVER_PORT: 8080
      DB_URL: jdbc:postgresql://postgres:5432/company
      DB_USERNAME: postgres
      DB_PASSWORD: postgres
  vacancy:
    build: ./vacancy-service
    container_name: vacancy
    depends_on:
      - postgres
    environment:
      SERVER_PORT: 8080
      DB_URL: jdbc:postgresql://postgres:5432/vacancy
      DB_USERNAME: postgres
      DB_PASSWORD: postgres
      COMPANY_URL: http://nginx/
  nginx:
    image: nginx
    depends_on:
      - vacancy
      - company
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    ports:
      - 80:80