version: '3'
services:
  mongodb-test:
    image: mongo:4.2.15
    container_name: mongo-pwndoc-test
    command: --wiredTigerCacheSizeGB 1 # 50% of (max RAM - 1GB) - minimum 0.25 (Modify it depending on defined RAM limits)
    deploy:
      resources:
        limits:
          memory: 3G # Maximum memory to allocate (Modify it depending on host ressources - leave at least 1GB free for host)
        reservations:
          memory: 1G # Minimum memory required
    volumes:
      - ./mongo-data-test:/data/db
    restart: always
    environment:
      - MONGO_DB:pwndoc

  backend-test:
    image: yeln4ts/pwndoc:backend-test
    build: 
      context: .
      dockerfile:  Dockerfile.test
    container_name: pwndoc-backend-test
    environment:
      - DB_SERVER=mongo-pwndoc-test
      - DB_NAME=pwndoc
    volumes:
      - ./tests:/app/tests
      - ./src:/app/src
      - ./jest.config.js:/app/jest.config.js
    depends_on:
      - mongodb-test

volumes:
  mongo-data-test:
