version: '3'

services:

  mongo-service:
    build: .
    image: registry.forge.grandlyon.com/web-et-numerique/web-et-numerique-internet/data.grandlyon.com/web-portal/components/services/mongo-service:${TAG}
    ports:
      - ${MONGO_SERVICE_BIND_PORT}:3000
    environment:
      ACCESS_TOKEN_COOKIE_KEY: ${ACCESS_TOKEN_COOKIE_KEY}
      ADMIN_GROUP_NAME: ${ADMIN_GROUP_NAME}
      GROUP_HEADER: ${GROUP_HEADER}
      MONGO_CLIENT_READ_PREFERENCE: primary
      MONGO_DB_HOST_AND_PORT: ${MONGO_DB_HOST_AND_PORT}
      MONGO_NON_ROOT_PASSWORD: ${MONGO_NON_ROOT_PASSWORD}
      MONGO_NON_ROOT_USERNAME: ${MONGO_NON_ROOT_USERNAME}
      STORAGE_ACCESS_KEY: ${STORAGE_ACCESS_KEY}
      STORAGE_BUCKET_PREFIX: ${STORAGE_BUCKET_PREFIX}
      STORAGE_HOST: minio
      STORAGE_PORT: ${STORAGE_PORT} # only if your are using an ip and not a host name
      STORAGE_SECRET_KEY: ${STORAGE_SECRET_KEY}
      USE_SSL: ${USE_SSL} # if set to true, https is used instead of http
    depends_on:
      - "mongodb"
    restart: unless-stopped

  mongodb:
    image: bitnami/mongodb:4.2.3
    environment:
      MONGODB_ROOT_PASSWORD: ${MONGO_ROOT_PASSWORD}
      MONGODB_USERNAME: ${MONGO_NON_ROOT_USERNAME}
      MONGODB_PASSWORD: ${MONGO_NON_ROOT_PASSWORD}
      MONGODB_DATABASE: services
    restart: unless-stopped
    ports:
      - ${MONGO_PORT}:27017
    volumes:
      - mongodb:/bitnami

  mongo-express:
    image: mongo-express
    restart: unless-stopped
    depends_on:
      - mongodb
    ports:
      - ${ME_PORT}:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_ROOT_PASSWORD}
      ME_CONFIG_BASICAUTH_USERNAME: ${ME_CONFIG_BASICAUTH_USERNAME}
      ME_CONFIG_BASICAUTH_PASSWORD: ${ME_CONFIG_BASICAUTH_PASSWORD}
      ME_CONFIG_MONGODB_SERVER: mongodb

  minio:
    image: minio/minio
    volumes:
    - ${MINIO_DATA_VOLUME}:/data
    ports:
    - "${STORAGE_PORT}:9000"
    environment:
      MINIO_ACCESS_KEY: ${STORAGE_ACCESS_KEY}
      MINIO_SECRET_KEY: ${STORAGE_SECRET_KEY}
    volumes:
      - minio_storage:/data
    command: server /data
    restart: unless-stopped

volumes:
  mongodb:
  minio_storage:
