<mohammadrony>
services:
  metabase:
    image: metabase/metabase:latest
    container_name: metabase
    hostname: metabase
    restart: always
    ports:
      - 3000:3000
    environment:
      MB_DB_TYPE: ${MB_DB_TYPE}
      MB_DB_HOST: ${MB_DB_HOST}
      MB_DB_DBNAME: ${POSTGRES_DB}
      MB_DB_PORT: ${MB_DB_PORT}
      MB_DB_USER: ${POSTGRES_USER}
      MB_DB_PASS: ${POSTGRES_PASSWORD}
    networks:
      - metabasenet
    depends_on:
      - postgres
    healthcheck:
      test: curl --fail -I http://localhost:3000/api/health || exit 1
      interval: 15s
      timeout: 5s
      retries: 5

  postgres:
    image: postgres:latest
    container_name: postgres
    hostname: postgres
    restart: always
    volumes:
      - postgres:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    networks:
      - metabasenet

  nginx:
    image: nginx:alpine
    container_name: nginx
    hostname: fileserver
    restart: always
    ports:
      - 8080:80
    networks:
      - metabasenet
    volumes:
      - ./Bangladesh_GeoJSON:/srv
      - ./fileserver.conf:/etc/nginx/conf.d/default.conf

  mongo:
    image: mongo:latest
    container_name: mongo
    hostname: mongo
    restart: always
    volumes:
      - mongo/:/data/db/
      - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
      MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE}
      MONGODB_USER: ${MONGODB_USER}
      MONGODB_PASSWORD: ${MONGODB_PASSWORD}
    networks:
      - metabasenet

volumes:
  postgres:
  mongo:

networks:
  metabasenet:
    driver: bridge