-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxc
executable file
·109 lines (90 loc) · 2.2 KB
/
xc
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
#!/bin/bash
action_exec() {
shift 1
$COMPOSE exec $@
}
action_artisan() {
shift 1
$COMPOSE exec laravel php /var/www/html/artisan $@
}
action_composer() {
shift 1
docker run --rm -it \
-v "$(pwd)":/var/www/html \
--workdir /var/www/html \
--entrypoint composer \
composer:latest \
--ignore-platform-reqs \
$@
}
action_node() {
shift 1
$COMPOSE run --rm node $@
}
action_up() {
shift 1
$COMPOSE up laravel --remove-orphans $@
}
action_up_hmr() {
shift 1
$COMPOSE -f docker-compose.hmr.dev.yml up laravel hmr --remove-orphans $@
}
action_down() {
shift 1
$COMPOSE down $@
}
action_install() {
docker run --rm -it \
-v "$(pwd)"/laravel-temp:/var/www/html \
--workdir /var/www/html \
--entrypoint composer \
composer:latest \
--ignore-platform-reqs \
create-project laravel/laravel . \
&& sudo chown -R $(id -u):$(id -g) laravel-temp \
&& cp -r laravel-temp/. "$(pwd)" \
&& sudo rm -rf laravel-temp
}
main() {
## Set defaults for our environment
COMPOSE_FILE="dev" #Default the Dev file to be used
# Set up our structure for our re-used commands
COMPOSE="docker compose -f docker-compose.yml -f docker-compose.$COMPOSE_FILE.yml"
# Check that an argument is passed
if [ $# -gt 0 ]; then
# Check the first argument and pass the user to proper action,
# Only some actions need arguments passed.
case $1 in
exec)
action_exec "$@"
;;
artisan)
action_artisan "$@"
;;
composer)
action_composer "$@"
;;
node)
action_node "$@"
;;
up)
action_up "$@"
;;
uphmr)
action_up_hmr "$@"
;;
down)
action_down "$@"
;;
install)
action_install
;;
*)
echo "\"$1\" is not a valid command."
;;
esac
else
echo "Command not defined"
fi
}
main "$@"