This project provides a Docker image designed to download and deploy the elastic search files generated in the FHIR Ontology Generator.
The primary purpose of this project is to automate the setup of the Elasticsearch Service used by the Dataportal Backend.
- Docker: Ensure Docker is installed and running on your system.
- Elasticsearch: A running instance of Elasticsearch to receive the index definitions and documents. The REST api of the elasticsearch instance must be reachable from within this container
To use this Docker image, follow these steps:
-
Clone the Project:
git clone https://github.com/medizininformatik-initiative/dataportal-es-init cd dataportal-es-init -
Build the Docker Image:
docker build -t dataportal-es-init:latest . -
Run the Docker Container:
Either use the docker-compose file and .env file provided or use the following command to start the container. Customize environment variables as needed.
docker run -e ES_HOST=<elasticsearch_host> \ -e ES_PORT=<elasticsearch_port> \ -e ONTO_GIT_TAG=<onto_git_tag> \ -e ONTO_REPO=<onto_repo> \ -e ONTO_RELATIVE_PATH=<onto_relative_path> \ -e DOWNLOAD_FILENAME=<download_filename> \ -e EXIT_ON_EXISTING_INDICES=false \ dataportal-es-init:latest
The Docker image supports several environment variables for configuration. The only variables that must not be omitted are MODE and ONTO_GIT_TAG if mode is download or LOCAL_PATH if mode is local, the others come with default values:
ES_HOST: The hostname or IP address of the Elasticsearch instance (default:127.0.0.1). Please note that the host must - for obvious reasons - be reachable from within this container. In case you are just using it for local purposes, set--network hostin your docker run command or compose file and use 127.0.0.1 . In that case, the elasticsearch port 9200 must be mapped to the host machine as well.ES_PORT: The port Elasticsearch is running on (default:9200).ONTO_GIT_TAG: The tag of the FHIR Ontology Generator files to use.ONTO_REPO: Base URL to the ontology generator repository (default:https://github.com/medizininformatik-initiative/fhir-ontology-generator/releases/download). Please do NOT enter a trailing slash since it will be inserted in the script.DOWNLOAD_FILENAME: The filename to get (default:elastic.zip)EXIT_ON_EXISTING_INDEX: If set to true, the container will shut down without doing anything if at least one of both indices (ontologyandcodeable_concept) exists (default: false)
A minimal example to run would be the following. Please see the description of the ES_HOST variable in the section above regarding the --network host setting. Feel free to remove this if your elasticsearch instance is otherwise reachable from within this container.
This is the default setting. Provide the git tag of the ontology you want to download (or override the source url as well)
docker run --network host \
-e ONTO_GIT_TAG=v3.0.1 \
ghcr.io/medizininformatik-initiative/dataportal-es-init:latestwhich would be equivalent to
docker run --network host \
-e ES_HOST=http://127.0.0.1 \
-e ES_PORT=9200 \
-e ONTO_GIT_TAG=v3.0.1 \
-e ONTO_REPO=https://github.com/medizininformatik-initiative/fhir-ontology-generator/releases/download \
-e DOWNLOAD_FILENAME=elastic.zip \
-e EXIT_ON_EXISTING_INDICES=false \
dataportal-es-init:latestIn case you want to use a local file on your machine instead of downloading from GitHub (or elsewhere), you must mount a valid zip file to /tmp/mounted_onto.zip in the container
docker run --network host \
--mount type=bind,src=/home/foo/my-ontology.zip,dst=/tmp/mounted_onto.zip,ro \
ghcr.io/medizininformatik-initiative/dataportal-es-init:latestor add an equivalent section to your docker-compose.yml in case you use docker compose.
e.g.
volumes:
- type: bind
source: /home/foo/my-ontology.zip
target: /tmp/mounted_onto.zip
read_only: true