diff --git a/compose-cluster/generate_compose_yaml.py b/compose-cluster/generate_compose_yaml.py index 036db93e50..7b865aef08 100644 --- a/compose-cluster/generate_compose_yaml.py +++ b/compose-cluster/generate_compose_yaml.py @@ -714,7 +714,7 @@ def newListIfEmpty(yaml_object, *keys): newListIfEmpty(yaml_obj, 'services', 'cardsinitial', 'ports').append("127.0.0.1:5005:5005") if args.cards_project: - yaml_obj['services']['cardsinitial']['environment'].append("CARDS_PROJECT={}".format(args.cards_project)) + yaml_obj['services']['cardsinitial']['environment'].append("PROJECT_NAME={}".format(args.cards_project)) if args.composum: yaml_obj['services']['cardsinitial']['environment'].append("DEV=true") diff --git a/distribution/Dockerfile b/distribution/Dockerfile index 4ad7627696..56379bbe91 100644 --- a/distribution/Dockerfile +++ b/distribution/Dockerfile @@ -51,7 +51,8 @@ RUN apk upgrade --available RUN apk add \ openjdk11-jre \ python3 \ - tzdata + tzdata \ + bash # Optional: enable remote debugging at port 5005 ENV DEBUG= @@ -87,6 +88,12 @@ COPY --from=0 /root/.m2 /root/.m2 # Copy in the build metadata COPY --from=0 /metadata /metadata +# Copy in the generic CARDS logo +COPY --from=0 /cards/modules/homepage/src/main/media/SLING-INF/content/libs/cards/resources/media/default/logo_light_bg.png /metadata/logo.png + +# Create the ~/.cards-generic-m2/repository empty directory +RUN mkdir -p /root/.cards-generic-m2/repository + # This is the default command executed when starting the container COPY docker_entry.sh /docker_entry.sh RUN chmod +x /docker_entry.sh diff --git a/distribution/docker_entry.sh b/distribution/docker_entry.sh index 64135626e2..f010f022d1 100644 --- a/distribution/docker_entry.sh +++ b/distribution/docker_entry.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -37,106 +37,63 @@ then PERMISSIONS="${PERMISSIONS:-trusted}" fi -PROJECT_ARTIFACTID=$1 -PROJECT_VERSION=$2 +CARDS_ARTIFACTID=$1 +CARDS_VERSION=$2 -VALID_CARDS_PROJECTS="||cards4kids|cards4lfs|cards4proms|cards4prems|cards4heracles|" -echo "${VALID_CARDS_PROJECTS}" | grep -q "|${CARDS_PROJECT}|" || { echo "Invalid project specified - defaulting to generic CARDS."; unset CARDS_PROJECT; } - -featureFlagString="" -if [ ! -z $CARDS_PROJECT ] +if [ -z $PROJECT_VERSION ] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/${CARDS_PROJECT}/${PROJECT_VERSION}/slingosgifeature" + PROJECT_VERSION=$CARDS_VERSION fi -[[ "${CARDS_PROJECT}" == 'cards4proms' || "${CARDS_PROJECT}" == 'cards4prems' ]] && SMTPS_ENABLED="true" +VALID_PROJECT_NAMES="||cards4kids|cards4lfs|cards4proms|cards4prems|cards4heracles|" +[ -e /external_project/project_code.txt ] && VALID_PROJECT_NAMES="${VALID_PROJECT_NAMES}$(cat /external_project/project_code.txt | head -n 1 | tr -d '\n')|" +echo "${VALID_PROJECT_NAMES}" | grep -q "|${PROJECT_NAME}|" || { echo "Invalid project specified - defaulting to generic CARDS."; unset PROJECT_NAME; } -[[ "${CARDS_PROJECT}" == 'cards4prems' ]] && CSV_EXPORT_ENABLED="true" -[[ "${CARDS_PROJECT}" == 'cards4proms' || "${CARDS_PROJECT}" == 'cards4prems' ]] && CLARITY_IMPORT_ENABLED="true" +featureFlagString="" +if [ ! -z $PROJECT_NAME ] && [ ! -z $PROJECT_VERSION ] +then + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/${PROJECT_NAME}/${PROJECT_VERSION}/slingosgifeature" +fi if [ ! -z $DEV ] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards/${PROJECT_VERSION}/slingosgifeature/composum" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards/${CARDS_VERSION}/slingosgifeature/composum" fi if [ ! -z $DEMO ] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-modules-demo-banner/${PROJECT_VERSION}/slingosgifeature," - featureFlagString="${featureFlagString}mvn:io.uhndata.cards/cards-modules-upgrade-marker/${PROJECT_VERSION}/slingosgifeature," - featureFlagString="${featureFlagString}mvn:io.uhndata.cards/cards-dataentry/${PROJECT_VERSION}/slingosgifeature/forms_demo" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-modules-demo-banner/${CARDS_VERSION}/slingosgifeature," + featureFlagString="${featureFlagString}mvn:io.uhndata.cards/cards-modules-upgrade-marker/${CARDS_VERSION}/slingosgifeature," + featureFlagString="${featureFlagString}mvn:io.uhndata.cards/cards-dataentry/${CARDS_VERSION}/slingosgifeature/forms_demo" else if [ ! -z $DEMO_BANNER ] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-modules-demo-banner/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-modules-demo-banner/${CARDS_VERSION}/slingosgifeature" fi fi if [ ! -z $ENABLE_TEST_FEATURES ] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-modules-test-forms/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-modules-test-forms/${CARDS_VERSION}/slingosgifeature" fi if [ ! -z $SAML_CLOUD_IAM_DEMO ] then if [[ ${BEHIND_SSL_PROXY} == 'true' ]] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-cloud-iam-demo-saml-support-ssl/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-cloud-iam-demo-saml-support-ssl/${CARDS_VERSION}/slingosgifeature" else - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-cloud-iam-demo-saml-support/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-cloud-iam-demo-saml-support/${CARDS_VERSION}/slingosgifeature" fi fi if [ ! -z $ADDITIONAL_SLING_FEATURES ] then - featureFlagString="$featureFlagString -f $ADDITIONAL_SLING_FEATURES" + featureFlagString="$featureFlagString -f ${ADDITIONAL_SLING_FEATURES@P}" fi -#Parse the (legacy) ADDITIONAL_RUN_MODES environment variable and determine the features that need to be enabled -legacyRunModes=$(echo $ADDITIONAL_RUN_MODES | tr "," "\n") -for legacyRunMode in $legacyRunModes -do - #Perform the translation - if [[ ${legacyRunMode} == 'oak_tar' ]] - then - STORAGE=tar - elif [[ ${legacyRunMode} == 'oak_mongo' ]] - then - STORAGE=mongo - elif [[ ${legacyRunMode} == 'dev' ]] - then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards/${PROJECT_VERSION}/slingosgifeature/composum" - elif [[ ${legacyRunMode} == 'kids' ]] - then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards4kids/${PROJECT_VERSION}/slingosgifeature" - elif [[ ${legacyRunMode} == 'lfs' ]] - then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards4lfs/${PROJECT_VERSION}/slingosgifeature" - elif [[ ${legacyRunMode} == 'proms' ]] - then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards4proms/${PROJECT_VERSION}/slingosgifeature" - SMTPS_ENABLED="true" - elif [[ ${legacyRunMode} == 'test' ]] - then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-modules-test-forms/${PROJECT_VERSION}/slingosgifeature" - elif [[ ${legacyRunMode} == 'demo' ]] - then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-modules-demo-banner/${PROJECT_VERSION}/slingosgifeature," - featureFlagString="${featureFlagString}mvn:io.uhndata.cards/cards-modules-upgrade-marker/${PROJECT_VERSION}/slingosgifeature," - featureFlagString="${featureFlagString}mvn:io.uhndata.cards/cards-dataentry/${PROJECT_VERSION}/slingosgifeature/forms_demo" - elif [[ ${legacyRunMode} == 'permissions_open' ]] - then - PERMISSIONS="open" - elif [[ ${legacyRunMode} == 'permissions_trusted' ]] - then - PERMISSIONS="trusted" - elif [[ ${legacyRunMode} == 'permissions_ownership' ]] - then - PERMISSIONS="ownership" - fi -done - # Read /sling-features.json and enable the features required for this project -PROJECT_REQUIRED_FEATURES=$(CARDS_VERSION=${PROJECT_VERSION} PROJECT_NAME=${CARDS_PROJECT} PROJECT_VERSION=${PROJECT_VERSION} PERMISSIONS=${PERMISSIONS} python3 /get_project_dependency_features.py /sling-features.json) +PROJECT_REQUIRED_FEATURES=$(CARDS_VERSION=${CARDS_VERSION} PROJECT_NAME=${PROJECT_NAME} PROJECT_VERSION=${PROJECT_VERSION} PERMISSIONS=${PERMISSIONS} python3 /get_project_dependency_features.py /sling-features.json) if [ ! -z $PROJECT_REQUIRED_FEATURES ] then featureFlagString="$featureFlagString -f $PROJECT_REQUIRED_FEATURES" @@ -150,7 +107,9 @@ echo "DEBUG = $DEBUG" echo "PERMISSIONS = $PERMISSIONS" echo "ADDITIONAL_RUN_MODES = $ADDITIONAL_RUN_MODES" echo "ADDITIONAL_SLING_FEATURES = $ADDITIONAL_SLING_FEATURES" -echo "PROJECT_ARTIFACTID = $PROJECT_ARTIFACTID" +echo "CARDS_ARTIFACTID = $CARDS_ARTIFACTID" +echo "CARDS_VERSION = $CARDS_VERSION" +echo "PROJECT_NAME = $PROJECT_NAME" echo "PROJECT_VERSION = $PROJECT_VERSION" #Are we using an external MongoDB service for data storage? @@ -178,31 +137,31 @@ fi #Should the SMTPS OSGi bundle be enabled? if [[ "$SMTPS_ENABLED" == "true" ]] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-email-notifications/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-email-notifications/${CARDS_VERSION}/slingosgifeature" fi #Should the SAML OSGi bundle be enabled? if [[ "$SAML_AUTH_ENABLED" == "true" ]] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-saml-support/${PROJECT_VERSION}/slingosgifeature/base -C io.dropwizard.metrics:metrics-core:ALL -f mvn:io.uhndata.cards/cards-fetch-requires-saml-login/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-saml-support/${CARDS_VERSION}/slingosgifeature/base -C io.dropwizard.metrics:metrics-core:ALL -f mvn:io.uhndata.cards/cards-fetch-requires-saml-login/${CARDS_VERSION}/slingosgifeature" fi #Should the scheduled-csv-export module be loaded? if [[ "$CSV_EXPORT_ENABLED" == "true" ]] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-scheduled-csv-export/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-scheduled-csv-export/${CARDS_VERSION}/slingosgifeature" fi #Should the clarity-integration module be loaded? if [[ "$CLARITY_IMPORT_ENABLED" == "true" ]] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-clarity-integration/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-clarity-integration/${CARDS_VERSION}/slingosgifeature" fi #Should the cards-slack-notifications module be loaded? if [[ "$SLACK_NOTIFICATIONS_ENABLED" == "true" ]] then - featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-slack-notifications/${PROJECT_VERSION}/slingosgifeature" + featureFlagString="$featureFlagString -f mvn:io.uhndata.cards/cards-slack-notifications/${CARDS_VERSION}/slingosgifeature" fi if [[ "$SMTPS_LOCALHOST_PROXY" == "true" ]] @@ -228,4 +187,4 @@ done #Execute the volume_mounted_init.sh script if it is present [ -e /volume_mounted_init.sh ] && /volume_mounted_init.sh -java -Djdk.xml.entityExpansionLimit=0 ${CARDS_JAVA_MEMORY_LIMIT_MB:+ -Xmx${CARDS_JAVA_MEMORY_LIMIT_MB}m} ${DEBUG:+ -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=*:5005} -jar org.apache.sling.feature.launcher.jar -p .cards-data -u "file://$(realpath ${HOME}/.m2/repository),https://nexus.phenotips.org/nexus/content/groups/public,https://repo.maven.apache.org/maven2,https://repository.apache.org/content/groups/snapshots" -f ./${PROJECT_ARTIFACTID}-${PROJECT_VERSION}-core_${STORAGE}_far.far${EXT_MONGO_VARIABLES}${SMTPS_VARIABLES}${featureFlagString} +java -Djdk.xml.entityExpansionLimit=0 ${CARDS_JAVA_MEMORY_LIMIT_MB:+ -Xmx${CARDS_JAVA_MEMORY_LIMIT_MB}m} ${DEBUG:+ -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=*:5005} -jar org.apache.sling.feature.launcher.jar -p .cards-data -u "file://$(realpath ${HOME}/.m2/repository),file://$(realpath ${HOME}/.cards-generic-m2/repository),https://nexus.phenotips.org/nexus/content/groups/public,https://repo.maven.apache.org/maven2,https://repository.apache.org/content/groups/snapshots" -f ./${CARDS_ARTIFACTID}-${CARDS_VERSION}-core_${STORAGE}_far.far${EXT_MONGO_VARIABLES}${SMTPS_VARIABLES}${featureFlagString} diff --git a/start_cards.sh b/start_cards.sh index 47d2c7cc5e..ed80da29b3 100755 --- a/start_cards.sh +++ b/start_cards.sh @@ -353,7 +353,8 @@ do ARGS[$ARGS_LENGTH]=mvn:io.uhndata.cards/cards-slack-notifications/${CARDS_VERSION}/slingosgifeature ARGS_LENGTH=${ARGS_LENGTH}+1 else - ARGS[$i]=${ARGS[$i]/VERSION/${CARDS_VERSION}} + ARGS[$i]=${ARGS[$i]@P} + ARGS[$i]=${ARGS[$i]//VERSION/${CARDS_VERSION}} fi done