This repository was archived by the owner on Apr 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
examples/docker/devcontrol Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # @description Destroy the platform
4+ #
5+ # @example
6+ # destroy
7+ #
8+ # @arg $1 Task: "brief", "help" or "exec"
9+ #
10+ # @exitcode The exit code of the statements of the action
11+ # @exitcode 1 If the task is not implemented
12+ #
13+ # @stdout "Not implemented" message if the requested task is not implemented
14+ #
15+ function destroy() {
16+
17+ # Init
18+ local briefMessage=" Environment removal"
19+ local helpMessage=" Destroy the docker-compose platform and the data volumes using 'docker-compose down -v'"
20+
21+ # Task choosing
22+ case $1 in
23+ brief)
24+ showBriefMessage ${FUNCNAME[0]} " $briefMessage "
25+ ;;
26+ help)
27+ showHelpMessage ${FUNCNAME[0]} " $helpMessage "
28+ ;;
29+ exec)
30+ docker-compose down -v
31+ ;;
32+ * )
33+ showNotImplemtedMessage $1 ${FUNCNAME[0]}
34+ return 1
35+ esac
36+ }
37+
38+ # Main
39+ destroy " $@ "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # @description Access to a container console using bash
4+ #
5+ # @example
6+ # enter web
7+ #
8+ # @arg $1 Task: "brief", "help" or "exec"
9+ # @arg $2 Service: "web", "app" or "duing"
10+ #
11+ # @exitcode The exit status of the `docker-compose exec bash` command
12+ #
13+ # @stdout "Not implemented" message if the requested task is not implemented
14+ #
15+ function enter() {
16+
17+ # Init
18+ local briefMessage=" Enter with a console to a service: 'app' (default), 'db' or 'duing'"
19+ local helpMessage=" " " Use 'docker-compose' to exec a bash terminal in a service" " "
20+
21+ # Task choosing
22+ case $1 in
23+ brief)
24+ showBriefMessage ${FUNCNAME[0]} " $briefMessage "
25+ ;;
26+ help)
27+ showHelpMessage ${FUNCNAME[0]} " $helpMessage "
28+ ;;
29+ exec)
30+ service=$2
31+ docker-compose exec ${service} bash
32+ ;;
33+ * )
34+ showNotImplemtedMessage ${FUNCNAME[0]} $1
35+ return 1
36+ esac
37+ }
38+
39+ # Main
40+ enter " $@ "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # @description Show logs
4+ #
5+ # @example
6+ # logs
7+ #
8+ # @arg $1 Task: "brief", "help" or "exec"
9+ #
10+ # @exitcode The exit status of the statements of the action
11+ #
12+ # @stdout "Not implemented" message if the requested task is not implemented
13+ #
14+ function logs() {
15+
16+ # Init
17+ local briefMessage=" Show logs"
18+ local helpMessage=" Show logs of the containers of the platform using 'docker-compose logs'"
19+
20+ # Task choosing
21+ case $1 in
22+ brief)
23+ showBriefMessage ${FUNCNAME[0]} " $briefMessage "
24+ ;;
25+ help)
26+ showHelpMessage ${FUNCNAME[0]} " $helpMessage "
27+ ;;
28+ exec)
29+ docker-compose logs --tail=100 -f
30+ ;;
31+ * )
32+ showNotImplemtedMessage ${FUNCNAME[0]} $1
33+ return 1
34+ esac
35+ }
36+
37+ # Main
38+ logs " $@ "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # @description Start the platform
4+ #
5+ # @example
6+ # start
7+ #
8+ # @arg $1 Task: "brief", "help" or "exec"
9+ #
10+ # @exitcode The exit code of the statements of the action
11+ #
12+ # @stdout "Not implemented" message if the requested task is not implemented
13+ #
14+ function start() {
15+
16+ # Init
17+ local briefMessage=" Environment start and load initial data"
18+ local helpMessage=" Start the docker-compose platform"
19+
20+ # Task choosing
21+ case $1 in
22+ brief)
23+ showBriefMessage ${FUNCNAME[0]} " $briefMessage "
24+ ;;
25+ help)
26+ showHelpMessage ${FUNCNAME[0]} " $helpMessage "
27+ ;;
28+ exec)
29+ checkDocker
30+ docker-compose up -d
31+ ;;
32+ * )
33+ showNotImplemtedMessage $1 ${FUNCNAME[0]}
34+ return 1
35+ esac
36+ }
37+
38+ # Main
39+ start " $@ "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # @description Show status of the docker platform
4+ #
5+ # @example
6+ # status
7+ #
8+ # @arg $1 Task: "brief", "help" or "exec"
9+ #
10+ # @exitcode The exit code of the `docker-compose ps` command
11+ # @exitcode 1 If the task is not implemented
12+ #
13+ # @stdout "Not implemented" message if the requested task is not implemented
14+ #
15+ function status() {
16+
17+ # Init
18+ local briefMessage=" Get status of the local docker development environment"
19+ local helpMessage=" Execute the 'docker-compose ps' command"
20+
21+ # Task choosing
22+ case $1 in
23+ brief)
24+ showBriefMessage ${FUNCNAME[0]} " $briefMessage "
25+ ;;
26+ help)
27+ showHelpMessage ${FUNCNAME[0]} " $helpMessage "
28+ ;;
29+ exec)
30+ docker-compose ps
31+ ;;
32+ * )
33+ showNotImplemtedMessage ${FUNCNAME[0]} $1
34+ return 1
35+ esac
36+ }
37+
38+ # Main
39+ status " $@ "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # @description Stop the platform
4+ #
5+ # @example
6+ # stop
7+ #
8+ # @arg $1 Task: "brief", "help" or "exec"
9+ #
10+ # @exitcode The exit code of the statements of the action
11+ # @exitcode 1 If the task is not implemented
12+ #
13+ # @stdout "Not implemented" message if the requested task is not implemented
14+ #
15+ function stop() {
16+
17+ # Init
18+ local briefMessage=" Platform stop"
19+ local helpMessage=" Stop the docker-compose platform"
20+
21+
22+ # Task choosing
23+ case $1 in
24+ brief)
25+ showBriefMessage ${FUNCNAME[0]} " $briefMessage "
26+ ;;
27+ help)
28+ showHelpMessage ${FUNCNAME[0]} " $helpMessage "
29+ ;;
30+ exec)
31+ docker-compose stop
32+ ;;
33+ * )
34+ showNotImplemtedMessage $1 ${FUNCNAME[0]}
35+ return 1
36+ esac
37+ }
38+
39+ # Main
40+ stop " $@ "
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # @file devcontrol/global/startup.sh
4+ # @brief devcontrol startup script and functions
5+ echo " Devcontrol Docker Example (c) 2019"
6+ echo
7+
8+ # @description Check presence of docker-related pieces in the system
9+ # The function aborts the execution if the system dont have docker installed
10+ #
11+ # @example
12+ # checkDocker
13+ #
14+ # @noargs
15+ #
16+ # @exitcode 0 If docker exist, abort execution if other case and return 1 to the system
17+ #
18+ # @stdout Show "Docker not present. Exiting -" message if missing docker
19+ #
20+ function checkDocker() {
21+ which docker docker-compose > /dev/null 2>&1 || bash -c ' echo "Missing docker: aborting"; exit 1'
22+ }
23+ export -f checkDocker
You can’t perform that action at this time.
0 commit comments