-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·110 lines (90 loc) · 2.41 KB
/
run.sh
File metadata and controls
executable file
·110 lines (90 loc) · 2.41 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
#
# This script starts and stops the CloudForest instance. It manages user options and
# runs the necessary docker-compose configuration.
#
print_help () {
cat << EOF
Usage: ./run_it.sh [--tag tag_name] [--sftp] [--follow]
--tag <tag_name>
Run an image from the cloudforestphylo/cloudforestgalaxy:latest
repository with the tag <tag_name>. Use latest for the most recent build from master.
--sftp
Enable SFTP on 127.0.0.1:8022. Warning: the current implementation of
SFTP allows any users to access all SFTP files, so it should only be used in local,
single-user contexts.
--follow
Output logs after starting the container.
--stop
Bring down the CloudForest service
--usage
--help
Display this message.
EOF
}
# Don't allow sftp by default because its implementation in galaxy-docker is insecure.
# Should only be used for local instances
ALLOW_SFTP=false
# Follow log output after running container.
FOLLOW_LOGS=false
# Are we bringing the CloudForest down.
STOP_CONTAINER=false
# Optional arguments before the required tag and container name
while [[ $# -gt 0 ]]; do
case $1 in
"--sftp")
ALLOW_SFTP=true
shift
;;
"--tag")
shift
export CLOUDFOREST_TAG=$1
shift
;;
"--follow")
FOLLOW_LOGS=true
shift
;;
"--stop")
STOP_CONTAINER=true
shift
;;
"--help"|"--usage")
print_help
exit 0
;;
*)
echo "Error: unrecognized option: $1"
exit 1
;;
esac
done
# Create .env file if it doesn't exist
if [[ ! -f .env ]]; then
cp .env.example .env
fi
COMPOSE_FILE_ARGS=" -f docker-compose.yml"
if [[ $ALLOW_SFTP == "true" ]]; then
COMPOSE_FILE_ARGS="$COMPOSE_FILE_ARGS -f docker-compose-sftp.yml "
fi
if [[ ! -z $CLOUDFOREST_TAG ]]; then
COMPOSE_FILE_ARGS="$COMPOSE_FILE_ARGS -f docker-compose-remote.yml"
docker-compose $COMPOSE_FILE_ARGS pull cloudforest
else
COMPOSE_BUILD_ARGS="--build"
fi
if [[ $STOP_CONTAINER == "true" ]]; then
docker-compose $COMPOSE_FILE_ARGS down
exit 0
fi
# Read CRA credentials
read -p "CRA username: " TS_CRA_USERNAME
read -s -p "CRA password (characters will not be displayed as you type): " TS_CRA_PASSWORD
echo
export TS_CRA_USERNAME
export TS_CRA_PASSWORD
# Bring up service with docker-compose.
docker-compose $COMPOSE_FILE_ARGS up -d $COMPOSE_BUILD_ARGS
if [[ $FOLLOW_LOGS == "true" ]]; then
docker logs -f "$CONTAINER_NAME"
fi