11#! /usr/bin/env bash
22
33function main() {
4- local xampp=$( dirname " $0 " ) / name=${PWD##*/ }
4+ local xampp=$( dirname " $0 " ) / name=${PWD##*/ } version=latest env=prod run=1 i volumes mounts rm share
5+ share=" $HOME " /.local/share/xampp/" $name "
6+
7+ mkdir -p " $share "
8+ touch " $share " /.bash_history
9+ mounts=" $mounts --mount type=bind,source=$share /.bash_history,target=/home/app/.bash_history"
510
6- local i version=latest env=prod rm run=YES
711 for i in " $@ "
812 do
913 case $i in
@@ -19,13 +23,20 @@ function main() {
1923
2024 --rm)
2125 run=
22- rm=YES
26+ rm=1
2327 shift
2428 ;;
2529
2630 --restart)
27- run=YES
28- rm=YES
31+ rm=1
32+ shift
33+ ;;
34+
35+ --mount-vendor)
36+ rm=1
37+ mkdir -p " $share " /vendor
38+ mkdir -p " $( pwd) " /vendor
39+ mounts=" $mounts --mount type=bind,source=$share /vendor,target=/app/vendor"
2940 shift
3041 ;;
3142
@@ -50,8 +61,8 @@ function main() {
5061 mkdir -p ~ /.ssh
5162
5263 # mount directories' symbolic links which are outside of the base directory as volumes to the container
53- local base=${PWD} volumes link candidate relative
54- local host=$( ip -4 addr show scope global dev docker0 | grep inet | awk ' {print $2}' | cut -d / -f 1)
64+ local base=${PWD} link candidate relative host
65+ host=$( ip -4 addr show scope global dev docker0 | grep inet | awk ' {print $2}' | cut -d / -f 1)
5566
5667 for link in $( find " ${base} " -type l) ; do
5768 candidate=$( readlink -f " ${link} " )
@@ -61,9 +72,6 @@ function main() {
6172 }
6273 done ;
6374
64- mkdir -p ~ /.local/share/xampp/" $name "
65- touch ~ /.local/share/xampp/" $name " /.bash_history
66-
6775 docker start " $name " 2> /dev/null || docker run -td --rm --net local \
6876 --name " $name " \
6977 --hostname " $name " \
@@ -90,20 +98,20 @@ function main() {
9098 --env WEB_DOCUMENT_ROOT=/app \
9199 --env WEB_ALIAS_DOMAIN=" *.localhost" \
92100 --env PHP_IDE_CONFIG=" serverName=app" \
93- --env COMPOSER_ALLOW_XDEBUG=1 \
101+ --env COMPOSER_ALLOW_XDEBUG=0 \
94102 --env XDEBUG_PROFILER_ENABLE_TRIGGER=1 \
95103 --env XDEBUG_CONFIG=" idekey=phpstorm" \
96104 --env XDEBUG_REMOTE_HOST=" $host " \
97105 --env DOCKER_XAMPP_BIN_ENV=" $env " \
98106 --env ACCOUNT=" http://$name .localhost" \
99- --volume ~ /.local/share/xampp/" $name " /.bash_history:/home/app/.bash_history \
100107 --volume ~ /.composer:/home/app/.composer \
101108 --volume ~ /.npm:/home/app/.npm \
102109 --volume ~ /.gitconfig:/home/app/.gitconfig:ro \
103110 --volume ~ /.ssh:/home/app/.ssh:ro \
104111 --volume $( pwd) :/app \
105112 --volume $( pwd) :/opt/project \
106113 $volumes \
114+ $mounts \
107115 " $@ " \
108116 " xampp/app:$version "
109117
0 commit comments