Browse Source

+ profiler things

* fix custom node version install in workspace
master
parent
commit
3535a09ce9
  1. 22
      README.md
  2. 5
      bash/quit-xdebug.sh
  3. 5
      bash/start-xdebug.sh
  4. 3
      docker-compose.base.yml
  5. 4
      docker-compose.yml.example
  6. 8
      dockerfiles/php-fpm/xdebug.ini
  7. 17
      dockerfiles/php-fpm/xdebug.sh
  8. 26
      dockerfiles/workspace/workspace74.Dockerfile

22
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 `./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 ### Mysql
For import dumps from `hostfiles` directory you might be enter to mysql console: For import dumps from `hostfiles` directory you might be enter to mysql console:

5
bash/quit-xdebug.sh

@ -2,8 +2,9 @@
DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)" DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)"
PHP_VERSION=$1 # Without dot PHP_VERSION=$1 # Without dot
WITH_PROFILER=$2
if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi 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}
${DIR}/dockerfiles/php-fpm/xdebug.sh stop ${PHP_VERSION} ${WITH_PROFILER}
${DIR}/dockerfiles/workspace/xdebug.sh stop ${PHP_VERSION} ${WITH_PROFILER}

5
bash/start-xdebug.sh

@ -2,8 +2,9 @@
DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)" DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)"
PHP_VERSION=$1 # Without dot PHP_VERSION=$1 # Without dot
WITH_PROFILER=$2
if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=74; fi 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}

3
docker-compose.base.yml

@ -14,7 +14,7 @@ services:
- "443:443" - "443:443"
expose: expose:
- 80 - 80
php-fpm:
php:
build: build:
context: ./dockerfiles/php-fpm context: ./dockerfiles/php-fpm
args: args:
@ -27,6 +27,7 @@ services:
restart: always restart: always
volumes: volumes:
- ${PROJECTS_DIR}:/usr/share/nginx/html - ${PROJECTS_DIR}:/usr/share/nginx/html
- ./data/profiler:/tmp
expose: expose:
- 9000 - 9000
workspace: workspace:

4
docker-compose.yml.example

@ -12,13 +12,13 @@ services:
php73: php73:
extends: extends:
file: docker-compose.base.yml file: docker-compose.base.yml
service: php-fpm
service: php
build: build:
dockerfile: php73.Dockerfile dockerfile: php73.Dockerfile
php74: php74:
extends: extends:
file: docker-compose.base.yml file: docker-compose.base.yml
service: php-fpm
service: php
build: build:
dockerfile: php74.Dockerfile dockerfile: php74.Dockerfile
workspace73: workspace73:

8
dockerfiles/php-fpm/xdebug.ini

@ -5,11 +5,11 @@ xdebug.remote_connect_back=1
xdebug.remote_port=9000 xdebug.remote_port=9000
xdebug.idekey=PHPSTORM xdebug.idekey=PHPSTORM
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.cli_color=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.profiler_output_dir=/tmp
xdebug.remote_handler=dbgp xdebug.remote_handler=dbgp

17
dockerfiles/php-fpm/xdebug.sh

@ -3,6 +3,7 @@
# NOTE: At the moment, this has only been confirmed to work with PHP 7 # NOTE: At the moment, this has only been confirmed to work with PHP 7
PHP_VERSION=$2 # Without dot PHP_VERSION=$2 # Without dot
WITH_PROFILER=$3
# Grab full name of php-fpm container # Grab full name of php-fpm container
PHP_FPM_CONTAINER=$(docker ps | grep php${PHP_VERSION} | awk '{print $1}') PHP_FPM_CONTAINER=$(docker ps | grep php${PHP_VERSION} | awk '{print $1}')
@ -12,6 +13,10 @@ if [[ -z "${PHP_FPM_CONTAINER}" ]]; then
exit 1 exit 1
fi fi
if [[ ! -z "${WITH_PROFILER}" ]]; then
echo "With profiler option".
fi
# Grab OS type # Grab OS type
if [[ "$(uname)" == "Darwin" ]]; then if [[ "$(uname)" == "Darwin" ]]; then
OS_TYPE="OSX" 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" 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_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" 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 running on Windows, need to prepend with winpty :(
if [[ $OS_TYPE == "MINGW" ]]; then if [[ $OS_TYPE == "MINGW" ]]; then
@ -52,12 +58,19 @@ xdebug_start ()
docker restart $PHP_FPM_CONTAINER docker restart $PHP_FPM_CONTAINER
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' 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 else
docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}" 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_AUTOSTART_CMD}"
docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_ENABLE_CMD}" docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_ENABLE_CMD}"
docker restart $PHP_FPM_CONTAINER docker restart $PHP_FPM_CONTAINER
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' 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 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" 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_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" 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 running on Windows, need to prepend with winpty :(
if [[ $OS_TYPE == "MINGW" ]]; then if [[ $OS_TYPE == "MINGW" ]]; then
@ -82,7 +96,7 @@ xdebug_stop ()
docker restart $PHP_FPM_CONTAINER docker restart $PHP_FPM_CONTAINER
#docker-compose restart php-fpm #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 'php -v'
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_DISABLE_CMD}"
else else
docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}" docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}"
docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_AUTOSTART_CMD}" docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_AUTOSTART_CMD}"
@ -90,6 +104,7 @@ xdebug_stop ()
# docker-compose restart php-fpm # docker-compose restart php-fpm
docker restart $PHP_FPM_CONTAINER docker restart $PHP_FPM_CONTAINER
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_DISABLE_CMD}"
fi fi
} }

26
dockerfiles/workspace/workspace74.Dockerfile

@ -40,28 +40,28 @@ USER laradock
COPY ./minio/auth.json /home/laradock/.mc/config.json COPY ./minio/auth.json /home/laradock/.mc/config.json
########################################################################### ###########################################################################
# Crontab
# Install custom node version
########################################################################### ###########################################################################
USER root 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 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
RUN chmod -R 644 /etc/cron.d
Loading…
Cancel
Save