Skip to content

Instantly share code, notes, and snippets.

@wellic
Last active February 26, 2021 10:41
Show Gist options
  • Save wellic/33d8c9d4b87826da0893aab26372fbaf to your computer and use it in GitHub Desktop.
Save wellic/33d8c9d4b87826da0893aab26372fbaf to your computer and use it in GitHub Desktop.
Console debug from docker
#/usr/bin/env sh
SERVER_NAME=localhost \
SERVER_PORT=80 \
XDEBUG_CONFIG="PHPSTORM" \
php -dxdebug.remote_host=`ip route show default | awk '{print $3}'` \
$@
#Usage:
#c_xdebug.sh script.php.
#useful info:
#ip route show default | awk '{print $3}'
#ip route show | awk '/default/{print $3}'
# for debuging on remote server
# ssh -R 9000:localhost:9000 user@server
# check: /etc/ssh/sshd_config
# GatewayPorts yes
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND="noninteractive"
WORKDIR /tmp
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository ppa:ondrej/php \
&& add-apt-repository ppa:ondrej/apache2 \
&& apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y curl wget iproute2 zip vim
# https://launchpad.net/~ondrej/+archive/ubuntu/php?field.series_filter=focal
# install php, php modules and apache
RUN apt-get install -y apache2 \
php5.6 php5.6-dev php5.6-xdebug \
php5.6-apcu php5.6-bcmath php5.6-bz2 \
php5.6-curl php5.6-enchant php5.6-gd \
php5.6-gmp php5.6-imap php5.6-json \
php5.6-mailparse php5.6-mbstring php5.6-mcrypt \
php5.6-mysql php5.6-readline php5.6-xml php5.6-soap \
php5.6-sqlite3 php5.6-ssh2 php5.6-tidy \
php5.6-xmlrpc php5.6-xsl php5.6-opcache \
php5.6-zip
# source apache environment variables
RUN . /etc/apache2/envvars
# Install PHPUnit
RUN wget -O phpunit https://phar.phpunit.de/phpunit-5.phar \
&& chmod +x phpunit \
&& mv phpunit /usr/bin
# install log4php from source
# https://logging.apache.org/log4php/install.html
# http://www.gtlib.gatech.edu/pub/apache/logging/log4php/
RUN curl -O --ipv4 http://www.gtlib.gatech.edu/pub/apache/logging/log4php/2.3.0/apache-log4php-2.3.0-src.tar.gz \
&& tar xf apache-log4php-2.3.0-src.tar.gz \
&& mkdir -p /usr/share/php/log4php \
&& cp -r apache-log4php-2.3.0/src/main/php/* /usr/share/php/log4php \
&& rm -fr apache-log4php-2.3.0*
# deploy xdebug settings
COPY c_xdebug.sh /usr/local/bin/c_xdebug.sh
RUN chmod +x /usr/local/bin/c_xdebug.sh
COPY xdebug.ini /etc/php/5.6/cli/conf.d/xdebug.ini
COPY xdebug.ini /etc/php/5.6/apache2/conf.d/xdebug.ini
[xdebug]
;zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.idekey=PHPSTORM
xdebug.remote_enable = 1
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
;xdebug.remote_host=127.0.0.1
;xdebug.remote_port=9000
;xdebug.remote_log= "/tmp/xdebug_remote.log"
;xdebug.profiler_enable=1
;xdebug.profiler_output_dir=/data/tmp/snapshots
;xdebug.profiler_enable_trigger=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment