version: '3.7'
services:
  database-agent:
    image: mysql:8
    networks:
      backoffice:
    restart: always
    volumes:
      - /mnt/local/data/ecolyo_agent_mysql_data:/var/lib/mysql
      - ./dbinit:/dbinit
    environment:
      MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD}
      MYSQL_DATABASE: ${DATABASE_NAME}
    healthcheck:
      test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD
      interval: 5s
      timeout: 10s
      retries: 60

  backend:
    image: registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server:dev
    networks:
      backoffice:
      nginx-network:
    depends_on:
      database-agent:
        condition: service_healthy
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./configs:/app/configs
      - ./letsencrypt_cache:/app/letsencrypt_cache
      - ./data:/app/data
      - ./${IMAGE_FOLDER}:/app/${IMAGE_FOLDER}
    expose:
      - ${HTTPS_PORT}
    environment:
      - HOSTNAME=${HOSTNAME}
      - HTTPS_PORT=${HTTPS_PORT}
      - ADMIN_ROLE=${ADMIN_ROLE}
      - REDIRECT_URL=${REDIRECT_URL}
      - CLIENT_ID=${CLIENT_ID}
      - CLIENT_SECRET=${CLIENT_SECRET}
      - AUTH_URL=${AUTH_URL}
      - IMAGE_FOLDER=${IMAGE_FOLDER}
      - MOCK_OAUTH2=${MOCK_OAUTH2}
      - TOKEN_URL=${TOKEN_URL}
      - USERINFO_URL=${USERINFO_URL}
      - DEBUG_MODE=${DEBUG_MODE}
      - DATABASE_USER=${DATABASE_USER}
      - DATABASE_NAME=${DATABASE_NAME}
      - DATABASE_PASSWORD=${DATABASE_PASSWORD}
      - DATABASE_HOST=database-agent

networks:
  backoffice:
  nginx-network:
    external: true