From c547b859c84deaf7e3d16f2f5b87960b844fe359 Mon Sep 17 00:00:00 2001 From: Joel Rowley Date: Fri, 26 Aug 2016 16:40:23 -0400 Subject: [PATCH 1/2] * Converted to using named volumes. * Cleaned up Dockerfile and made it more conform to standards --- Docker Image/Dockerfile | 129 ++++++++++++++----------- Docker Image/bin/setup-container | 15 ++- Docker Image/mods-available/xdebug.ini | 8 +- docker-compose.yml | 36 ++++++- 4 files changed, 115 insertions(+), 73 deletions(-) diff --git a/Docker Image/Dockerfile b/Docker Image/Dockerfile index bccf720..823ff4f 100644 --- a/Docker Image/Dockerfile +++ b/Docker Image/Dockerfile @@ -1,80 +1,91 @@ FROM debian:jessie MAINTAINER Joel Rowley +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 ''; \ - echo '\tSetHandler application/x-httpd-php'; \ - echo ''; \ - 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 ''; \ + echo '\tSetHandler application/x-httpd-php'; \ + echo ''; \ + echo; \ # echo 'DirectoryIndex disabled'; \ - echo 'DirectoryIndex index.php index.html'; \ - echo; \ - echo ''; \ - echo '\tOptions -Indexes'; \ - echo '\tAllowOverride All'; \ - echo ''; \ - } | 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 ''; \ + echo '\tOptions -Indexes'; \ + echo '\tAllowOverride All'; \ + echo ''; \ + } | 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} diff --git a/Docker Image/bin/setup-container b/Docker Image/bin/setup-container index 424bf26..c49a64b 100644 --- a/Docker Image/bin/setup-container +++ b/Docker Image/bin/setup-container @@ -11,18 +11,17 @@ _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 "$@" diff --git a/Docker Image/mods-available/xdebug.ini b/Docker Image/mods-available/xdebug.ini index 91ff1d1..16653d8 100644 --- a/Docker Image/mods-available/xdebug.ini +++ b/Docker Image/mods-available/xdebug.ini @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 70ede01..50efab8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -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 \ No newline at end of file From ae3a84ef857d11b40b52e7e766812013cbde5e99 Mon Sep 17 00:00:00 2001 From: Joel Rowley Date: Fri, 26 Aug 2016 16:46:50 -0400 Subject: [PATCH 2/2] Removed old reference to a script --- Docker Image/bin/setup-container | 1 - 1 file changed, 1 deletion(-) diff --git a/Docker Image/bin/setup-container b/Docker Image/bin/setup-container index c49a64b..c14bfcf 100644 --- a/Docker Image/bin/setup-container +++ b/Docker Image/bin/setup-container @@ -3,7 +3,6 @@ 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}"