-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdock
executable file
·144 lines (125 loc) · 3.33 KB
/
dock
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
#######################################
# FUNCTIONS
#######################################
# Run an Artisan command
artisan () {
docker compose run --rm artisan "${@:1}"
}
# Build all of the images or the specified one
build () {
docker compose build "${@:1}"
}
# Run a Composer command
composer () {
docker compose run --rm composer "${@:1}"
}
# Run a NPM Command
npm () {
docker compose run --rm --service-ports npm "${@:1}"
}
# Run a Pest Command
pest () {
docker compose run --rm pest "${@:1}"
}
# Run a Pint Command
pint () {
docker compose run --rm pint "${@:1}"
}
# Run PHPStan Command
phpstan () {
docker compose run --rm phpstan analyse --memory-limit=2G "${@:1}"
}
# Remove the entire Docker environment
destroy () {
read -p "This will delete containers, volumes and images. Are you sure? [y/N]: " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit; fi
docker compose down -v --rmi all --remove-orphans
}
# Stop and destroy all containers
down () {
docker compose down "${@:1}"
}
# Display and tail the logs of all containers or the specified one's
logs () {
docker compose logs -f "${@:1}"
}
# Restart the containers
restart () {
stop && start
}
# Start the containers
start () {
docker compose up
}
# Stop the containers
stop () {
docker compose stop
}
case "$1" in
artisan)
artisan "${@:2}"
;;
build)
build "${@:2}"
;;
composer)
composer "${@:2}"
;;
npm)
npm "${@:2}"
;;
pest)
pest "${@:2}"
;;
pint)
pint "${@:2}"
;;
phpstan)
phpstan "${@:2}"
;;
destroy)
destroy
;;
down)
down "${@:2}"
;;
logs)
logs "${@:2}"
;;
restart)
restart
;;
start)
start
;;
stop)
stop
;;
*)
cat << EOF
Command line interface for the Docker-based web development environment.
Usage:
dock <command> [options] [arguments]
Available commands:
artisan ................................... Run an Artisan command
build [image] ............................. Build all of the images or the specified one
composer .................................. Run a Composer command
pest ...................................... Run Pest
npm ....................................... Run NPM
pint ...................................... Run Pint
phpstan ................................... Run Phpstan
destroy ................................... Remove the entire Docker environment
down [-v] ................................. Stop and destroy all containers
Options:
-v .................... Destroy the volumes as well
init ...................................... Initialise the Docker environment and the application
logs [container] .......................... Display and tail the logs of all containers or the specified one's
restart ................................... Restart the containers
start ..................................... Start the containers
stop ...................................... Stop the containers
update .................................... Update the Docker environment
EOF
exit 1
;;
esac