comparison prod/update-inventory-app.sh @ 363:cf7166c5c52f

INV-196 Move inventory scripts to prod directory
author Matt Calmes <calmes@ssdt-ohio.org>
date Mon, 16 Aug 2021 12:58:30 -0400
parents
children 3dc92d4243ef
comparison
equal deleted inserted replaced
362:91d530304bbf 363:cf7166c5c52f
1 #!/bin/bash
2 #
3 # read required env variables
4 BASEDIR="$PWD"
5 source $BASEDIR/.env/ssdt-inventory-shared.properties
6 source $BASEDIR/.env/ssdt-inventory-app.properties
7 #
8 # docker login
9 echo "Attempting to login to $artifactUrl"
10 docker login $artifactUrl -u $artifactUser -p $artifactPassword
11 # docker pull app image
12 echo "Attempting to pull $artifactUrl/inventory-app:$appVersion"
13 docker pull $artifactUrl/inventory-app:$appVersion
14 #
15 # docker stop inventory app container
16 echo "Attempting to stop $entityId-inventory-app container"
17 docker stop $entityId-inventory-app
18 #
19 # docker rm inventory app container
20 echo "Attempting to remove $entityId-inventory-app container"
21 docker rm $entityId-inventory-app
22 #
23 # docker run inventory app container based on new image
24 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"
25 dockerRunCommand="$dockerRunCommand -e SPRING_DATASOURCE_PASSWORD=$dbPassword -e SPRING_PROFILES_ACTIVE=prod -e APPLICATION_ADMIN_PASSWORD=$adminPassword -e JAVA_OPTS=$java_opts"
26 dockerRunCommand="$dockerRunCommand -e USAS_CONFIGURATION_HOST=$usasHost -e USAS_CONFIGURATION_PORT=$usasPort -e USAS_CONFIGURATION_APIKEY=$inventoryApiKey -e USAS_CONFIGURATION_REMOTEAPIKEY=$usasApiKey"
27 if [ ! -z "$virtualHost" ]; then
28 dockerRunCommand="$dockerRunCommand -e VIRTUAL_HOST=$virtualHost"
29 fi
30 #
31 if [ ! -z "$virtualPort" ]; then
32 dockerRunCommand="$dockerRunCommand -e VIRTUAL_PORT=$virtualPort"
33 fi
34 #
35 if [ ! -z "$letsencryptHost" ]; then
36 dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_HOST=$letsencryptHost"
37 fi
38 #
39 if [ ! -z "$letsencryptEmail" ]; then
40 dockerRunCommand="$dockerRunCommand -e LETSENCRYPT_EMAIL=$letsencryptEmail"
41 fi
42 #
43 if [ ! -z "$hostPort" ]; then
44 dockerRunCommand="$dockerRunCommand -p $hostPort"
45 fi
46 #
47 dockerRunCommand="$dockerRunCommand -d $artifactUrl/inventory-app:$appVersion"
48 #
49 # Execute constructed docker run command to create $entityId-inventory-app container connected to db and docker network
50 echo "Executing docker run command"
51 $dockerRunCommand