Skip to content

Commit

Permalink
Merge pull request #108 from srdc/tofhir-log-server
Browse files Browse the repository at this point in the history
Tofhir log server
  • Loading branch information
sinaci authored Oct 20, 2023
2 parents e473be6 + 3978ec3 commit 503d32c
Show file tree
Hide file tree
Showing 44 changed files with 2,565 additions and 199 deletions.
4 changes: 0 additions & 4 deletions docker/build.sh

This file was deleted.

40 changes: 40 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '3.9'
services:
tofhir-log-server:
image: srdc/tofhir-log-server:latest
container_name: tofhir-log-server
hostname: tofhir-log-server
ports:
- "8086:8086"
networks:
- tofhir-network
volumes:
- './tofhir-docker-logs:/usr/local/tofhir/logs'
tofhir-server:
image: srdc/tofhir-server:latest
container_name: tofhir
hostname: tofhir
environment:
- LOG_SERVICE_ENDPOINT=http://tofhir-log-server:8086/tofhir-logs
- FHIR_DEFINITIONS_ENDPOINT=http://onfhir:8080/fhir
- FHIR_REPO_URL=http://onfhir:8080/fhir
- APP_CONF_FILE=/usr/local/tofhir/conf/docker/tofhir-server.conf
- CONTEXT_PATH=conf
ports:
- "8085:8085"
networks:
- tofhir-network
volumes:
- './data-integration-suite:/usr/local/tofhir/conf'
- './tofhir-docker-logs:/usr/local/tofhir/logs'
tofhir-web:
image: srdc/tofhir-web:latest
container_name: tofhir-web
ports:
- "8082:80"
networks:
- tofhir-network
networks:
tofhir-network:
name: onfhir-network
external: true
4 changes: 2 additions & 2 deletions docker/Dockerfile-addJar → docker/engine/Dockerfile-addJar
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ENV TOFHIR_HOME /usr/local/tofhir
RUN mkdir -p "$TOFHIR_HOME"
WORKDIR $TOFHIR_HOME

COPY ./tofhir-engine/target/tofhir-standalone.jar .
COPY ./docker/docker-entrypoint.sh .
COPY ./tofhir-engine/target/tofhir-engine-standalone.jar .
COPY ./docker/engine/docker-entrypoint.sh .
RUN chmod +x docker-entrypoint.sh

