-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdeploy-carina.sh
executable file
·83 lines (66 loc) · 1.63 KB
/
deploy-carina.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
. build-support/build-common.sh
usage() {
echo "Usage: $0 DEPLOY_CLUSTER"
}
check_volume() {
if docker volume &> /dev/null; then
if docker volume ls |awk "\$2 == \"$1\"{++m} END {exit (m>0?0:1)}"; then
return
else
echo "Missing required volume $1"
exit 1
fi
else
echo "WARN: 'docker volume' not supported so we'll have to trust $1 exists"
fi
}
if [[ $# < 1 ]]; then
usage
exit 1
fi
export DEPLOY_CLUSTER=$1
if [[ -z $CIRCLE_TAG ]]; then
if [[ $CIRCLE_BRANCH == "master" ]]; then
export MCCY_TAG=latest
else
export MCCY_TAG=$CIRCLE_BRANCH
fi
else
export MCCY_TAG=$CIRCLE_TAG
fi
export BRANCH=${CIRCLE_BRANCH:-tag}
check_var CARINA_USERNAME
check_var CARINA_APIKEY
check_var MCCY_PASSWORD
check_var LETSENCRYPT_EMAIL
check_var LETSENCRYPT_DOMAIN
check_var MCCY_TAG
resolve_vars
set -e
#### SETUP credentials
mkdir -p $HOME/carina
docker pull itzg/carina-cli
docker run --name $$ -e CARINA_USERNAME -e CARINA_APIKEY itzg/carina-cli credentials $DEPLOY_CLUSTER
docker cp $$:/carina/clusters/$CARINA_USERNAME/$DEPLOY_CLUSTER/. $HOME/carina
if [[ $CIRCLECI != true ]]; then
docker rm $$ > /dev/null
fi
. $HOME/carina/docker.env
docker info
export DOCKER_HOST_URI=${DOCKER_HOST/tcp:/https:}
#### DEPLOY
COMPOSE_FILE=docker-compose-carina.yml
export COMPOSE_PROJECT_NAME="${BRANCH}"
docker-compose -f $COMPOSE_FILE pull
docker-compose --verbose -f $COMPOSE_FILE up -d
echo "
READY for use on the cluster $DEPLOY_CLUSTER
"
if [[ -v CIRCLE_ARTIFACTS ]]; then
cat <<EOF > $CIRCLE_ARTIFACTS/results.html
<html><body>
Ready for use on the cluster $DEPLOY_CLUSTER
</body></html>
EOF
fi