diff --git a/.env b/.env new file mode 100644 index 0000000000000000000000000000000000000000..135ac1e238d788b858bcd7cc2d110a1b263e30ad --- /dev/null +++ b/.env @@ -0,0 +1,48 @@ +## WCMS Docker Environment settings ## +## If changes are required to any setting they should be added/done here ## + + + +### Project Settings ### +################################# + +PROJECT_NAME=wcms-docker +PROJECT_BASE_URL=wcms.localhost + + +### Database Settings ### +################################# + +DB_NAME=d8_fdsu1 +DB_USER=drupal +DB_PASSWORD=vagrant +DB_ROOT_PASSWORD=root +DB_HOST=mariadb +DB_DRIVER=mysql +DB_ADDITIONAL=d7_fdsu1 d7_fdsu2 d7_fdsu3 d7_fdsu4 d8_fdsu2 d8_fdsu3 d8_fdsu4 + + +### PHP Setttings ### +################################## + + +PHP_VERSION=5.6 +#PHP_VERSION=7.1 +#PHP_VERSION=7.2 +#PHP_VERSION=7.3 + +#PHP_VERSION8=7.1 +PHP_VERSION8=7.2 +#PHP_VERSION8=7.3 + +### DRUPAL settings ### +################################## + +DRUPAL7_VERSION=7.63 + +DRUPAL8_VERSION=8.6.7 + + + + +=================================================================================== \ No newline at end of file diff --git a/build-scripts/drupal7/Dockerfile b/build-scripts/drupal7/Dockerfile index 9a80a26b88f0cc3fff70d40fef773fd929a7cdd6..87eb853c285fae2c9ff762005269c4df0d5c2067 100644 --- a/build-scripts/drupal7/Dockerfile +++ b/build-scripts/drupal7/Dockerfile @@ -5,6 +5,13 @@ # Set the base image to Ubuntu FROM ubuntu:xenial +# Pass the argument variables from the docker-compose file to the Dockerfile and echo them out +ARG PHP_VERSION +ARG DRUPAL7_VERSION + +RUN echo "PHP version: $PHPVERSION" +RUN echo "Drupal 7 version: $DRUPAL7_VERSION" + # Allows installing of packages without prompting the user to answer any questions ENV DEBIAN_FRONTEND noninteractive @@ -35,21 +42,22 @@ RUN apt-get install -y \ vim \ git \ apache2 \ - php7.1 \ - php7.1-apc \ - php7.1-fpm \ - php7.1-xml \ - php7.1-simplexml \ - php7.1-mbstring \ - php7.1-cli \ - php7.1-mysql \ - php7.1-gd \ - php7.1-curl \ - php7.1-ldap \ - php7.1-mcrypt \ - php7.1-zip \ + php${PHP_VERSION} \ + php${PHP_VERSION}-apc \ + php${PHP_VERSION}-fpm \ + php${PHP_VERSION}-xml \ + php${PHP_VERSION}-simplexml \ + php${PHP_VERSION}-mbstring \ + php${PHP_VERSION}-cli \ + php${PHP_VERSION}-mysql \ + php${PHP_VERSION}-gd \ + php${PHP_VERSION}-gd \ + php${PHP_VERSION}-curl \ + php${PHP_VERSION}-ldap \ + php${PHP_VERSION}-mcrypt \ + php${PHP_VERSION}-zip \ php-pear \ - libapache2-mod-php7.1 \ + libapache2-mod-php${PHP_VERSION} \ optipng \ pdftk \ jpegoptim \ @@ -107,19 +115,19 @@ RUN useradd -d /home/vagrant -ms /bin/bash -g root -G sudo -p vagrant vagrant # Replace the default site configuration with our own. COPY 000-default.conf /etc/apache2/sites-available/000-default.conf RUN a2enmod proxy_fcgi setenvif -RUN a2enconf php7.1-fpm -RUN service php7.1-fpm restart +RUN a2enconf php${PHP_VERSION}-fpm +RUN service php${PHP_VERSION}-fpm restart ## Make sure we are running php5.6 -RUN update-alternatives --set php /usr/bin/php7.1 -RUN a2enmod php7.1 +RUN update-alternatives --set php /usr/bin/php${PHP_VERSION} +RUN a2enmod php${PHP_VERSION} RUN service apache2 restart ## Check version of PHP RUN php -v ## Install Drupal. -RUN drush dl -v -d drupal-7.63 --destination="/var/www" --drupal-project-rename="drupal7" +RUN drush dl -v -d drupal-${DRUPAL7_VERSION} --destination="/var/www" --drupal-project-rename="drupal7" RUN chown -R www-data:www-data /var/www/ @@ -188,18 +196,18 @@ COPY docker-entrypoint-d7.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint-d7.sh ## Add Drupal specific changes for PHP to the php.ini files. -RUN sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.1/apache2/php.ini && \ - sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.1/fpm/php.ini && \ - sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.1/cli/php.ini && \ - sed -i "s/max_execution_time =.*/max_execution_time = 240/" /etc/php/7.1/apache2/php.ini && \ - sed -i "s/max_execution_time =.*/max_execution_time = 240/" /etc/php/7.1/cli/php.ini && \ - sed -i "s/max_input_time = .*/max_input_time = 240/" /etc/php/7.1/apache2/php.ini && \ - sed -i "s/max_input_time = .*/max_input_time = 240/" /etc/php/7.1/cli/php.ini && \ - sed -i "s/memory_limit = .*/memory_limit = 768M/" /etc/php/7.1/apache2/php.ini && \ - sed -i "s/memory_limit = .*/memory_limit = 768M/" /etc/php/7.1/cli/php.ini && \ - sed -i "s/; max_input_vars = .*/max_input_vars = 10000/" /etc/php/7.1/apache2/php.ini && \ - sed -i "s/;date.timezone = */date.timezone = America\/Toronto/" /etc/php/7.1/apache2/php.ini && \ - sed -i "s/;date.timezone = */date.timezone = America\/Toronto/" /etc/php/7.1/cli/php.ini +RUN sed -i "s/display_errors = .*/display_errors = On/" /etc/php/${PHP_VERSION}/apache2/php.ini && \ + sed -i "s/display_errors = .*/display_errors = On/" /etc/php/${PHP_VERSION}/fpm/php.ini && \ + sed -i "s/display_errors = .*/display_errors = On/" /etc/php/${PHP_VERSION}/cli/php.ini && \ + sed -i "s/max_execution_time =.*/max_execution_time = 240/" /etc/php/${PHP_VERSION}/apache2/php.ini && \ + sed -i "s/max_execution_time =.*/max_execution_time = 240/" /etc/php/${PHP_VERSION}/cli/php.ini && \ + sed -i "s/max_input_time = .*/max_input_time = 240/" /etc/php/${PHP_VERSION}/apache2/php.ini && \ + sed -i "s/max_input_time = .*/max_input_time = 240/" /etc/php/${PHP_VERSION}/cli/php.ini && \ + sed -i "s/memory_limit = .*/memory_limit = 768M/" /etc/php/${PHP_VERSION}/apache2/php.ini && \ + sed -i "s/memory_limit = .*/memory_limit = 768M/" /etc/php/${PHP_VERSION}/cli/php.ini && \ + sed -i "s/; max_input_vars = .*/max_input_vars = 10000/" /etc/php/${PHP_VERSION}/apache2/php.ini && \ + sed -i "s/;date.timezone = */date.timezone = America\/Toronto/" /etc/php/${PHP_VERSION}/apache2/php.ini && \ + sed -i "s/;date.timezone = */date.timezone = America\/Toronto/" /etc/php/${PHP_VERSION}/cli/php.ini # Expose the default Apache port. EXPOSE 80 diff --git a/build-scripts/drupal8/Dockerfile b/build-scripts/drupal8/Dockerfile index 82218ffa160bb87799714a139384dcb2b6109a70..0bd16c269f1a7dd7570a60e48722e17b043d0c85 100644 --- a/build-scripts/drupal8/Dockerfile +++ b/build-scripts/drupal8/Dockerfile @@ -1,14 +1,20 @@ +############################################################ +# Dockerfile to build WCMS container images +# Based on Ubuntu +############################################################ +# Set the base image to Ubuntu FROM ubuntu:xenial -################################################################################ -# # -# THIS CONTAINER IS FOR EDUCATIONAL USE ONLY! # -# # -# Never use this container for running production workloads! # -# # -################################################################################ +# Pass the argument variables from the docker-compose file to the Dockerfile and echo them out +ARG PHP_VERSION8 +ARG DRUPAL8_VERSION + +RUN echo "PHP version: ${PHPVERSION8}" +RUN echo "Drupal 8 version: ${DRUPAL8_VERSION}" + # Allows installing of packages without prompting the user to answer any questions ENV DEBIAN_FRONTEND noninteractive + RUN apt-get update && \ apt-get install --assume-yes \ software-properties-common \ @@ -36,21 +42,21 @@ RUN apt-get update && \ openssh-server \ wget \ sudo \ - php7.2 \ - libapache2-mod-php7.2 \ - php7.2-mysql \ - php7.2-cli \ - php7.2-common \ - php7.2-gd \ - php7.2-mbstring \ - php7.2-xml \ - php7.2-opcache \ - php7.2-sqlite3 \ - php7.2-mysql \ - php7.2-curl \ - php7.2-soap \ - php7.2-phar \ - php7.2-cgi \ + php${PHP_VERSION8} \ + libapache2-mod-php${PHP_VERSION8} \ + php${PHP_VERSION8}-mysql \ + php${PHP_VERSION8}-cli \ + php${PHP_VERSION8}-common \ + php${PHP_VERSION8}-gd \ + php${PHP_VERSION8}-mbstring \ + php${PHP_VERSION8}-xml \ + php${PHP_VERSION8}-opcache \ + php${PHP_VERSION8}-sqlite3 \ + php${PHP_VERSION8}-mysql \ + php${PHP_VERSION8}-curl \ + php${PHP_VERSION8}-soap \ + php${PHP_VERSION8}-phar \ + php${PHP_VERSION8}-cgi \ php-uploadprogress \ php-pear \ optipng \ @@ -128,7 +134,7 @@ ENV APACHE_PID_FILE /var/run/apache2.pid # Clone Drupal -RUN drush dl -v -d drupal-8.6.7 --destination="/var/www" --drupal-project-rename="drupal8" +RUN drush dl -v -d drupal-${DRUPAL8_VERSION} --destination="/var/www" --drupal-project-rename="drupal8" RUN echo "Cloned Drupal 8...." # Clone our WCMS profile diff --git a/docker-compose.yml b/docker-compose.yml index 1f2c1e2bdc0144a3b79d63cfcc485f2e757d6bf8..a40f78a4c634b6f33c76f494c5fe42fc26ca5d31 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,22 +3,32 @@ services: drupal7: container_name: wcms-drupal7 - build: ./build-scripts/drupal7 + build: + context: ./build-scripts/drupal7 + args: + PHP_VERSION: ${PHP_VERSION} + DRUPAL7_VERSION: ${DRUPAL7_VERSION} ports: - "8080:80" - "4443:443" + stdin_open: true tty: true drupal8: container_name: wcms-drupal8 - build: ./build-scripts/drupal8 + build: + context: ./build-scripts/drupal8 + args: + PHP_VERSION8: ${PHP_VERSION8} + DRUPAL8_VERSION: ${DRUPAL8_VERSION} ports: - "8081:80" - "4444:443" + stdin_open: true tty: true @@ -30,11 +40,11 @@ services: volumes: - ./db-backups:/var/mysql/backups:delegated environment: - MYSQL_ROOT_PASSWORD: root - MYSQL_DATABASE: d8_fdsu1 - MYSQL_USER: drupal - MYSQL_PASSWORD: vagrant - ADDITIONAL_DATABASES: d7_fdsu1 d7_fdsu2 d7_fdsu3 d7_fdsu4 d8_fdsu2 d8_fdsu3 d8_fdsu4 + MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD + MYSQL_DATABASE: $DB_NAME + MYSQL_USER: $DB_USER + MYSQL_PASSWORD: $DB_PASSWORD + ADDITIONAL_DATABASES: ${DB_ADDITIONAL} ports: - "3306:3306" @@ -60,6 +70,7 @@ services: - /var/run/docker.sock:/var/run/docker.sock - portainer_data:/data + volumes: portainer_data: \ No newline at end of file