Carrot MapperDeploymentLocal/Virtual Machine

Deploy Carrot Mapper

This page will guide you through getting Carrot Mapper deployed in a Virtual Machine (VM) or locally on your machine, using the published container images.

🥕

We provide a container registry for ease of deployment.

This page is for running released versions of Carrot Mapper. To run Carrot from source for development, see the developer quickstart.

Prerequisites

Deployment Steps

Get the example Compose file

Download the sample Carrot Mapper Compose file by running the command:

wget https://raw.githubusercontent.com/Health-Informatics-UoN/carrot/refs/heads/main/samples/Carrot-Mapper/compose/mapper.compose.yml

Get the Keycloak realm configuration

Airflow uses Keycloak for authentication. Keycloak imports its realm (CARROT-MAPPER), the Airflow client and the default users from a JSON file on start-up.

In the same directory as mapper.compose.yml, run:

mkdir -p realm-config
wget -O realm-config/Carrot-Mapper.json https://raw.githubusercontent.com/Health-Informatics-UoN/carrot-mapper/main/realm-config/Carrot-Mapper.json
⚠️

Without this file, Keycloak starts with no CARROT-MAPPER realm, and Airflow (and therefore scan report processing and auto-mapping) will not work.

Environment configuration

All the settings you are likely to change are collected in a sample .env file. Download it next to mapper.compose.yml and copy it to .env:

wget https://raw.githubusercontent.com/Health-Informatics-UoN/carrot/refs/heads/main/samples/Carrot-Mapper/compose/.env.example
cp .env.example .env

Docker Compose reads .env automatically. Every variable has a default in the compose file except RELEASE_VERSION, which must be set. The main variables are:

VariableDefaultDescription
RELEASE_VERSION(required)The Carrot Mapper image version to deploy, 5.0.0 or later.
FRONTEND_URLhttp://localhost:3000URL users open the frontend on.
AIRFLOW_URLhttp://localhost:8080URL users open Airflow on.
KEYCLOAK_HOSTNAMEhttp://keycloak.localtest.me:8085URL of Keycloak, used by both the browser and Airflow. See the note below.
SYNTHETIC_VOCABStrueSet to false to load your own vocabularies from the vocabs folder.
POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DBpostgresDatabase credentials, shared by Carrot, Airflow, Keycloak and OMOP Lite.
SUPERUSER_DEFAULT_USERNAME, SUPERUSER_DEFAULT_PASSWORD, SUPERUSER_DEFAULT_EMAILadmin, admin, admin@carrot.comThe Carrot superuser created on first start.
SECRET_KEY, SIGNING_KEY, NEXTAUTH_SECRET-Secrets for the API and frontend.
S3_ACCESS_KEY, S3_SECRET_KEYs3adminRustFS storage credentials, shared by RustFS, the API and Airflow.
AIRFLOW_ADMIN_USERNAME, AIRFLOW_ADMIN_PASSWORDcarrot-admin, password123Keycloak user the API uses to trigger Airflow DAGs.
AIRFLOW_OPENID_CLIENT_SECRET-Secret of the CARROT-AIRFLOW Keycloak client. Must match realm-config/Carrot-Mapper.json.
KEYCLOAK_BOOTSTRAP_ADMIN_PASSWORDadminPassword of the Keycloak admin user.
KEYCLOAK_STARTUP_COMMANDstart-devUse start (which requires HTTPS) for production.

See the comments in .env.example for the full list. For what each variable does in the services, see the Configuration section.

keycloak.localtest.me always resolves to 127.0.0.1, so the default only works when you open Airflow in a browser on the same machine that runs Docker. If Carrot runs on a remote VM, set KEYCLOAK_HOSTNAME to a URL that both your browser and the VM can reach, and update the extra_hosts entry of the airflow-api service if needed.

⚠️

Changing AIRFLOW_ADMIN_USERNAME, AIRFLOW_ADMIN_PASSWORD or AIRFLOW_OPENID_CLIENT_SECRET in .env does not change Keycloak. Update the matching user or client in Keycloak (or in realm-config/Carrot-Mapper.json before the first start) as well.

⚠️

The defaults are meant for local or trial deployments only. Change all passwords and secrets in .env before exposing Carrot Mapper to other users. Database credentials are also used inside connection URIs, so URL-encode any special characters in POSTGRES_PASSWORD.

