From 701c5f9a47601a8ab06a94c9d0cefe161f3e58e6 Mon Sep 17 00:00:00 2001
From: mnshantz <mnshantz@uwaterloo.ca>
Date: Mon, 20 Aug 2018 10:56:01 -0400
Subject: [PATCH] updated scripts to move files out of docroot and into the
 container.

---
 build-scripts/web/Dockerfile           | 28 +++++++++++++++++++++++---
 build-scripts/web/docker-entrypoint.sh | 12 ++++++++---
 docker-compose.yml                     |  4 +---
 3 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/build-scripts/web/Dockerfile b/build-scripts/web/Dockerfile
index 26c1059..d40fa41 100644
--- a/build-scripts/web/Dockerfile
+++ b/build-scripts/web/Dockerfile
@@ -14,14 +14,14 @@ RUN apt-get update && \
     language-pack-en \
     curl \
     apt-transport-https
-    
+
 ## Added so we can install yarn for Drupal8 theme work.
 RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
 RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
 
 ## Added so we can installs 8.x branch of nodejs.
 RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
-    
+
 RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
 RUN export LANG=en_US.UTF-8
 
@@ -65,6 +65,7 @@ RUN apt-get update && \
     libapache2-mod-fastcgi \
     git \
     nodejs \
+    yarn \
     drush \
     ruby-sass \
     ruby-compass \
@@ -110,6 +111,27 @@ RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
 COPY docker-entrypoint.sh /usr/local/bin/
 RUN chmod +x /usr/local/bin/docker-entrypoint.sh
 
+# Clone PatternLab into the html directory.
+RUN git clone https://git.uwaterloo.ca/wcms/uw_wcms_pattern_lab.git /var/www/html/uw_wcms_pattern_lab
+RUN echo "Cloned patternlab..."
+
+# Clone Drupal
+RUN drush dl -v -d drupal-8.5.5 --destination="/var/www" --drupal-project-rename="drupal8"
+RUN echo "Cloned Drupal 8...."
+
+# Clone our WCMS profile
+RUN cd /var/www/drupal8/profiles && \
+    git clone https://git.uwaterloo.ca/wcms/uw_base_profile.git && \
+    cd /var/www/drupal8/profiles/uw_base_profile && \
+    git checkout 8.x-3.x
+
+# Manually set up the apache environment variables
+ENV APACHE_RUN_USER www-data
+ENV APACHE_RUN_GROUP www-data
+ENV APACHE_LOG_DIR /var/log/apache2
+ENV APACHE_LOCK_DIR /var/lock/apache2
+ENV APACHE_PID_FILE /var/run/apache2.pid
+
 # Expose the default Apache port.
 EXPOSE 80
 EXPOSE 443
@@ -118,4 +140,4 @@ EXPOSE 443
 ENTRYPOINT ["docker-entrypoint.sh"]
 
 # If no command is passed to the container, start Apache by default.
-CMD ["apachectl", "-D", "FOREGROUND"]
\ No newline at end of file
+CMD ["apachectl", "-D", "FOREGROUND"]
diff --git a/build-scripts/web/docker-entrypoint.sh b/build-scripts/web/docker-entrypoint.sh
index f56f24a..9a7d5b3 100644
--- a/build-scripts/web/docker-entrypoint.sh
+++ b/build-scripts/web/docker-entrypoint.sh
@@ -11,20 +11,26 @@ if [ -f /run/apache2/apache2.pid ]; then
     rm /run/apache2/apache2.pid
 fi
 
+## Setup Drupal8 and Patternlab.
+#cd /var/www/drupal8/profiles/uw_base_profile
+#apt-get install composer
+#composer config --global github-oauth.github.com 5e7a5890e9935f4a03a3785e11816851430e930c
+#./rebuild.sh -y > tmp/profile-build.log
+
 # Allow the Apache docroot to be overridden.
-APACHE_DOCROOT_DIR="${APACHE_DOCROOT_DIR:-/var/www/html}"
+APACHE_DOCROOT_DIR="${APACHE_DOCROOT_DIR:-/var/www/drupal8}"
 if [ -n "$APACHE_DOCROOT_DIR" ]; then
      sed -i 's@^\s*DocumentRoot.*@'"        DocumentRoot ${APACHE_DOCROOT_DIR}"'@'  /etc/apache2/sites-available/000-default.conf
 fi
 
 # Allow the site name to be overriden.
-APACHE_SITE_NAME="${APACHE_SITE_NAME:-docker.test}"
+APACHE_SITE_NAME="${APACHE_SITE_NAME:docker8}"
 if [ -n "$APACHE_SITE_NAME" ]; then
      sed -i 's@^\s*ServerName.*@'"        ServerName ${APACHE_SITE_NAME}"'@'  /etc/apache2/sites-available/000-default.conf
 fi
 
 # Allow for site aliases to be provided.
-APACHE_SITE_ALIAS="${APACHE_SITE_ALIAS:-docker.localhost}"
+APACHE_SITE_ALIAS="${APACHE_SITE_ALIAS:docke8.localhost}"
 if [ -n "$APACHE_SITE_ALIAS" ]; then
      sed -i 's@^\s*ServerAlias.*@'"        ServerAlias ${APACHE_SITE_ALIAS}"'@'  /etc/apache2/sites-available/000-default.conf
 fi
diff --git a/docker-compose.yml b/docker-compose.yml
index d0c1f5a..a27dead 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -2,9 +2,7 @@ version: '3'
 services:
   web:
     build: ./build-scripts/web
-    volumes:
-      - ./docroot/drupal:/var/www/drupal
-      - ./docroot/uwpatternlab:/var/www/html/uw_wcms_pattern_lab
+
     ports:
       - "80:80"
       - "443:443"
-- 
GitLab