forked from cloudfoundry/cloud_controller_ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv.sh
executable file
·121 lines (109 loc) · 3.12 KB
/
devenv.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
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
111
112
113
114
115
116
117
118
119
120
121
#/bin/bash
set -eu
trap "pkill -P $$" EXIT
# Help text
help_command() {
echo "Usage: $0 COMMAND"
echo ""
echo "Commands:"
echo " create - Setting up the development environment(containers)"
echo " start - Starting the development environment(containers), a existing fully set up set of containers must exist."
echo " stop - Stopping but not removing the development environment(containers)"
echo " destroy - Stopping and removing the development environment(containers)"
echo " runconfigs - Copies matching run configurations for Intellij and VS Code into the respective folders"
echo " help - Print this help text"
}
# Create a clean development environment
create_command(){
docker-compose -p "" down
docker buildx bake -f docker-compose.yml &
docker-compose -p "" pull &
wait $(jobs -p)
docker-compose -p "" up -d --build
./.devcontainer/scripts/setupDevelopmentEnvironment.sh
}
# Start containers
start_command(){
docker-compose -p "" start
}
# Stop containers
stop_command(){
docker-compose -p "" stop
}
# Remove containers
destroy_command(){
docker-compose -p "" down
}
# Call Setup IDEs Script
runconfigs_command(){
./.devcontainer/scripts/setupIDEs.sh
echo """
# In case you want the recommended extentions for VSCode(needed for debug, follow code symbols etc.), execute:
code --install-extension ms-azuretools.vscode-docker
code --install-extension oderwat.indent-rainbow
code --install-extension 2gua.rainbow-brackets
code --install-extension KoichiSasada.vscode-rdbg
code --install-extension Fooo.ruby-spec-runner
code --install-extension castwide.solargraph
code --install-extension eamodio.gitlens
code --install-extension github.vscode-github-actions
"""
}
# Error handler
handle_error() {
echo "Error: Invalid command"
help_command
exit 1
}
# Handle no command specified
if [ $# -eq 0 ]; then
handle_error
fi
# Check Prerequisites
export should_exit=0
# Check Path Exists
for p in docker docker-compose ruby bundle mysql psql yq; do
if ! command -v "${p}" >/dev/null 2>&1; then
echo "Error: Dependency \"$p\" is not installed" && export should_exit=1
fi
done
# Check execution as ruby might set a shim
# shellcheck disable=SC2043
for p in uaac; do
if ! eval "${p} --version" >/dev/null 2>&1; then
echo "Error: Dependency \"$p\" is not installed" && export should_exit=1
fi
done
if [ $should_exit != 0 ]; then
exit 1
fi
# Parse commands
case "$1" in
create)
echo "Setting up the development environment(containers)"
create_command
;;
start)
echo "Starting the development environment(containers), a existing fully set up set of containers must exist."
start_command
;;
stop)
echo "Stopping but not removing the development environment(containers)"
stop_command
;;
destroy)
echo "Stopping and removing the development environment(containers)"
destroy_command
;;
runconfigs)
echo "Copying matching run configurations for intellij and vscode into the respective folders"
runconfigs_command
;;
help)
help_command
;;
*)
handle_error
;;
esac
trap "" EXIT