-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprod-compose.sh
More file actions
executable file
·61 lines (45 loc) · 1.36 KB
/
prod-compose.sh
File metadata and controls
executable file
·61 lines (45 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash -ex
RANCHER_STACK_NAME=${RANCHER_STACK_NAME:-stack-name}
if [ ! -f rancher_cli.env ]; then
echo "ERROR: You have to create rancher_cli.env file from rancher_cli.env.template"
exit 1
fi
if [ ! -f shared_vars.env ]; then
echo "ERROR: You have to: create shared_vars.env file from shared_vars.env.template"
exit 1
fi
# load and export all defined variables
set -o allexport
source shared_vars.env
set +o allexport
cleanup () {
rm -rf secrets
}
check_compose_variables () {
# check variables used in docker-compose files
# values of the variables will be read from the current environment
test $PUBLIC_VARIABLE
}
create_secrets_files () {
# create files with secrets values
test $SECRET_VARIABLE
# content of the specified files will be used to create the secrets
# before creating the stack and starting the services
mkdir -p secrets
echo $SECRET_VARIABLE > secrets/secret-variable.txt
unset SECRET_VARIABLE
}
rancher_cli () {
rancher --file docker-compose.yml --file docker-compose.rancher.yml \
--rancher-file rancher-compose.yml "$@"
}
trap cleanup EXIT
check_compose_variables
create_secrets_files
# load Rancher access data
source rancher_cli.env
test $RANCHER_URL
test $RANCHER_ACCESS_KEY
test $RANCHER_SECRET_KEY
rancher_cli up -d --stack $RANCHER_STACK_NAME --pull --upgrade \
--confirm-upgrade --description "A simple Rancher stack example"