From 5635b47c6f25ff04331338fe0a91542eb6cb0c72 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Sun, 9 Oct 2016 20:27:03 -0400 Subject: [PATCH] refactor the workspace docker file --- php-fpm/Dockerfile-70 | 1 + workspace/Dockerfile | 130 +++++++++++++++++++++--------------------- 2 files changed, 66 insertions(+), 65 deletions(-) diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index d1efc42c..f6cb318d 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -34,6 +34,7 @@ MAINTAINER Mahmoud Zalt # in the `docker-compose.yml` before the build. # Example: # - INSTALL_ZIP_ARCHIVE=true +# - ... # ##################################### diff --git a/workspace/Dockerfile b/workspace/Dockerfile index ef418149..46058bc9 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -32,65 +32,10 @@ MAINTAINER Mahmoud Zalt # # Optional Software's will only be installed if you set them to `true` # in the `docker-compose.yml` before the build. +# Example: +# - INSTALL_NODE=false +# - ... # -# - INSTALL_XDEBUG= false -# - INSTALL_MONGO= false -# - COMPOSER_GLOBAL_INSTALL= false -# - INSTALL_NODE= false -# - INSTALL_DRUSH= false -# - -##################################### -# xDebug: -##################################### - -# Check if xDebug needs to be installed -ARG INSTALL_XDEBUG=false -ENV INSTALL_XDEBUG ${INSTALL_XDEBUG} -RUN if [ ${INSTALL_XDEBUG} = true ]; then \ - # Load the xdebug extension only with phpunit commands - apt-get update && \ - apt-get install -y --force-yes php7.0-xdebug && \ - sed -i 's/^/;/g' /etc/php/7.0/cli/conf.d/20-xdebug.ini && \ - echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc \ -;fi -# ADD for REMOTE debugging -COPY ./xdebug.ini /etc/php/7.0/cli/conf.d/xdebug.ini - - -##################################### -# ssh: -##################################### - -# Check if ssh needs to be installed -# See: https://github.com/phusion/baseimage-docker#enabling_ssh -ADD insecure_id_rsa /tmp/id_rsa -ADD insecure_id_rsa.pub /tmp/id_rsa.pub -ARG INSTALL_WORKSPACE_SSH=false -ENV INSTALL_WORKSPACE_SSH ${INSTALL_WORKSPACE_SSH} -RUN if [ ${INSTALL_WORKSPACE_SSH} = true ]; then \ - rm -f /etc/service/sshd/down && \ - cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys \ - && cat /tmp/id_rsa.pub >> /root/.ssh/id_rsa.pub \ - && cat /tmp/id_rsa >> /root/.ssh/id_rsa \ - && rm -f /tmp/id_rsa* \ - && chmod 644 /root/.ssh/authorized_keys /root/.ssh/id_rsa.pub \ - && chmod 400 /root/.ssh/id_rsa \ -;fi - - -##################################### -# MongoDB: -##################################### - -# Check if Mongo needs to be installed -ARG INSTALL_MONGO=false -ENV INSTALL_MONGO ${INSTALL_MONGO} -RUN if [ ${INSTALL_MONGO} = true ]; then \ - # Install the mongodb extension - pecl install mongodb && \ - echo "extension=mongodb.so" >> /etc/php/7.0/cli/php.ini \ -;fi ##################################### # Non-Root User: @@ -121,6 +66,62 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \ composer global install \ ;fi +##################################### +# Crontab +##################################### +USER root + +COPY ./crontab /var/spool/cron/crontabs + +##################################### +# xDebug: +##################################### + +# Check if xDebug needs to be installed +ARG INSTALL_XDEBUG=false +ENV INSTALL_XDEBUG ${INSTALL_XDEBUG} +RUN if [ ${INSTALL_XDEBUG} = true ]; then \ + # Load the xdebug extension only with phpunit commands + apt-get update && \ + apt-get install -y --force-yes php7.0-xdebug && \ + sed -i 's/^/;/g' /etc/php/7.0/cli/conf.d/20-xdebug.ini && \ + echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc \ +;fi +# ADD for REMOTE debugging +COPY ./xdebug.ini /etc/php/7.0/cli/conf.d/xdebug.ini + +##################################### +# ssh: +##################################### +ARG INSTALL_WORKSPACE_SSH=false +ENV INSTALL_WORKSPACE_SSH ${INSTALL_WORKSPACE_SSH} + +ADD insecure_id_rsa /tmp/id_rsa +ADD insecure_id_rsa.pub /tmp/id_rsa.pub + +RUN if [ ${INSTALL_WORKSPACE_SSH} = true ]; then \ + rm -f /etc/service/sshd/down && \ + cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys \ + && cat /tmp/id_rsa.pub >> /root/.ssh/id_rsa.pub \ + && cat /tmp/id_rsa >> /root/.ssh/id_rsa \ + && rm -f /tmp/id_rsa* \ + && chmod 644 /root/.ssh/authorized_keys /root/.ssh/id_rsa.pub \ + && chmod 400 /root/.ssh/id_rsa \ +;fi + +##################################### +# MongoDB: +##################################### + +# Check if Mongo needs to be installed +ARG INSTALL_MONGO=false +ENV INSTALL_MONGO ${INSTALL_MONGO} +RUN if [ ${INSTALL_MONGO} = true ]; then \ + # Install the mongodb extension + pecl install mongodb && \ + echo "extension=mongodb.so" >> /etc/php/7.0/cli/php.ini \ +;fi + ##################################### # Drush: ##################################### @@ -167,6 +168,7 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ # Add NVM binaries to root's .bashrc USER root + RUN if [ ${INSTALL_NODE} = true ]; then \ echo "" >> ~/.bashrc && \ echo 'export NVM_DIR="/home/laradock/.nvm"' >> ~/.bashrc && \ @@ -177,10 +179,13 @@ RUN if [ ${INSTALL_NODE} = true ]; then \ # PHP Aerospike: ##################################### USER root -ARG INSTALL_AEROSPIKE_EXTENSION=false + +ARG INSTALL_AEROSPIKE_EXTENSION=true ENV INSTALL_AEROSPIKE_EXTENSION ${INSTALL_AEROSPIKE_EXTENSION} + # Copy aerospike configration for remote debugging COPY ./aerospike.ini /etc/php/7.0/cli/conf.d/aerospike.ini + RUN if [ ${INSTALL_AEROSPIKE_EXTENSION} = true ]; then \ # Install the php aerospike extension curl -L -o /tmp/aerospike-client-php.tar.gz "https://github.com/luciano-jr/aerospike-client-php/archive/master.tar.gz" \ @@ -194,16 +199,11 @@ RUN if [ ${INSTALL_AEROSPIKE_EXTENSION} = true ]; then \ ) \ && rm /tmp/aerospike-client-php.tar.gz \ ;fi + RUN if [ ${INSTALL_AEROSPIKE_EXTENSION} = false ]; then \ rm /etc/php/7.0/cli/conf.d/aerospike.ini \ ;fi -##################################### -# Crontab -##################################### -USER root -COPY ./crontab /var/spool/cron/crontabs - # #-------------------------------------------------------------------------- # Final Touch