Skip to content

Commit

Permalink
Added extra environment variables to make this image more Bridgehead-…
Browse files Browse the repository at this point in the history
…compatible.

Also updated used package versions where possible.
  • Loading branch information
DavidCroftDKFZ committed Jun 27, 2024
1 parent c673526 commit 3018263
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ RUN apt-get -y update && apt-get -y install curl
WORKDIR /app

# Get bbmri-fhir-gen, for generating test data
RUN curl -LO https://github.com/samply/bbmri-fhir-gen/releases/download/v0.3.0/bbmri-fhir-gen-0.3.0-linux-amd64.tar.gz
RUN tar xzf bbmri-fhir-gen-0.3.0-linux-amd64.tar.gz
RUN curl -LO https://github.com/samply/bbmri-fhir-gen/releases/download/v0.4.0/bbmri-fhir-gen-0.4.0-linux-amd64.tar.gz
RUN tar xzf bbmri-fhir-gen-*-linux-amd64.tar.gz
RUN mv ./bbmri-fhir-gen /usr/local/bin/bbmri-fhir-gen
RUN bbmri-fhir-gen --version

# Get blazectl, for uploading data to a FHIR store
RUN curl -LO https://github.com/samply/blazectl/releases/download/v0.3.0/blazectl-0.3.0-linux-amd64.tar.gz
RUN tar xzf blazectl-0.3.0-linux-amd64.tar.gz
RUN curl -LO https://github.com/samply/blazectl/releases/download/v0.15.1/blazectl-0.15.1-linux-amd64.tar.gz
RUN tar xzf blazectl-*-linux-amd64.tar.gz
RUN mv ./blazectl /usr/local/bin/blazectl
RUN blazectl --version

RUN apt-get -y update && apt-get -y purge curl

RUN mkdir -p /app/sample
COPY run.sh /app/run.sh
RUN chmod a+rx /app/run.sh
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ The test data loader is configured using environment variables:
|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------|----------------------------------|
| `FHIR_STORE_URL` | HTTP Address of the FHIR store | http://store:8080/fhir |
| `PATIENT_COUNT` | Number of patients to be generated. | 100 |
| `START_DELAY` | Time in seconds before starting upload. | 0 |
| `USE_BRIDGEHEAD_AUTH` | Use Bridgehead-specific authorization credentials to access Blaze. | false |
| `KEEP_ALIVE` | Keep the script alive once it has done its work. | false |

You can use the START_DELAY variable if you want to wait for something (typically Blaze) to start before running the data load.

If you set USE_BRIDGEHEAD_AUTH to true, then the script will look in /etc/bridgehead, to see if there is a file called ccp.local.conf or similar, and try to extract the authorization credentials for Blaze from there.

If you set KEEP_ALIVE to true, the script will never terminate. This can be useful if you are working in a Bridgehead environemnt, where terminating containers cause the Bridgehead to shut down.

## Building

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.7"
services:
store:
container_name: store
image: samply/blaze:develop
image: samply/blaze:latest
environment:
BASE_URL: "http://store:8080"
ports:
Expand All @@ -14,4 +14,4 @@ services:
environment:
FHIR_STORE_URL: "http://store:8080/fhir"
PATIENT_COUNT: "2000"
command: sh -c "sleep 60 && /app/run.sh" # wait for Blaze to start
START_DELAY: 90
32 changes: 29 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
#!/usr/bin/env bash

#cd /app
if [ -n "$START_DELAY" ]; then
echo "Waiting for $START_DELAY seconds..."
sleep "$START_DELAY"
fi

echo Generating fake data
bbmri-fhir-gen /app/sample -n ${PATIENT_COUNT:-100}

AUTH=""
if [ -n "$USE_BRIDGEHEAD_AUTH" ] && [ "$USE_BRIDGEHEAD_AUTH" = true ]; then
FILE="/etc/bridgehead/ccp.local.conf"
if [ ! -e "$FILE" ]; then
FILE="/etc/bridgehead/bbmri.local.conf"
fi
if [ ! -e "$FILE" ]; then
# Use a glob pattern to find any matching file
FILE=$(ls /etc/bridgehead/*.local.conf 2>/dev/null | head -n 1)
fi
if [ -e "$FILE" ]; then
USER=$(grep -m 1 User "$FILE" | sed 's/# User: //')
PASSWORD=$(grep -m 1 Password "$FILE" | sed 's/# Password: //')
fi
if [ -n "$USER" ] && [ -n "$PASSWORD" ]; then
AUTH="--user $USER --password $PASSWORD"
fi
fi

echo Uploading data to Blaze Store
blazectl --server ${FHIR_STORE_URL:-http://store:8080/fhir} upload /app/sample/
blazectl --server ${FHIR_STORE_URL:-http://store:8080/fhir} count-resources
blazectl $AUTH --server ${FHIR_STORE_URL:-http://store:8080/fhir} upload /app/sample/
blazectl $AUTH --server ${FHIR_STORE_URL:-http://store:8080/fhir} count-resources

echo Done

if [ -n "$KEEP_ALIVE" ] && [ "$KEEP_ALIVE" = true ]; then
tail -f /dev/null
fi

0 comments on commit 3018263

Please sign in to comment.