version: '3.7'
services:
  nginx:
    image: registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-client:dev
    restart: unless-stopped
    ports:
      - 8088:8080
    depends_on:
      - backend
    networks:
      backoffice:
    volumes:
      - ./site.conf:/etc/nginx/conf.d/default.conf
      - ./image-lib:/usr/share/nginx/html/lib
      - ./dacc-preview:/usr/share/nginx/html/static-site

  database-agent:
    image: mysql:5
    ports:
      - 3306:3306
    networks:
      backoffice:
    restart: unless-stopped
    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
    volumes:
      - ./dbinit:/dbinit

  backend:
    image: registry.forge.grandlyon.com/web-et-numerique/factory/llle_project/backoffice-server:dev
    networks:
      backoffice:
    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}
    ports:
      - ${HTTPS_PORT}:${HTTPS_PORT}
      - 8190:8090
    environment:
      - HOSTNAME=${HOSTNAME}
      - HTTPS_PORT=${HTTPS_PORT}
      - ANIMATOR_ROLE=${ANIMATOR_ROLE}
      - 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:
