-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlaravel-sail
53 lines (45 loc) · 1.51 KB
/
laravel-sail
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
#!/bin/sh
# Colors
NC='\033[0m'
BBlue='\033[1;34m'
BRed='\033[1;33m'
phpVersions=$(grep -o '"php": "[^"]*' composer.json | grep -o '[^"]*$' | sed 's/\^*\.*//g')
IFS='|' read -ra PHPVERSION <<<"$phpVersions"
max=${PHPVERSION[0]}
for i in "${PHPVERSION[@]}"; do
if [ "$((i > max))" -ne 0 ]; then
max=$i
fi
done
phpVersion=$(echo $max | cut -c 1-2)
docker info > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "${BRed}Docker is not running.${NC}"
exit 1
fi
echo "\n${BBlue}Installing Laravel Sail${NC}\n"
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
"laravelsail/php$phpVersion-composer:latest" \
bash -c "composer require laravel/sail --dev --no-cache" \
composer install --ignore-platform-reqs
echo "\n${BBlue}Installing PHP Packages${NC}\n"
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
"laravelsail/php$phpVersion-composer:latest" \
composer install --ignore-platform-reqs --no-cache
echo "\n${BRed}Which database would you like to use? [mysql]\n${NC}"
echo " [0] mysql\n [1] pgsql\n [2] mariadb\n"
read DATABASE
databases=(mysql pgsql mariadb)
echo "\n${BBlue}Creating the docker-composer.yml file (with ${databases[DATABASE]}, redis, and mailhog)\n${NC}"
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
"laravelsail/php$phpVersion-composer:latest" \
bash -c "php artisan sail:install --with=${databases[DATABASE]},redis,mailhog"