services:
  node:
    image: node:16.13.1
    working_dir: /app/web
    volumes:
      - ./web:/app/web
    command: sh -c "npm install && npm run build"

  postgres:
    image: postgres:16.1
    ports:
      - "5432:5432"
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -d ${POSTGRES_DB} -U ${POSTGRES_USER}" ]
      interval: 5s
      timeout: 5s
      retries: 5
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - ./postgres:/var/lib/postgresql/data

  scala:
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_HOST: ${POSTGRES_HOST}
      METEO_USER: ${METEO_USER}
      METEO_PASSWORD: ${METEO_PASSWORD}
      METEO_URL: ${METEO_URL}
    build:
      context: .
      dockerfile: Dockerfile.local
    volumes:
      - ./:/app
    ports:
      - "9090:8080"
    depends_on:
      - postgres