version: "3.9"

services:
  bot:
    build:
      context: docker/zhamao
      dockerfile: ./Dockerfile
    container_name: zhamao-bot
    depends_on:
      - database-postgres
      - database-redis
    networks:
      - bot-net
    ports:
      - "20001-20005:20001-20005/tcp"
    volumes:
      - ".:/bot"

  walle-q:
    build:
      context: docker/walle-q
      dockerfile: ./Dockerfile
    container_name: zhamao-bot-walle-q
    depends_on:
      - bot
    networks:
      - bot-net
    volumes:
      - "./docker/volumes/walle-q-data:/bot"

  database-postgres:
    container_name: zhamao-bot-db-postgres
    env_file:
      - docker/environment.env
    image: postgres:14.4-alpine
    networks:
      - bot-net
    ports:
      - "5432:5432/tcp"
    restart: always
    volumes:
      - "./docker/volumes/postgres-data:/var/lib/postgresql/data"
      - "./docker/volumes/postgres-init:/docker-entrypoint-initdb.d"

  database-redis:
    command:
      - redis-server
      - --requirepass
      - "$${REDIS_PASSWORD}"
    container_name: zhamao-bot-db-redis
    env_file:
      - docker/environment.env
    image: redis:7.0-alpine
    networks:
      - bot-net
    ports:
      - "6379:6379/tcp"
    restart: always
    volumes:
      - "./docker/volumes/redis-data:/data"

  db-admin-adminer:
    container_name: zhamao-bot-dbadmin-adminer
    depends_on:
      database-postgres:
        condition: service_started
      database-redis:
        condition: service_started
    env_file:
      - docker/environment.env
    image: adminer:latest
    networks:
      - bot-net
    ports:
      - "15432:8080/tcp"
    profiles:
      - with-adminer

  db-admin-redis-insight:
    container_name: zhamao-bot-dbadmin-redis-insight
    depends_on:
      database-postgres:
        condition: service_started
      database-redis:
        condition: service_started
    image: redislabs/redisinsight:latest
    networks:
      - bot-net
    ports:
      - "16379:8001/tcp"
    profiles:
      - with-adminer

networks:
  bot-net:
    name: bot-net
