volumes:
  db:
  scoro_logs:
  meilisearch:


services:
  back:
    #platform: linux/amd64
    build: ./back
    ports:
      - "3000:3000"
    depends_on:
      db:
        condition: service_healthy
      meilisearch:
        condition: service_healthy
      
    env_file:
      - .env
    volumes:
      - ./assets:/assets
      - ./data:/data

  scorometer:
    build: ./scorometer
    ports:
      - "6543:6543"
    volumes:
      - ./assets:/assets
      - scoro_logs:/logs
    env_file:
      - .env
  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: ./front
    environment:
      - API_URL=http://back:3000/
      - SCOROMETER_URL=http://scorometer:6543/
      - NGINX_PORT=80
    ports:
      - "80:80"
    depends_on:
      - "back"
    env_file:
      - .env

  meilisearch:
    image: getmeili/meilisearch:v1.5
    ports:
      - "7700:7700"
    volumes:
      - meilisearch:/meili_data
    env_file:
      - .env
    healthcheck:
      test:
          - CMD
          - wget
          - '--no-verbose'
          - '--spider'
          - 'http://localhost:7700/health'
      retries: 3
      timeout: 5s