Prerequisites

Note

A whole tutorial referenced here is available in the following Postman collection: https://documenter.getpostman.com/view/1515623/2sAXqqbhKp

Run the following docker compose (or configure it to your liking, i.e. change to Postgres if required):

services:
  openfhir:
    image: openfhir/openfhir:latest
    container_name: openfhir
    ports:
      - "8080:8080"
    volumes:
      - "/home/user/Documents/openFHIR/license.json:/app/openfhir-license.json"
      - "/home/user/Documents/openFHIR/openfhir-bootstrap/:/app/bootstrap/"
    environment:
        SPRING_DATA_MONGODB_URI: "mongodb://openfhir:openfhir@localhost:27017/openfhir"
        LICENSE: "/app/openfhir-license.json" # could also be left out, as this is the default
        BOOTSTRAP_DIR: "/app/bootstrap/" # could also be left out, as this is the default

  mongodb:
    image: mongo:latest
    container_name: mongodb
    ports:
      - "27017:27017"
    environment:
      MONGO_INITDB_ROOT_USERNAME: "admin"
      MONGO_INITDB_ROOT_PASSWORD: "admin"
      MONGO_INITDB_DATABASE: "openfhir"
    volumes:
      - ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro

File referenced under volumes in the mongodb service (init-mongo.js) could look as follows:

// Connect to the admin database to create a user for a specific database
db = db.getSiblingDB('openfhir');

// Create a new user with readWrite access to the 'openfhir' database
db.createUser({
    user: 'openfhir',
    pwd: 'openfhir',
    roles: [
        {
            role: 'readWrite',
            db: 'openfhir'
        }
    ]
});