services:
# MongoDB
#
# https://www.mongodb.com/
  mongodb:
    image: mongodb/mongodb-community-server:8.0-ubi8
    volumes:
      - mongodb_config:/data/configdb
      - mongodb_data:/data/db
      - ./mongodb-entrypoint-initdb.d:/docker-entrypoint-initdb.d:Z
      - ./initdb.d:/initdb.d:z
    #ports:
    #  - "27017:27017"
    #networks:
    #  - caddy_net
    environment:
      MONGODB_INITDB_ROOT_USERNAME: ${MONGODB_USER}
      MONGODB_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}

  #mongodb-exporter:
  #  image: percona/mongodb_exporter:0.47
  #  ports:
  #    - 9216:9216
  #  environment:
  #    MONGODB_URI: mongodb://mongodb:${MONGODB_PORT:-27017}
  #  labels:
  #    prometheus-job: mongodb

  mongo-express:
    image: mongo-express
    restart: "no"
    depends_on:
      - mongodb
    environment:
      ME_CONFIG_MONGODB_URL: mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@mongodb:27017/
      ME_CONFIG_BASICAUTH_ENABLED: true
      ME_CONFIG_BASICAUTH_USERNAME: ${MONGOEXPRESS_USER}
      ME_CONFIG_BASICAUTH_PASSWORD: ${MONGOEXPRESS_PASSWORD}
    ports:
      - 8081:8081
    #networks:
    #  - caddy_net
    labels:
      caddy: mongo-express.localhost
      caddy.reverse_proxy: "{{upstreams 8081}}"
      caddy.tls: internal

volumes:
  mongodb_config:
  mongodb_data:
