version: '3.1'

services:
  middleware-legacy-auth:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/middlewares/legacy-auth:${TAG}
    ports:
      - ${MIDDLEWARE_LEGACY_SERVICE_BIND_PORT}:3000
    environment:
      - LEGACY_AUTH_SERVICE_URL=${LEGACY_AUTH_SERVICE_URL}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - ADMIN_USERNAME=${ADMIN_USERNAME}
      - SERVICE_EMAIL_URL=${SERVICE_EMAIL_URL}
      - USER_SUPPORT_MAILBOX=${USER_SUPPORT_MAILBOX}
      - FRONT_END_URL=${FRONT_END_URL}
      - VALIDATE_ACCOUNT_URI=${VALIDATE_ACCOUNT_URI}
      - PASSWORD_RESET_URI=${PASSWORD_RESET_URI}
      - API_KEY=${API_KEY}
      - ACCESS_TOKEN_COOKIE_KEY=${ACCESS_TOKEN_COOKIE_KEY}
      - IMAGE_HOST=${IMAGE_HOST}
      - REDIS_SENTINEL_HOST=${REDIS_SENTINEL_HOST}
      - REDIS_SENTINEL_PORT=${REDIS_SENTINEL_PORT}
      - REDIS_GROUP_NAME=${REDIS_GROUP_NAME}
    restart: unless-stopped
    depends_on:
      - redis-sentinel

  redis-master:
    image: 'bitnami/redis:5.0.5'
    environment:
      - ALLOW_EMPTY_PASSWORD=${ALLOW_EMPTY_PASSWORD}
    ports:
      - '${REDIS_MASTER_PORT}:6379'
    volumes:
      - redis-master:/bitnami/redis/data
    restart: unless-stopped

  redis-sentinel:
    image: 'bitnami/redis-sentinel:5.0.5'
    environment:
      - REDIS_MASTER_HOST=${REDIS_MASTER_HOST}
      - REDIS_MASTER_SET=${REDIS_GROUP_NAME}
    ports:
      - '${REDIS_SENTINEL_EXPOSED_PORT}:26379'
    restart: unless-stopped

  redis-slave:
    image: 'bitnami/redis:5.0.5'
    environment:
      - ALLOW_EMPTY_PASSWORD=${ALLOW_EMPTY_PASSWORD}
    ports:
      - '${REDIS_SLAVE_PORT}:6379'
    command: redis-server --bind 0.0.0.0 --slaveof redis-master 6379 --dir /bitnami/redis/data
    volumes:
      - redis-slave-1:/bitnami/redis/data
    restart: unless-stopped

volumes:
  redis-master:
  redis-slave-1:


