services:
  back:
    build: ./back
    ports:
      - "3000:3000"
    depends_on:
      db:
        condition: service_healthy
    env_file:
      - .env
    volumes:
      - ./musics:/musics
  scorometer:
    build: ./scorometer
    ports:
      - "6543:6543"
    volumes:
      - ./musics:/musics
  db:
    container_name: db
    image: postgres:alpine3.14
    environment:
    - POSTGRES_USER=${POSTGRES_USER}
    - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    - POSTGRES_DB=${POSTGRES_DB}
    ports:
      - "5432:5432"
    volumes:
      - db:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 5s
      timeout: 5s
      retries: 5

  front:
    build:
      context: ./front
      args:
        - API_URL=${API_URL}
        - SCORO_URL=${SCORO_URL}
    environment:
      - API_URL=http://back:3000/
      - SCOROMETER_URL=http://scorometer:6543/
      - NGINX_PORT=80
    ports:
      - "80:80"
    depends_on:
      - "back"
    env_file:
      - .env

volumes:
  db:
