diff --git a/README.md b/README.md index 81e3733..7f38cb4 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,28 @@ For start debugging in php-fpm, also in workspace `./stop-xdebug.sh` or `./stop-xdebug.sh 73` if you launch start with php-version 73 +#### Xdebug with profiler + +Profiler saved your profiles into `/tmp` directory in own container. + +In docker-compose.base.yml exists volume that represent `/tmp` directory to `./data/profiler`. +In this case `./data/profiler` must be have `777` chmod`s. + +For starting xdebug with profiler enable you might: + +`./start-xdebug.sh 74 1` + +Or + +`./start-xdebug.sh 74 profiler` if you like + +Second argument must be have any string + +For disable profiler - just simple launch + +`./quit-xdebug.sh` + + ### Mysql For import dumps from `hostfiles` directory you might be enter to mysql console: diff --git a/bash/quit-xdebug.sh b/bash/quit-xdebug.sh index 13bd61f..32dd4c9 100755 --- a/bash/quit-xdebug.sh +++ b/bash/quit-xdebug.sh @@ -2,8 +2,9 @@ DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)" PHP_VERSION=$1 # Without dot +WITH_PROFILER=$2 if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi -${DIR}/dockerfiles/php-fpm/xdebug.sh stop ${PHP_VERSION} -${DIR}/dockerfiles/workspace/xdebug.sh stop ${PHP_VERSION} \ No newline at end of file +${DIR}/dockerfiles/php-fpm/xdebug.sh stop ${PHP_VERSION} ${WITH_PROFILER} +${DIR}/dockerfiles/workspace/xdebug.sh stop ${PHP_VERSION} ${WITH_PROFILER} \ No newline at end of file diff --git a/bash/start-xdebug.sh b/bash/start-xdebug.sh index ae18fce..1fb94c6 100755 --- a/bash/start-xdebug.sh +++ b/bash/start-xdebug.sh @@ -2,8 +2,9 @@ DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)" PHP_VERSION=$1 # Without dot +WITH_PROFILER=$2 if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi -${DIR}/dockerfiles/php-fpm/xdebug.sh start ${PHP_VERSION} -${DIR}/dockerfiles/workspace/xdebug.sh start ${PHP_VERSION} +${DIR}/dockerfiles/php-fpm/xdebug.sh start ${PHP_VERSION} ${WITH_PROFILER} +${DIR}/dockerfiles/workspace/xdebug.sh start ${PHP_VERSION} ${WITH_PROFILER} diff --git a/docker-compose.base.yml b/docker-compose.base.yml index 6241fa5..e418a73 100755 --- a/docker-compose.base.yml +++ b/docker-compose.base.yml @@ -14,7 +14,7 @@ services: - "443:443" expose: - 80 - php-fpm: + php: build: context: ./dockerfiles/php-fpm args: @@ -27,6 +27,7 @@ services: restart: always volumes: - ${PROJECTS_DIR}:/usr/share/nginx/html + - ./data/profiler:/tmp expose: - 9000 workspace: diff --git a/docker-compose.yml.example b/docker-compose.yml.example index e0241a3..ab995e9 100755 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -12,13 +12,13 @@ services: php73: extends: file: docker-compose.base.yml - service: php-fpm + service: php build: dockerfile: php73.Dockerfile php74: extends: file: docker-compose.base.yml - service: php-fpm + service: php build: dockerfile: php74.Dockerfile workspace73: diff --git a/dockerfiles/php-fpm/xdebug.ini b/dockerfiles/php-fpm/xdebug.ini index 6981068..25c1f50 100644 --- a/dockerfiles/php-fpm/xdebug.ini +++ b/dockerfiles/php-fpm/xdebug.ini @@ -5,11 +5,11 @@ xdebug.remote_connect_back=1 xdebug.remote_port=9000 xdebug.idekey=PHPSTORM -xdebug.remote_autostart=1 -xdebug.remote_enable=1 +xdebug.remote_autostart=0 +xdebug.remote_enable=0 xdebug.cli_color=0 -xdebug.profiler_enable=1 -xdebug.profiler_enable_trigger=1 +xdebug.profiler_enable=0 +xdebug.profiler_enable_trigger=0 xdebug.profiler_output_dir=/tmp xdebug.remote_handler=dbgp diff --git a/dockerfiles/php-fpm/xdebug.sh b/dockerfiles/php-fpm/xdebug.sh index 2ec971b..3e2a732 100755 --- a/dockerfiles/php-fpm/xdebug.sh +++ b/dockerfiles/php-fpm/xdebug.sh @@ -3,6 +3,7 @@ # NOTE: At the moment, this has only been confirmed to work with PHP 7 PHP_VERSION=$2 # Without dot +WITH_PROFILER=$3 # Grab full name of php-fpm container PHP_FPM_CONTAINER=$(docker ps | grep php${PHP_VERSION} | awk '{print $1}') @@ -12,6 +13,10 @@ if [[ -z "${PHP_FPM_CONTAINER}" ]]; then exit 1 fi +if [[ ! -z "${WITH_PROFILER}" ]]; then + echo "With profiler option". +fi + # Grab OS type if [[ "$(uname)" == "Darwin" ]]; then OS_TYPE="OSX" @@ -43,6 +48,7 @@ xdebug_start () ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" REMOTE_AUTOSTART_CMD="sed -i 's/^xdebug.remote_autostart=0/xdebug.remote_autostart=1/g' /usr/local/etc/php/conf.d/xdebug.ini" REMOTE_ENABLE_CMD="sed -i 's/^xdebug.remote_enable=0/xdebug.remote_enable=1/g' /usr/local/etc/php/conf.d/xdebug.ini" + PROFILER_ENABLE_CDM="sed -i 's/^xdebug.profiler_enable=0/xdebug.profiler_enable=1/g' /usr/local/etc/php/conf.d/xdebug.ini" # If running on Windows, need to prepend with winpty :( if [[ $OS_TYPE == "MINGW" ]]; then @@ -52,12 +58,19 @@ xdebug_start () docker restart $PHP_FPM_CONTAINER winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + if [[ ! -z "${WITH_PROFILER}" ]]; then + winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_ENABLE_CDM}" + fi else docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}" docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_AUTOSTART_CMD}" docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_ENABLE_CMD}" docker restart $PHP_FPM_CONTAINER docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + + if [[ ! -z "${WITH_PROFILER}" ]]; then + docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_ENABLE_CDM}" + fi fi } @@ -70,6 +83,7 @@ xdebug_stop () OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" REMOTE_AUTOSTART_CMD="sed -i 's/^xdebug.remote_autostart=1/xdebug.remote_autostart=0/g' /usr/local/etc/php/conf.d/xdebug.ini" REMOTE_ENABLE_CMD="sed -i 's/^xdebug.remote_enable=1/xdebug.remote_enable=0/g' /usr/local/etc/php/conf.d/xdebug.ini" + PROFILER_DISABLE_CMD="sed -i 's/^xdebug.profiler_enable=1/xdebug.profiler_enable=0/g' /usr/local/etc/php/conf.d/xdebug.ini" # If running on Windows, need to prepend with winpty :( if [[ $OS_TYPE == "MINGW" ]]; then @@ -82,7 +96,7 @@ xdebug_stop () docker restart $PHP_FPM_CONTAINER #docker-compose restart php-fpm winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' - + winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_DISABLE_CMD}" else docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}" docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_AUTOSTART_CMD}" @@ -90,6 +104,7 @@ xdebug_stop () # docker-compose restart php-fpm docker restart $PHP_FPM_CONTAINER docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' + docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_DISABLE_CMD}" fi } diff --git a/dockerfiles/workspace/workspace74.Dockerfile b/dockerfiles/workspace/workspace74.Dockerfile index 0c4bdc2..314c133 100644 --- a/dockerfiles/workspace/workspace74.Dockerfile +++ b/dockerfiles/workspace/workspace74.Dockerfile @@ -40,28 +40,28 @@ USER laradock COPY ./minio/auth.json /home/laradock/.mc/config.json ########################################################################### -# Crontab +# Install custom node version ########################################################################### USER root -COPY ./crontab74 /etc/cron.d +ARG CUSTOM_NODE_VERSION +ENV CUSTOM_NODE_VERSION ${CUSTOM_NODE_VERSION} -RUN chmod -R 644 /etc/cron.d +RUN if [ ! -z "${CUSTOM_NODE_VERSION}" ]; then \ + . ~/.bashrc && nvm install ${CUSTOM_NODE_VERSION} \ + && . ~/.bashrc && nvm alias default ${CUSTOM_NODE_VERSION} \ + && cp -R ~/.nvm/alias /home/laradock/.nvm \ + && cp -R ~/.nvm/versions /home/laradock/.nvm \ + && chown -R ${CUSTOM_PUID}:${CUSTOM_PGID} /home/laradock/.nvm \ +;fi ########################################################################### -# Install custom node version +# Crontab ########################################################################### USER root -ARG CUSTOM_NODE_VERSION -ENV CUSTOM_NODE_VERSION ${CUSTOM_NODE_VERSION} +COPY ./crontab74 /etc/cron.d -RUN if [ ${CUSTOM_NODE_VERSION} = true ]; then \ - . ~/.bashrc && nvm install lts/erbium \ - && . ~/.bashrc && nvm alias default lts/erbium \ - && cp -R ~/.nvm/alias /home/laradock/.nvm \ - && cp -R ~/.nvm/versions /home/laradock/.nvm \ - && chown -R ${CUSTOM_PUID}:${CUSTOM_PGID} /home/laradock/.nvm \ -;fi \ No newline at end of file +RUN chmod -R 644 /etc/cron.d \ No newline at end of file