OMOP CDM configuration

Before getting Carrot Mapper running, you need to configure the OMOP CDM in its database.

By default, Carrot Mapper uses a synthetic OMOP CDM database, which is loaded into the database by the omop-lite service. If you want to use your own vocabularies in the OMOP CDM, you need to:

  • Create a folder named vocabs in the same directory as the mapper.compose.yml file.
  • Download the desired vocabularies from Athena and place them in the vocabs folder.
  • Set SYNTHETIC_VOCABS=false in your .env file.

Run Carrot Mapper

To run Carrot, you need to specify the release version of the Carrot Mapper application you want to deploy. You can find the list of available versions in the container registry.

This compose file is for Carrot Mapper 5.0.0 and later (Airflow 3 with Keycloak). Earlier versions use a different set of services and will not work with it.

Set RELEASE_VERSION in your .env file, then run this command in the directory containing mapper.compose.yml:

docker compose -f mapper.compose.yml up -d

The command will pull and start the following services:

ServiceDescriptionPort(s)
dbPostgres 18. Holds Carrot’s data, the omop schema, and the airflow and keycloak databases.5432
omop-liteCreates the omop schema and loads the vocabularies, then exits.-
rustfsS3-compatible storage for scan reports and exported files.9000, 9001
keycloakIdentity provider used for Airflow logins.8085
apiCarrot Mapper backend (Django).8000
frontendCarrot Mapper frontend (Next.js).3000
airflow-apiAirflow API server, which serves the Airflow UI and REST API.8080
schedulerAirflow scheduler and DAG processor, which run Carrot’s background jobs.-

The services start in order: db first, then omop-lite loads the vocabularies. Once omop-lite has finished, api starts, followed by frontend, airflow-api and scheduler. Loading real vocabularies can take a while, depending on their size. You can follow progress with:

docker compose -f mapper.compose.yml logs -f omop-lite

Log in

After the services are up and running, you can access Carrot Mapper with the credentials below (these are the defaults; use your own values if you changed them in .env):

ServiceURLUsernamePassword
Frontendhttp://localhost:3000adminadmin
Django Admin (API)http://localhost:8000/adminadminadmin
Airflowhttp://localhost:8080carrot-adminpassword123
Keycloakhttp://localhost:8085adminadmin
RustFS consolehttp://localhost:9001s3admins3admin

Airflow redirects you to Keycloak to log in. You can use Airflow to monitor the DAGs that process scan reports, run auto-mapping and export mapping rules. Airflow users are managed in Keycloak, in the CARROT-MAPPER realm.

First instances creation

Please follow the create first instances step of the developer quickstart to create a Data Partner, Dataset and Project in Carrot Mapper.

Check-in

Try using Carrot by following the user quickstart. If you can upload a new scan report, create mapping rules, and export the mapping rules JSON, you have successfully deployed Carrot Mapper.

🎉

Congratulations on your first Carrot Mapper deployment!

Stopping and upgrading

To stop Carrot Mapper, run:

docker compose -f mapper.compose.yml down

Your data is kept in the db_data_pg18 and s3_data volumes. Running down -v also deletes these volumes, which removes all of Carrot’s data and the loaded vocabularies.

To upgrade to a newer release, change RELEASE_VERSION in .env and run up -d again. Database migrations run automatically when the api service starts.

⚠️

If you deployed a Carrot Mapper version earlier than 5.0.0 with the old sample compose file, don’t reuse that setup. The new file uses Postgres 18 with a new volume (db_data_pg18), RustFS instead of MinIO, and Keycloak for Airflow. Data in the old db_data and minio_data volumes is not migrated automatically.

Best Practices

When deploying Carrot Mapper, follow these best practices to ensure stability and consistency:

  • Use Tagged Versions: We tag each container image with a version number upon release, for example 5.0.3. Always deploy a specific tagged version rather than latest to avoid unintended updates.
  • Check Available Versions: You can find a list of available version tags in the container registry.
  • Environment Configuration: Ensure your deployment environment (for example database connections, API endpoints, Keycloak hostname) is correctly configured via environment variables.
  • Change Default Secrets: Replace the default passwords and secrets in .env (database, Django, NextAuth, Airflow, Keycloak and RustFS) before sharing the deployment with others. Keep .env out of version control.
  • Monitor and Log: Use logging and monitoring tools to track service health and quickly diagnose issues.