networks:
  loki:

volumes:
  scoro_logs:
  meilisearch:


services:
  back:
    #platform: linux/amd64
    build:
      context: ./back
      dockerfile: Dockerfile.dev
    privileged: true
    ports:
      - "3000:3000"
    volumes:
      - ./back:/app
      - ./assets:/assets
      - ./data:/data
    depends_on:
      db:
        condition: service_healthy
      
      meilisearch:
        condition: service_healthy
    env_file:
      - .env

  scorometer:
    build:
      context: ./scorometer
      dockerfile: Dockerfile.dev
    ports:
      - "6543:6543"
    volumes:
      - ./scorometer:/app
      - ./assets:/assets
      - scoro_logs:/logs
    networks:
      - loki
    env_file:
      - .env

  db:
    container_name: db
    image: postgres:alpine3.14
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 5s
      timeout: 5s
      retries: 5
    ports:
      - "5432:5432"

  front:
    build:
      context: ./front
      dockerfile: Dockerfile.dev
    environment:
      - SCOROMETER_URL=http://scorometer:6543/
      - NGINX_PORT=4567
    ports:
      - "19006:19006"
      - "8081:8081"
    volumes:
      - ./front:/app
    depends_on:
      - "back"
    env_file:
      - .env

  nginx:
    image: nginx
    environment:
      - API_URL=${API_URL:-http://back:3000}
      - SCOROMETER_URL=${SCOROMETER_URL:-http://scorometer:6543}
      - FRONT_URL=${FRONT_URL:-http://front:19006}
      - PORT=4567
    depends_on:
      - back
      - front
      - scorometer
    volumes:
      - "./front/assets:/assets:ro"
      - "./front/nginx.conf.template.dev:/etc/nginx/templates/default.conf.template:ro"
    ports:
      - "4567:4567"

  meilisearch:
    image: getmeili/meilisearch:v1.4
    volumes:
      - meilisearch:/meili_data
    env_file:
      - .env
    
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:7700/health"]
      interval: 10s
      timeout: 10s
      retries: 5

