Skip to content

Commit a6f4642

Browse files
committed
Merge branch 'develop'
2 parents 71d47e1 + 5bfadbf commit a6f4642

File tree

6 files changed

+145
-31
lines changed

6 files changed

+145
-31
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build.log
22
docker-compose.yml
3+
local/*
4+
!local/*.dist

Dockerfile

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM andrewholgate/drupal-php70:0.3.0
1+
FROM andrewholgate/drupal-php70:0.4.0
22
MAINTAINER Andrew Holgate <[email protected]>
33

44
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
@@ -8,46 +8,39 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
88
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-sphinx python-pip doxygen && \
99
DEBIAN_FRONTEND=noninteractive pip install sphinx_rtd_theme breathe
1010

11-
# Install XDebug 2.4.0 RC3
12-
RUN wget https://github.com/xdebug/xdebug/archive/XDEBUG_2_4_0RC3.tar.gz && \
13-
tar zxvf XDEBUG_2_4_0RC3.tar.gz && \
14-
rm -f XDEBUG_2_4_0RC3.tar.gz && \
15-
cd xdebug-XDEBUG_2_4_0RC3 && \
11+
# XML needed by PHPCodeSniffer 2.3+ and other developer tools.
12+
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install php7.0-xml
13+
14+
# Install XDebug 2.4.0
15+
RUN wget https://github.com/xdebug/xdebug/archive/XDEBUG_2_4_0RC4.tar.gz && \
16+
tar zxvf XDEBUG_2_4_0RC4.tar.gz && \
17+
rm -f XDEBUG_2_4_0RC4.tar.gz && \
18+
cd xdebug-XDEBUG_2_4_0RC4 && \
1619
phpize && \
1720
./configure --enable-xdebug && \
1821
make && \
1922
cp modules/xdebug.so /usr/lib/php/20151012/ && \
20-
rm -Rf ../xdebug-XDEBUG_2_4_0RC3
23+
rm -Rf ../xdebug-XDEBUG_2_4_0RC4
2124

2225
COPY xdebug.ini /etc/php/mods-available/xdebug.ini
23-
RUN ln -s /etc/php/mods-available/xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini
2426
RUN ln -s /etc/php/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini
27+
COPY xdebug /usr/local/bin/xdebug
28+
RUN chmod +x /usr/local/bin/xdebug
29+
2530
# Symlink log files.
2631
RUN ln -s /var/log/xdebug/xdebug.log /var/www/log/
2732

28-
# Install XHProf
29-
#RUN wget https://github.com/phacility/xhprof/archive/master.tar.gz && \
30-
# tar zxvf master.tar.gz && \
31-
# rm -f master.tar.gz
32-
# cd xhprof-master/extension/ && \
33-
# phpize && \
34-
# ./configure --with-php-config=/usr/bin/php-config7.0 && \
35-
# make && \
36-
# make install && \
37-
# make test && \
38-
# rm -Rf ../xhprof-master
39-
4033
# Install JRE (needed for some testing tools like sitespeed.io) and libs for PhantomJS.
4134
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install default-jre libfreetype6 libfontconfig
4235

43-
# Install Node 4.2.4 LTS
36+
# Install Node 4.3.1 LTS
4437
RUN cd /opt && \
45-
wget https://nodejs.org/dist/v4.2.4/node-v4.2.4-linux-x64.tar.gz && \
46-
tar -xzf node-v4.2.4-linux-x64.tar.gz && \
47-
mv node-v4.2.4-linux-x64 node && \
38+
wget https://nodejs.org/dist/v4.3.1/node-v4.3.1-linux-x64.tar.gz && \
39+
tar -xzf node-v4.3.1-linux-x64.tar.gz && \
40+
mv node-v4.3.1-linux-x64 node && \
4841
cd /usr/local/bin && \
4942
ln -s /opt/node/bin/* . && \
50-
rm -f /opt/node-v4.2.4-linux-x64.tar.gz
43+
rm -f /opt/node-v4.3.1-linux-x64.tar.gz
5144

5245
USER ubuntu
5346
RUN echo 'export PATH="$PATH:$HOME/.npm-packages/bin"' >> ~/.bashrc && \
@@ -66,6 +59,19 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get -y install imagemagick && \
6659
# Front-end tools
6760
RUN npm install -g phantomjs
6861

62+
# Install XHProf
63+
RUN wget https://github.com/RustJason/xhprof/archive/php7.tar.gz && \
64+
tar zxvf php7.tar.gz && \
65+
rm -f php7.tar.gz && \
66+
cd xhprof-php7/extension/ && \
67+
phpize && \
68+
./configure --with-php-config=/usr/bin/php-config7.0 && \
69+
make && \
70+
sudo make install && \
71+
rm -Rf ../xhprof-php7
72+
# Tests fail:
73+
# make test && \
74+
6975
# Turn on PHP error reporting
7076
RUN sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php/7.0/fpm/php.ini && \
7177
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php/7.0/cli/php.ini && \
@@ -76,7 +82,9 @@ RUN sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php/7.0/fpm
7682
sed -ri 's/^track_errors\s*=\s*Off/track_errors = On/g' /etc/php/7.0/fpm/php.ini && \
7783
sed -ri 's/^track_errors\s*=\s*Off/track_errors = On/g' /etc/php/7.0/cli/php.ini && \
7884
sed -ri 's/^;xmlrpc_errors\s*=\s*0/xmlrpc_errors = 1/g' /etc/php/7.0/fpm/php.ini && \
79-
sed -ri 's/^;xmlrpc_errors\s*=\s*0/xmlrpc_errors = 1/g' /etc/php/7.0/cli/php.ini
85+
sed -ri 's/^;xmlrpc_errors\s*=\s*0/xmlrpc_errors = 1/g' /etc/php/7.0/cli/php.ini && \
86+
sed -ri 's/^zend.assertions\s*=\s*-1/zend.assertions = 1/g' /etc/php/7.0/fpm/php.ini && \
87+
sed -ri 's/^zend.assertions\s*=\s*-1/zend.assertions = 1/g' /etc/php/7.0/cli/php.ini
8088

8189
# Disable Google Pagespeed
8290
RUN sed -ri 's/\s*ModPagespeed on/ ModPagespeed off/g' /etc/apache2/mods-available/pagespeed.conf
@@ -86,10 +94,18 @@ RUN apt-get -y install sudo && \
8694
echo "ubuntu ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
8795
usermod -a -G sudo ubuntu
8896

97+
# Load custom .bashrc settings if available.
98+
USER ubuntu
99+
RUN echo 'LOCAL_BASHRC="$HOME/.local/bashrc"; test -f "${LOCAL_BASHRC}" && source "${LOCAL_BASHRC}"' >> ~/.bashrc
100+
USER root
101+
89102
# Clean-up installation.
90103
RUN DEBIAN_FRONTEND=noninteractive apt-get -y autoclean && \
91104
DEBIAN_FRONTEND=noninteractive apt-get -y autoremove
92105

106+
# Apache does not like PID files pre-existing
107+
RUN rm -f /var/run/apache2/apache2.pid
108+
93109
RUN service apache2 restart
94110
RUN service php7.0-fpm start
95111

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Dockerised Drupal 8 development environment using PHP 7.0 on Ubuntu 14.04 with H
55
## Debugging Tools
66

77
- [XDebug](http://www.xdebug.org/) - PHP debugging and profiling.
8+
- [XHProf](http://pecl.php.net/package/xhprof) - function-level hierarchical profiler.
89

910
## Front-end Tools
1011

@@ -37,7 +38,7 @@ cp docker-compose.yml.dist docker-compose.yml
3738
vim docker-compose.yml
3839

3940
# Build docker containers using Docker Composer.
40-
sudo docker-compose build
41+
sudo docker-compose build --no-cache
4142
sudo docker-compose up -d
4243
```
4344

@@ -47,7 +48,7 @@ From the host server, add the web container IP address to the hosts file.
4748

4849
```bash
4950
# Add IP address to hosts file.
50-
./hosts.sh
51+
./host.sh
5152
```
5253

5354
## Logging into Web Front-end
@@ -57,6 +58,24 @@ From the host server, add the web container IP address to the hosts file.
5758
sudo docker exec -it dockerdrupalphp70dev_drupalphp70devweb_1 su - ubuntu
5859
```
5960

60-
# TODO
61+
## Local customisations
6162

62-
- [XHProf](http://pecl.php.net/package/xhprof) - function-level hierarchical profiler.
63+
```bash
64+
# Customize scripts in local folders.
65+
cp local/bashrc.dist local/bashrc
66+
vim local/bashrc
67+
```
68+
69+
## XDebug enable and disable
70+
71+
Note that XDebug CLI is disabled by default.
72+
73+
```bash
74+
# Turn XDebug on / off in Apache.
75+
xdebug on
76+
xdebug off
77+
78+
# Turn XDebug on / off fopr both Apache and CLI.
79+
xdebug on-all
80+
xdebug off-all
81+
```

local/bashrc.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
find_git_branch() {
2+
# Based on: https://github.com/jimeh/git-aware-prompt http://stackoverflow.com/a/13003854/170413
3+
local branch
4+
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then
5+
if [[ "$branch" == "HEAD" ]]; then
6+
branch='detached'
7+
fi
8+
git_branch="($branch)"
9+
else
10+
git_branch=""
11+
fi
12+
echo $git_branch;
13+
}
14+
15+
PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:`find_git_branch`\w\$ '
16+
17+
# XDebug config to work with CLI.
18+
export XDEBUG_CONFIG="remote_host=$(/sbin/ip route|awk '/default/ { print $3 }')"

xdebug

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
# Turn XDebug on and off for Apache and CLI.
3+
4+
XDEBUG_CLI=/etc/php/7.0/cli/conf.d/20-xdebug.ini
5+
XDEBUG_FPM=/etc/php/7.0/fpm/conf.d/20-xdebug.ini
6+
7+
function on_cli {
8+
if [ ! -f $XDEBUG_CLI ]; then
9+
sudo ln -s /etc/php/mods-available/xdebug.ini $XDEBUG_CLI
10+
fi
11+
}
12+
13+
function on_fpm {
14+
if [ ! -f $XDEBUG_FPM ]; then
15+
sudo ln -s /etc/php/mods-available/xdebug.ini $XDEBUG_FPM
16+
fi
17+
}
18+
19+
function off_cli {
20+
if [ -f $XDEBUG_CLI ]; then
21+
sudo rm $XDEBUG_CLI
22+
fi
23+
}
24+
25+
function off_fpm {
26+
if [ -f $XDEBUG_FPM ]; then
27+
sudo rm $XDEBUG_FPM
28+
fi
29+
}
30+
31+
case "$1" in
32+
on)
33+
on_fpm
34+
;;
35+
off)
36+
off_fpm
37+
;;
38+
on-all)
39+
on_cli
40+
on_fpm
41+
;;
42+
off-all)
43+
off_cli
44+
off_fpm
45+
;;
46+
*)
47+
echo
48+
php -v
49+
exit 1
50+
esac
51+
52+
echo
53+
54+
if [ ! $2 ]; then
55+
sudo service apache2 restart
56+
sudo service php7.0-fpm restart
57+
echo
58+
php -v
59+
fi

xdebug.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ zend_extension=xdebug.so
22
xdebug.remote_log="/var/log/xdebug/xdebug.log"
33
xdebug.remote_enable=1
44
xdebug.remote_connect_back=1
5+
xdebug.remote_autostart=1
56
;xdebug.remote_handler="dbgp"
67
;xdebug.remote_mode="req"
78
;xdebug.remote_host=172.17.0.40
89
;xdebug.remote_port=9000
910
;xdebug.profiler_enable=1
1011
;xdebug.profiler_output_dir="/tmp/xdebug"
1112
;xdebug.idekey="sublime.xdebug"
12-
;xdebug.remote_autostart=0

0 commit comments

Comments
 (0)