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