services:
  server:
    image: todo-backend-dev
    build:
      context: .
      dockerfile: dev.Dockerfile
    volumes:
      - ./:/usr/src/app
    ports: 
      - 3000:3000
    environment:
      REDIS_URL: "redis://redis:6379"
      MONGO_URL: "mongodb://the_username:the_password@mongo:27017/the_database"

  mongo:
    image: mongo
    ports:
     - 3456:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example
      MONGO_INITDB_DATABASE: the_database
    volumes:
      - ./mongo/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js
      - mongo_data:/data/db

  redis:
    image: redis
    ports:
      - 3457:6379
    # Everything else
    command: ['redis-server', '--appendonly', 'yes'] # Overwrite the CMD
    volumes: # Declare the volume
      - ./redis_data:/data

volumes:
  mongo_data:

