-
Notifications
You must be signed in to change notification settings - Fork 5
/
dockerize.sh
executable file
·79 lines (64 loc) · 2.43 KB
/
dockerize.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
#!/bin/bash
mkdir -p ./vendor/bin
#if [ ! -f ./vendor/bin/composer ]; then
echo "Downloading phpexperts/dockerize's php CLI launcher..."
curl https://raw.githubusercontent.com/PHPExpertsInc/dockerize/v10.0/bin/composer -o vendor/bin/composer
echo "Downloading phpexperts/dockerize's composer CLI launcher..."
curl https://raw.githubusercontent.com/PHPExpertsInc/dockerize/v10.0/bin/php -o vendor/bin/php
#cp -v /code/dockerize/bin/php vendor/bin/php
chmod 0755 ./vendor/bin/composer ./vendor/bin/php
#fi
hash -r
# @see https://linuxize.com/post/how-to-check-if-string-contains-substring-in-bash/
# @see https://github.com/composer/composer/issues/10389
SUB="/vendor/"
if [[ "$0" == *"$SUB"* ]]; then
ROOT="$(readlink -f /proc/$PPID/cwd)"
else
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
fi
if ! echo $PATH | grep -q ./vendor/bin; then
echo 'You do not have ./vendor/bin in your $PATH.'
echo 'Modern PHP apps and phpexperts/dockerize require this.'
if [ ! -f ${HOME}/.bashrc ]; then
echo "ERROR: It doesn't look like you are using bash (no ~/.bashrc file)."
echo " Please add ./vendor/bin to the PATH manually."
exit 1
fi
echo ''
echo -n 'May I add it to the front of your $PATH? (y/n) '
read YES_OR_NO
echo ''
if [ $YES_OR_NO == 'y' ]; then
echo 'Adding ./vendor/bin to your $PATH'
echo '# Added by phpexperts/dockerize' >> ~/.bashrc
echo 'PATH=./vendor/bin:$PATH' >> ~/.bashrc
echo 'Your $PATH has been updated. You need you start a new shell now.'
exit 2
else
echo "You can run Dockerized PHP manually:"
echo ""
echo " ./vendor/bin/php"
echo " ./vendor/bin/composer"
fi
fi
ORIG_PHP_VERSION=$PHP_VERSION
if [ -f "${ROOT}/.env" ]; then
source "${ROOT}/.env"
if [ ! -z "$ORIG_PHP_VERSION" ]; then
PHP_VERSION="$ORIG_PHP_VERSION"
fi
fi
if [ -z "$PHP_VERSION" ]; then
PHP_VERSION="8.1"
fi
#echo "PHP Version: $PHP_VERSION"
vendor/bin/composer show phpexperts/dockerize > /dev/null 2>&1 || vendor/bin/composer require --ignore-platform-reqs --dev phpexperts/dockerize
export PHP_VERSION=8.3
#cp -v /code/dockerize/bin/php vendor/bin/php
vendor/bin/php --version
#cp -v /code/dockerize/install.php vendor/phpexperts/dockerize/install.php
if [ ! -f docker-compose.yml ]; then
vendor/bin/php dockerize
fi
#script -qc "/usr/bin/php vendor/phpexperts/dockerize/install.php" typescript