version: '3.9'

services:
  nodebb:
    build: 
      context: .
      dockerfile: Dockerfile
      args:
        # Update 'VARIANT' to pick an LTS version of Node.js: 16, 14, 12.
        # Append -bullseye or -buster to pin to an OS version.
        # Use -bullseye variants on local arm64/Apple Silicon.
        VARIANT: 20-bookworm
    volumes:
      - ..:/workspace:cached
    # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
    network_mode: service:mongodb
    # Uncomment the next line to use a non-root user for all processes.
    # user: node

    # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. 
    # (Adding the "ports" property to this file will not forward from a Codespace.)

  mongodb:
    image: mongo:latest
    restart: unless-stopped
    volumes:
      - mongodb-data:/data/db
      # script that creates the nodebb user in nodebb database
      - ./nodebb-db-init.js:/docker-entrypoint-initdb.d/nodebb-db-init.js
    # Uncomment to change startup options
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: root
      MONGO_INITDB_DATABASE: nodebb

    # Add "forwardPorts": ["27017"] to **devcontainer.json** to forward MongoDB locally.
    # (Adding the "ports" property to this file will not forward from a Codespace.)
  meilisearch:
    image: getmeili/meilisearch:latest
    volumes:
      - meili-data:/meili_data
    network_mode: service:mongodb
volumes:
  mongodb-data:
  meili-data: