# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Docker Compose reference guide at
# https://docs.docker.com/go/compose-spec-reference/

# Here the instructions define your application as a service called "app".
# This service is built from the Dockerfile in the current directory.
# You can add other services your application may depend on here, such as a
# database or a cache. For examples, see the Awesome Compose repository:
# https://github.com/docker/awesome-compose
services:
  app:
    build:
      context: .
      target: final
    restart: unless-stopped
    ports:
      - 80:80
    depends_on:
      db:
        condition: service_healthy
      undetected-chromedriver:
        condition: service_healthy

  db:
    image: mysql:5.7
    restart: unless-stopped
    healthcheck:
      test: ["CMD", 'mysqladmin', 'ping', '-h', 'db', '-u', '${DB_USERNAME}', '-p${DB_PASSWORD}' ]
      interval: 2s
      timeout: 20s
      retries: 10
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_USER: ${DB_USERNAME}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - dbdata:/var/lib/mysql

  undetected-chromedriver:
    build:
      context: ./undetectedChromedriver
      dockerfile: seleniumChromedriverDockerfile
    restart: unless-stopped
    volumes:
      - /tmp:/tmp
    shm_size: 2gb
    ports:
      - "4444:4444"
      - "7900:7900"

volumes:
  dbdata:
