view prod/update-inventory-app.sh @ 604:f05817aee0f0

Add mini orange envars
author Marc Davis <marc.davis@mcoecn.org>
date Tue, 17 Sep 2024 14:25:27 -0400
parents c3f58eddce4f
children
line wrap: on
line source
#!/bin/bash
#
# read required env variables
BASEDIR="$PWD"
source $BASEDIR/.env/ssdt-inventory-shared.properties
source $BASEDIR/.env/ssdt-inventory-app.properties
#
# docker login
echo "Attempting to login to $artifactUrl"
docker login $artifactUrl -u $artifactUser -p $artifactPassword
# docker pull app image
echo "Attempting to pull $artifactUrl/inventory-app:$appVersion"
docker pull $artifactUrl/inventory-app:$appVersion
# 
echo "Attempting to pull $artifactUrl/inventory-importapp:$appVersion"
docker pull $artifactUrl/inventory-importapp:$appVersion
# 
# docker stop inventory app container
echo "Attempting to stop $entityId-inventory-app container"
docker stop $entityId-inventory-app
#
# docker rm inventory app container
echo "Attempting to remove $entityId-inventory-app container"
docker rm $entityId-inventory-app
#
# docker run inventory app container based on new image
dockerRunCommand="docker run --name $entityId-inventory-app --restart=unless-stopped --network $entityId-inventory-net -e SPRING_DATASOURCE_URL=jdbc:postgresql://$entityId-inventory-db:5432/invdb"
dockerRunCommand="$dockerRunCommand -e SPRING_DATASOURCE_PASSWORD=$dbPassword -e SPRING_PROFILES_ACTIVE=prod -e APPLICATION_ADMIN_PASSWORD=$adminPassword -e JAVA_OPTS=$java_opts"
dockerRunCommand="$dockerRunCommand -e USAS_CONFIGURATION_HOST=$usasHost -e USAS_CONFIGURATION_PORT=$usasPort -e USAS_CONFIGURATION_APIKEY=$inventoryApiKey -e USAS_CONFIGURATION_REMOTEAPIKEY=$usasApiKey"
if [ ! -z "$virtualHost" ]; then
    dockerRunCommand="$dockerRunCommand -e VIRTUAL_HOST=$virtualHost"
fi
#
if [ ! -z "$virtualPort" ]; then
    dockerRunCommand="$dockerRunCommand -e VIRTUAL_PORT=$virtualPort"
fi
#
if [ ! -z "$letsencryptHost" ]; then
    dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_HOST=$letsencryptHost"
fi
#
if [ ! -z "$letsencryptEmail" ]; then
    dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_EMAIL=$letsencryptEmail"
fi
#
if [ ! -z "$applicationAdminReset" ]; then
    dockerRunCommand="$dockerRunCommand -e APPLICATION_ADMIN_RESET=$applicationAdminReset"
fi
#
if [ ! -z "$hostPort" ]; then
    dockerRunCommand="$dockerRunCommand -p $hostPort"
fi
#
if [ ! -z "$duo_enabled" ]; then
    dockerRunCommand="$dockerRunCommand -e DUO_ENABLED=$duo_enabled -e DUO_CLIENT_ID=$duo_client_id -e DUO_CLIENT_SECRET=$duo_client_secret -e DUO_API_HOSTNAME=$duo_api_hostname -e DUO_FAIL_OPEN=$duo_fail_open "
    dockerRunCommand="$dockerRunCommand -e DUO_USXS_HOST=$duo_usxs_host -e DUO_USXS_PORT=$duo_usxs_port -e DUO_USXS_CONTEXT=$duo_usxs_context -e DUO_MINUTES_UNTIL_EXPIRATION=$duo_minutes_until_expiration "
fi
#
#
if [ ! -z "$miniOrangeEnabled" ]; then
    echo "Adding MiniOrange Configuration"
    dockerRunCommand="$dockerRunCommand -e MINI_ORANGE_ENABLED=$miniOrangeEnabled -e MINI_ORANGE_CLIENT_ID=$miniOrangeClientId -e MINI_ORANGE_CLIENT_SECRET=$miniOrangeClientSecret -e MINI_ORANGE_API_HOSTNAME=$miniOrangeApiHostname "
    dockerRunCommand="$dockerRunCommand -e MINI_ORANGE_FAIL_OPEN=$miniOrangeFailOpen -e MINI_ORANGE_APP_HOST=$miniOrangeEssHost -e MINI_ORANGE_MINUTES_UNTIL_EXPIRATION=$miniOrangeMinutesUntilExpiration "
fi
#
dockerRunCommand="$dockerRunCommand -d $artifactUrl/inventory-app:$appVersion"
#
# Execute constructed docker run command to create $entityId-inventory-app container connected to db and docker network
echo "Executing docker run command"
$dockerRunCommand