ENTRYPOINT ["./docker-entrypoint.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ ENV TOFHIR_HOME /usr/local/tofhir
RUN mkdir -p "$TOFHIR_HOME"
WORKDIR $TOFHIR_HOME

COPY --from=builder $TOFHIR_HOME/tofhir-engine/target/tofhir-standalone.jar .
COPY --from=builder $TOFHIR_HOME/tofhir-engine/target/tofhir-engine-standalone.jar .

COPY docker/docker-entrypoint.sh .
COPY docker/engine/docker-entrypoint.sh .
RUN chmod +x docker-entrypoint.sh

ENTRYPOINT ["./docker-entrypoint.sh"]
4 changes: 4 additions & 0 deletions docker/engine/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Execute one of the following commands from the project.root.directory (../../)

docker build -f docker/engine/Dockerfile-addJar -t srdc/tofhir:latest -t srdc/tofhir:1.0 .
docker build -f docker/engine/Dockerfile-buildJar -t srdc/tofhir:latest -t srdc/tofhir:1.0 .
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if [ ! -z "$FHIR_BATCH_SIZE" ]; then
JAVA_CMD+="-Dtofhir.fhir-writer.batch-group-size=$FHIR_BATCH_SIZE "
fi
if [ ! -z "$DB_PATH" ]; then
JAVA_CMD+="-Dtofhir.db=$DB_PATH "
JAVA_CMD+="-Dtofhir.db-path=$DB_PATH "
fi

# Delay the execution for this amount of seconds
Expand All @@ -46,6 +46,6 @@ if [ ! -z "$DELAY_EXECUTION" ]; then
fi

# Finally, tell which jar to run
JAVA_CMD+="tofhir-standalone.jar"
JAVA_CMD+="tofhir-engine-standalone.jar"

eval $JAVA_CMD "$@"
11 changes: 11 additions & 0 deletions docker/log-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM openjdk:11-jre-slim

ENV TOFHIR_HOME /usr/local/tofhir
RUN mkdir -p "$TOFHIR_HOME"
WORKDIR $TOFHIR_HOME

COPY ./tofhir-log-server/target/tofhir-log-server-standalone.jar .
COPY ./docker/log-server/docker-entrypoint.sh .
RUN chmod +x docker-entrypoint.sh

ENTRYPOINT ["./docker-entrypoint.sh"]
4 changes: 4 additions & 0 deletions docker/log-server/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Execute one of the following commands from the project.root.directory (../../)

docker build -f docker/log-server/Dockerfile -t srdc/tofhir-log-server:latest .

42 changes: 42 additions & 0 deletions docker/log-server/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

JAVA_CMD="java -Xms256m -Xmx3g -jar "

# Configure application.conf path
if [ ! -z "$APP_CONF_FILE" ]; then
JAVA_CMD+="-Dconfig.file=$APP_CONF_FILE "
fi

# Configure logback configuration file
if [ ! -z "$LOGBACK_CONF_FILE" ]; then
JAVA_CMD+="-Dlogback.configurationFile=$LOGBACK_CONF_FILE "
fi

# Configure Spark
if [ ! -z "$SPARK_APPNAME" ]; then
JAVA_CMD+="-Dspark.app-name=$SPARK_APPNAME "
fi
if [ ! -z "$SPARK_MASTER" ]; then
JAVA_CMD+="-Dspark.master=$SPARK_MASTER "
fi

# Configure tofhir-server web server
if [ ! -z "$WEBSERVER_HOST" ]; then
JAVA_CMD+="-Dwebserver.host=$WEBSERVER_HOST "
fi
if [ ! -z "$WEBSERVER_PORT" ]; then
JAVA_CMD+="-Dwebserver.port=$WEBSERVER_PORT "
fi
if [ ! -z "$WEBSERVER_BASEURI" ]; then
JAVA_CMD+="-Dwebserver.base-uri=$WEBSERVER_BASEURI "
fi

# Delay the execution for this amount of seconds
if [ ! -z "$DELAY_EXECUTION" ]; then
sleep $DELAY_EXECUTION
fi

# Finally, tell which jar to run
JAVA_CMD+="tofhir-log-server-standalone.jar"

eval $JAVA_CMD "$@"
11 changes: 11 additions & 0 deletions docker/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM openjdk:11-jre-slim

ENV TOFHIR_HOME /usr/local/tofhir
RUN mkdir -p "$TOFHIR_HOME"
WORKDIR $TOFHIR_HOME

COPY ./tofhir-server/target/tofhir-server-standalone.jar .
COPY ./docker/server/docker-entrypoint.sh .
RUN chmod +x docker-entrypoint.sh

ENTRYPOINT ["./docker-entrypoint.sh"]
4 changes: 4 additions & 0 deletions docker/server/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Execute one of the following commands from the project.root.directory (../../)

docker build -f docker/server/Dockerfile -t srdc/tofhir-server:latest .

84 changes: 84 additions & 0 deletions docker/server/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash

JAVA_CMD="java -Xms256m -Xmx3g -jar "

# Configure application.conf path
if [ ! -z "$APP_CONF_FILE" ]; then
JAVA_CMD+="-Dconfig.file=$APP_CONF_FILE "
fi

# Configure logback configuration file
if [ ! -z "$LOGBACK_CONF_FILE" ]; then
JAVA_CMD+="-Dlogback.configurationFile=$LOGBACK_CONF_FILE "
fi

# Configure Spark
if [ ! -z "$SPARK_APPNAME" ]; then
JAVA_CMD+="-Dspark.app-name=$SPARK_APPNAME "
fi
if [ ! -z "$SPARK_MASTER" ]; then
JAVA_CMD+="-Dspark.master=$SPARK_MASTER "
fi

# Configure toFHIR mapping-related paths
if [ ! -z "$CONTEXT_PATH" ]; then
JAVA_CMD+="-Dtofhir.context-path=$CONTEXT_PATH "
fi
if [ ! -z "$MAPPINGS_FOLDER" ]; then
JAVA_CMD+="-Dtofhir.mappings.repository.folder-path=$MAPPINGS_FOLDER "
fi
if [ ! -z "$SCHEMAS_FOLDER" ]; then
JAVA_CMD+="-Dtofhir.mappings.schemas.repository.folder-path=$SCHEMAS_FOLDER "
fi
if [ ! -z "$MAPPING_JOB" ]; then
JAVA_CMD+="-Dtofhir.mapping-jobs.initial-job-file-path=$MAPPING_JOB "
fi
if [ ! -z "$FHIR_BATCH_SIZE" ]; then
JAVA_CMD+="-Dtofhir.fhir-writer.batch-group-size=$FHIR_BATCH_SIZE "
fi
if [ ! -z "$DB_PATH" ]; then
JAVA_CMD+="-Dtofhir.db-path=$DB_PATH "
fi

# Configure the FHIR endpoint to which this toFHIR can connect to retrieve resource definitions etc.
if [ ! -z "$FHIR_DEFINITIONS_ENDPOINT" ]; then
JAVA_CMD+="-Dfhir.definitions-fhir-endpoint=$FHIR_DEFINITIONS_ENDPOINT "
fi
if [ ! -z "$FHIR_DEFINITIONS_ROOT_URL" ]; then
JAVA_CMD+="-Dfhir.definitions-root-urls=$FHIR_DEFINITIONS_ROOT_URL "
fi
if [ ! -z "$FHIR_DEFINITIONS_PROFILES_PATH" ]; then
JAVA_CMD+="-Dfhir.profiles-path=$FHIR_DEFINITIONS_ROOT_URL "
fi
if [ ! -z "$FHIR_DEFINITIONS_VALUESETS_PATH" ]; then
JAVA_CMD+="-Dfhir.valuesets-path=$FHIR_DEFINITIONS_VALUESETS_PATH "
fi
if [ ! -z "$FHIR_DEFINITIONS_CODESYSTEMS_URL" ]; then
JAVA_CMD+="-Dfhir.codesystems-path=$FHIR_DEFINITIONS_CODESYSTEMS_URL "
fi

# Configure tofhir-server web server
if [ ! -z "$WEBSERVER_HOST" ]; then
JAVA_CMD+="-Dwebserver.host=$WEBSERVER_HOST "
fi
if [ ! -z "$WEBSERVER_PORT" ]; then
JAVA_CMD+="-Dwebserver.port=$WEBSERVER_PORT "
fi
if [ ! -z "$WEBSERVER_BASEURI" ]; then
JAVA_CMD+="-Dwebserver.base-uri=$WEBSERVER_BASEURI "
fi

# Configure log service
if [ ! -z "$LOG_SERVICE_ENDPOINT" ]; then
JAVA_CMD+="-Dlog-service.endpoint=$LOG_SERVICE_ENDPOINT "
fi

# Delay the execution for this amount of seconds
if [ ! -z "$DELAY_EXECUTION" ]; then
sleep $DELAY_EXECUTION
fi

# Finally, tell which jar to run
JAVA_CMD+="tofhir-server-standalone.jar"

eval $JAVA_CMD "$@"
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<modules>
<module>tofhir-engine</module>
<module>tofhir-server</module>
<module>tofhir-log-server</module>
<module>tofhir-common</module>
<module>tofhir-rxnorm</module>
</modules>
Expand Down Expand Up @@ -356,6 +357,11 @@
<artifactId>tofhir-server-common_2.13</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.onfhir</groupId>
<artifactId>tofhir-log-server-common_2.13</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.onfhir</groupId>
<artifactId>tofhir-engine_2.13</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tofhir-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</filter>
</filters>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>tofhir-standalone</finalName>
<finalName>tofhir-engine-standalone</finalName>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ToFhirEngine(mappingRepository: Option[IFhirMappingCachedRepository] = Non

//Spark configurations
private val sparkConf: SparkConf = ToFhirConfig.createSparkConf

val engineConfig: ToFhirEngineConfig = ToFhirConfig.engineConfig

val sparkSession: SparkSession = SparkSession.builder().config(sparkConf).getOrCreate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ object ToFhirConfig {
lazy val sparkAppName: String = Try(sparkConfig.getString("app.name")).getOrElse("AICCELERATE Data Integration Suite")
/** Master url of the Spark cluster */
lazy val sparkMaster: String = Try(sparkConfig.getString("master")).getOrElse("local[4]")

/**
* Default configurations for spark
*/
Expand Down
Loading

0 comments on commit 503d32c

Please sign in to comment.