Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoelr committed Aug 26, 2016
2 parents 6ecfe86 + af189a0 commit fb78d58
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 74 deletions.
129 changes: 70 additions & 59 deletions Docker Image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,80 +1,91 @@
FROM debian:jessie
MAINTAINER Joel Rowley <[email protected]>

LABEL vendor="The Wilds" \
org.wilds.docker-wpdevenvironment.version="2.1.0"

# Adapted and modified from the following files:
# - https://github.com/splattael/docker-debian-php/blob/master/jessie/Dockerfile
# - https://github.com/docker-library/php/blob/f016f5dc420e7d360f7381eb014ac6697e247e11/5.6/apache/Dockerfile

ENV RELEASE_DATE 2016-07-28
ENV DEBIAN_FRONTEND noninteractive

RUN \
apt-get -qq update && \
apt-get -qq install \
apache2 php5 php5-cli ssmtp libapache2-mod-php5 php5-mysql php5-json php5-curl php5-gd \
php5-xdebug libmcrypt-dev zlib1g-dev telnet git curl vim && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV MODS_AVAILABLE_PATH /etc/php5/mods-available
ENV CONFD_PATH /etc/php5/apache2/conf.d

# Copy custom ini modules
COPY mods-available/*.ini ${MODS_AVAILABLE_PATH}/

# Enable different module settings
RUN php5enmod xdebug

# Make sure opcache is disabled
RUN php5dismod opcache

ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars

# logs should go to stdout / stderr
RUN set -ex \
&& . "$APACHE_ENVVARS" \
&& ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"

# PHP files should be handled by PHP, and should be preferred over any other file type
RUN { \
echo '<FilesMatch \.php$>'; \
echo '\tSetHandler application/x-httpd-php'; \
echo '</FilesMatch>'; \
echo; \
apt-get -qq update && apt-get -qq install \
apache2 \
curl \
git \
libapache2-mod-php5 \
libmcrypt-dev \
php5 \
php5-cli \
php5-curl \
php5-gd \
php5-json \
php5-mysql \
php5-xdebug \
rsync \
ssmtp \
telnet \
vim \
zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV MODS_AVAILABLE_PATH=/etc/php5/mods-available \
CONFD_PATH=/etc/php5/apache2/conf.d \
APACHE_CONFDIR=/etc/apache2 \
XDEBUG_REMOTE_HOST=10.0.75.1 \
TIMEZONE='America/New_York' \
VOLUME_PATH=/var/www/html \
CERTIFICATE_PATH=/usr/local/share/ca-certificates \
TERM=xterm

ENV APACHE_ENVVARS=$APACHE_CONFDIR/envvars

RUN set -e \

# logs should go to stdout / stderr
&& . "$APACHE_ENVVARS" \
&& ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \
&& ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log" \

# PHP files should be handled by PHP, and should be preferred over any other file type
&& { \

echo '<FilesMatch \.php$>'; \
echo '\tSetHandler application/x-httpd-php'; \
echo '</FilesMatch>'; \
echo; \
# echo 'DirectoryIndex disabled'; \
echo 'DirectoryIndex index.php index.html'; \
echo; \
echo '<Directory /var/www/>'; \
echo '\tOptions -Indexes'; \
echo '\tAllowOverride All'; \
echo '</Directory>'; \
} | tee "$APACHE_CONFDIR/conf-available/docker-php.conf" \
&& a2enconf docker-php

# Enable mod_rewrite
RUN a2enmod rewrite
echo 'DirectoryIndex index.php index.html'; \
echo; \
echo '<Directory /var/www/>'; \
echo '\tOptions -Indexes'; \
echo '\tAllowOverride All'; \
echo '</Directory>'; \
} | tee "$APACHE_CONFDIR/conf-available/docker-php.conf" \
&& a2enconf docker-php \

# Add a symbolic link to PHP that is the same as the web host.
# This is primarily for CLI php scripts run inside the container.
&& ln -s $(which php) /usr/local/bin/php56

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin \
--filename=composer

# Add a symbolic link to PHP that is the same as the web host.
# This is primarily for CLI php scripts run inside the container.
RUN ln -s $(which php) /usr/local/bin/php56
--install-dir=/usr/local/bin \
--filename=composer

COPY bin/* /usr/local/bin/

ENV TIMEZONE 'America/New_York'

ENV VOLUME_PATH /var/www/html
ENV CERTIFICATE_PATH /usr/local/share/ca-certificates
# Copy custom ini modules
COPY mods-available/*.ini ${MODS_AVAILABLE_PATH}/

VOLUME ${VOLUME_PATH}
VOLUME ${CERTIFICATE_PATH}
# Enable different module settings
RUN php5enmod xdebug # enable xdebug settings \
&& php5dismod opcache # disable opcache \
&& a2enmod rewrite # enable mod_rewrite

WORKDIR ${VOLUME_PATH}

Expand Down
16 changes: 7 additions & 9 deletions Docker Image/bin/setup-container
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@
typeset script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

. "$script_dir/timezone"
. "$script_dir/create-user-from-directory-owner"

# Set timezone in container
_set_timezone "${TIMEZONE}"

# Set DocumentRoot to VOLUME_PATH
sed -i "s|\${VOLUME_PATH}|${VOLUME_PATH}|g" ${APACHE_CONFDIR}/apache2.conf

# Set Apache user/group
create_user_from_directory_owner "${VOLUME_PATH}"
# Make sure xdebug is going to send events back to the correct IP.
sed -i "s/xdebug.remote_host=.*/xdebug.remote_host=${XDEBUG_REMOTE_HOST}/" ${MODS_AVAILABLE_PATH}/xdebug.ini

