view prod/install-inventory-app.sh @ 402:be08b5a62a77

INV-334: Updated inventory scripts to handle new reset property.
author Jason Klinger <klinger@nwoca.org>
date Fri, 20 May 2022 19:49:19 +0100
parents cf7166c5c52f
children c3f58eddce4f
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
# 
# Build docker run command based on setting in env files
echo "Building docker run command"
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
#
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