version: '3.3'

services:
  service:
    image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:latest
    privileged: true
    ports:
      - 9200:9200
    environment:
      - SPRING_PROFILES_ACTIVE=prod
      - MYSQL_HOST=mysql
      - MYSQL_PORT=3306
      - MYSQL_DATABASE=orion_visor
      - MYSQL_USER=root
      - MYSQL_PASSWORD=Data@123456
      - REDIS_HOST=redis
      - REDIS_PASSWORD=Data@123456
      - SECRET_KEY=uQeacXV8b3isvKLK
      - DEMO_MODE=false
    volumes:
      - /data/orion-visor-space/docker-volumes/service/root-orion:/root/orion
    healthcheck:
      test: [ "CMD", "curl", "http://127.0.0.1:9200/orion-visor/api/server/bootstrap/health" ]
      interval: 15s
      timeout: 5s
      retries: 10
      start_period: 15s
    depends_on:
      mysql:
        condition: service_healthy
      redis:
        condition: service_healthy
    networks:
      - orion-visor-net

  mysql:
    image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:latest
    privileged: true
    ports:
      - 3307:3306
    environment:
      - MYSQL_DATABASE=orion_visor
      - MYSQL_USER=orion
      - MYSQL_PASSWORD=Data@123456
      - MYSQL_ROOT_PASSWORD=Data@123456
    volumes:
      - /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql:/var/lib/mysql
      - /data/orion-visor-space/docker-volumes/mysql/var-lib-mysql-files:/var/lib/mysql-files
    healthcheck:
      test: [ "CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/3306" ]
      interval: 15s
      timeout: 5s
      retries: 10
      start_period: 5s
    networks:
      - orion-visor-net

  redis:
    image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:latest
    privileged: true
    ports:
      - 6380:6379
    environment:
      - REDIS_PASSWORD=Data@123456
    volumes:
      - /data/orion-visor-space/docker-volumes/redis/data:/data
    command: sh -c "redis-server /usr/local/redis.conf --requirepass $${REDIS_PASSWORD}"
    healthcheck:
      test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
      interval: 15s
      timeout: 5s
      retries: 10
      start_period: 5s
    networks:
      - orion-visor-net

  testing:
    build:
      context: ./docker/e2e
    environment:
      SERVER: http://service:80
    depends_on:
      service:
        condition: service_healthy
    networks:
      - orion-visor-net

networks:
  orion-visor-net:
    driver: bridge