# Set the Apache2 ServerName to the hostname of the container
echo "ServerName `hostname`" > ${APACHE_CONFDIR}/conf-available/set-hostname.conf
a2enconf set-hostname

# Set correct permissions on certificates added to the container
# This has no affect on files hosted through a volume
for FILE in ${CERTIFICATE_PATH}/*; do
chown root:staff $FILE
chmod 775 $FILE
done
chown -R root:staff ${CERTIFICATE_PATH}
chmod -R 775 ${CERTIFICATE_PATH}

# set appropriate permissions
chown -R www-data:www-data "${VOLUME_PATH}"

exec "$@"
8 changes: 7 additions & 1 deletion Docker Image/mods-available/xdebug.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_connect_back=1
xdebug.remote_host=CHANGEME

; This doesn't seem to work in Docker for Windows as the
; IP that the container sees the request come from does
; not equal the same IP as that of the requesting
; computer.
;xdebug.remote_connect_back=1

; Require the debug cookie to be sent before debugging
xdebug.remote_autostart=0
Expand Down
36 changes: 31 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ services:
environment:
- MYSQL_ROOT_PASSWORD=pw
- MYSQL_DATABASE=local_db
command: "/mysql.sh"
volumes:
- ../.docker-data/mysql:/var/lib/mysql
- ./mysql.sh:/mysql.sh
- docker-mysql:/var/lib/mysql
restart: on-failure

phpmyadmin:
Expand All @@ -25,18 +23,46 @@ services:
links:
- mysql:db

vsftpd:
container_name: vsftpd
image: wilds/vsftpd
hostname: vsftpd
ports:
- "21:21"
- "30000-30009:30000-30009"
volumes:
- docker-html:/home/virtual/www-data/html
- docker-certificates:/home/virtual/certs/certs
- docker-mysql:/home/virtual/mysql/mysql
environment:
PASV_ADDRESS: 10.0.75.1
PASV_MIN_PORT: 30000
PASV_MAX_PORT: 30009
VSFTPD_USER_1: 'www-data:ftp:33:'
VSFTPD_USER_2: 'mysql:mysql:999:'
VSFTPD_USER_3: 'certs:certs:50:'

wordpress:
container_name: wordpress
image: wilds/wpdevenvironment:latest
hostname: wordpress
environment:
- TIMEZONE=America/New_York
- XDEBUG_REMOTE_HOST=10.0.75.1
ports:
- "80:80"
working_dir: /var/www/html
volumes:
- ../.docker-html:/var/www/html
- ../.docker-certs:/usr/local/share/ca-certificates
- docker-html:/var/www/html
- docker-certificates:/usr/local/share/ca-certificates
links:
- mysql:db
restart: on-failure

volumes:
docker-mysql:
external: true
docker-html:
external: true
docker-certificates:
external: true

0 comments on commit fb78d58

Please sign in to comment.