Skip to content
Snippets Groups Projects

WCMS Docker setup

CAUTION! This Docker box is meant for local development only. This set up is not hardened and is not secure, so only us it as a local development environment.

To run the dockerfile:

       docker build -t dockerfile .

Just capturing this here...

Use docker-compose instead of docker build. Need to have a docker-compose.yml file and reference any other files in a docker folder (or whatever you want to name it).

To build using docker-compose:

       docker-compose up -d

To check that all the boxes are running:

       docker-compose ps

If you get an error running docker-compose related to wincred got to ~/.docker/config.json and remove the "credstore":"wincred" but leave the curly braces {} and save the file.

Running setup.sh creates a Vagrantfile that will allow you to create a Docker box that (currently) runs Ubuntu 16.04 LTS with Apache 2.4.18, MySQL 5.7 and PHP 5.6.19/7.1.6 as well as Drupal currently at 7.59/8.5. Please note, this setup only allows local logins to sites. CAS doesn't work "out of the box". You will need to add an additional file if you require CAS which you will need to contact a WCMS team member to get.

A few things to be aware of:

You need to have Git (https://git-scm.com/downloads), Vagrant (https://www.vagrantup.com/downloads.html) and Docker (https://www.docker.com/community-edition) installed on your host system to create the dev environment. If you are on a Mac you will also need Xcode installed.

NOTE TO SELF CHECK IF THIS IS TRUE WITH DOCKER

You need to create a Host-only Network in Docker. To do that go to Preferences -> Network and select the Host-Only tab. On the right you will see a green +, click that and then enter:

     IPv4 address        192.168.101.1
     IPv4 network mask   255.255.255.0

Running setup.sh:

You will need to run the setup.sh file first. This will create a Vagrantfile and update settings that you then use to create your virtual machine. When you run setup.sh it will ask you for a hostname, an IP address (which needs to start with 192.168.101) and what your server will be eg. d7 or k7 etc. You can leave the defaults if you want but if you are running or plan to run multiple wcms virtual machines then you should change some of the defaults for each one. It will also ask you to choose a version of PHP. If you are planning on doing Drupal 8 development then you should chose option 2, 7.1. For Drupal 7 development you should chose option 1, for 5.6.

NOTE Before running setup.sh Be aware, you may need to run the vagrant commands as an administrator or at least supply an administrator password for your local dev site to build correctly.

After running setup.sh:

  1. You should add the vbguest vagrant plugin. If you are on a Windows machine you should also add the winnfsd plugin:

    $ vagrant plugin install vagrant-vbguest
    $ vagrant plugin install vagrant-winnfsd
  2. If you just downloaded wcms-vagrant you can skip this step, otherwise before running you should make sure that the base box is updated:

    $ vagrant box update
  3. You need to add the ip address and server name you created during setup to the host machines "hosts" file. On a Windows machine you will need to add the defaults or if you changed the defaults, what you set the IP, host-name and sites to into your windows hosts file (C:\Windows\System32\drives\etc).

    You're Windows hosts file should look something like this:

        192.168.101.20 wcms-vagrant d7 d7alt d7rel d7lrel d7os d8 d8alt

    If you have or are planning to have multiple vm's running using this script you should be aware that you will need to change the name of you're sites when you run setup.sh and not rely on the defaults. That way on Windows your computer can route the sites correctly with the Windows hosts file.

    You're Windows hosts file should look something like this:

       192.168.101.20 wcms-vagrant d7 d7alt d7rel d7lrel d7os d8 d8alt
       192.168.101.21 wcms-vagrant1 test7 test7alt test8 test7rel test7lrel test7os test8 test8alt
       192.168.101.35 wcms-vagrant2 p7 p7alt p7rel p7lrel p7os p8 p8alt

Note If you don't update the hosts file you won't be able to access the local development sites in a web browser.

  1. Once you've run the setup.sh file (which creates the Vagrantfile and the manifests) from the command prompt type:
    $ vagrant up
    This will create your dev environment, after a few minutes it will complete and you should see:
    ==> default: ***************************************************************************************
    ==> default: The installation is now complete. You can access you VM via ssh vagrant@192.168.101.20
    ==> default: ***************************************************************************************
    You can then log in over ssh using the IP address you created earlier.

Logging in to your local development server:

  1. The login for your local development server is user: vagrant password: vagrant.

  2. You will need to add your Gitlab key to the VM so you can access the git repos. Here are the instructions from Gitlab for adding the key:

    https://git.uwaterloo.ca/help/ssh/README

  3. You may need to add the LDAP config settings if you need CAS to work. If you are part of the WCMS team you should already have access to this, if you are an on-campus developer you can contact the WCMS and ask how to set this up.

  4. You should go to one of your drupal folders, located at /var/www/drupal7/profiles/uw_base_profile (or drupal7alt) and pull down the latest version of the wcms base profile or the version you need to work with:

    $ git pull

    You should also do a rebuild of the profile to update any modules:

    $ ./rebuild.sh

    NOTE Drupal 8 is included as one of the options, but it is currently not supported by the WCMS. It is included for investigative purposes only

  5. If you run into an issue when using drush to clear caches the first time after you create a site, it could be that the permissions of the files folder for that site have changed. Either change the permissions for that specific file directory or just change the permissions at the /var/www level:

    $ sudo chown -R vagrant:www-data /var/www
  6. Xdebug is disabled by default because it affects performance of Xhprof, to enable it you need to remove the semi-colon from the zend_extension line of:

    $ sudo nano /etc/php/<version of php>/mods_available/xdebug.ini
  7. Be aware that OpenScholar takes a lot of memory to install, the VM has 3072MB of memory allocated to it because of this, so running multiple VM's could cause performance issues.

  8. You should periodically make sure that your dev environment is up to date. You can do that when you are logged in to your server by doing an update and upgrade:

    $ sudo apt-get update
    
    $ sudo apt-get upgrade
  9. To shutdown the VM type (from within the wcms-vagrant folder):

    $ vagrant halt

    To start it again you just type (from within the wcms-vagrant folder):

    $ vagrant up
  10. If you don't want your VM any more type (from within the wcms-vagrant folder):

    $ vagrant destroy

    This will destroy your dev environment and remove it from Docker but it keeps the settings you set when you ran setup.sh. If you want remove those settings as well then you need to run clean.sh which will remove all the config files and allow you to start again from scratch.

Helpful aliases included in with the wcms-vagrant

From the command line type the text on the left of the = to have the command on the right run:

web = 'cd /var/www/'

sites = 'cd /var/www/drupal7/sites/'

profile = 'cd /var/www/drupal7/profiles/uw_base_profile'

profilealt = 'cd /var/www/drupal7alt/profiles/uw_base_profile'

profilerel = 'cd /var/www/drupal7rel/profiles/uw_base_profile'

profilelrel = 'cd /var/www/drupal7lrel/profiles/uw_base_profile'

profileos = 'cd /var/www/drupal7os/profiles/uw_base_profile'

profile8 = 'cd /var/www/drupal8/profiles/uw_base_profile'

profile8alt = 'cd /var/www/drupal8alt/profiles/uw_base_profile'

drush7 = '~/drush7/vendor/bin/drush'

drush8 = '~/drush8/vendor/bin/drush'

defaultphp56 = 'defaultphp5.6.sh'

defaultphp71 = 'defaultphp7.1.sh'

fdsu1 = 'cd /var/www/drupal7/sites/7.fdsu1'

fdsu2 = 'cd /var/www/drupal7/sites/7.fdsu2'

fdsu3 = 'cd /var/www/drupal7/sites/7.fdsu3'

fdsu4 = 'cd /var/www/drupal7/sites/7.fdsu4'

fdsu5 = 'cd /var/www/drupal7/sites/7.fdsu5'

fdsu1alt = 'cd /var/www/drupal7alt/sites/7alt.fdsu1'

fdsu2alt = 'cd /var/www/drupal7alt/sites/7alt.fdsu2'

fdsu3alt = 'cd /var/www/drupal7alt/sites/7alt.fdsu3'

fdsu4alt = 'cd /var/www/drupal7alt/sites/7alt.fdsu4'

fdsu5alt = 'cd /var/www/drupal7alt/sites/7alt.fdsu5'

fdsu1rel = 'cd /var/www/drupal7rel/sites/7rel.fdsu1'

fdsu2rel = 'cd /var/www/drupal7rel/sites/7rel.fdsu2'

fdsu3rel = 'cd /var/www/drupal7rel/sites/7rel.fdsu3'

fdsu4rel = 'cd /var/www/drupal7rel/sites/7rel.fdsu4'

fdsu5rel = 'cd /var/www/drupal7rel/sites/7rel.fdsu5'

fdsu1lrel = 'cd /var/www/drupal7lrel/sites/7lrel.fdsu1'

fdsu2lrel = 'cd /var/www/drupal7lrel/sites/7lrel.fdsu2'

fdsu3lrel = 'cd /var/www/drupal7lrel/sites/7lrel.fdsu3'

fdsu4lrel = 'cd /var/www/drupal7lrel/sites/7lrel.fdsu4'

fdsu5lrel = 'cd /var/www/drupal7lrel/sites/7lrel.fdsu5'

fdsu1os = 'cd /var/www/drupal7os/sites/7os.fdsu1'

fdsu2os = 'cd /var/www/drupal7os/sites/7os.fdsu2'

fdsu3os = 'cd /var/www/drupal7os/sites/7os.fdsu3'

fdsu4os = 'cd /var/www/drupal7os/sites/7os.fdsu4'

fdsu5os = 'cd /var/www/drupal7os/sites/7os.fdsu5'

fdsu1-8 = 'cd /var/www/drupal8/sites/8.fdsu1'

fdsu2-8 = 'cd /var/www/drupal8/sites/8.fdsu2'

fdsu3-8 = 'cd /var/www/drupal8/sites/8.fdsu3'

fdsu4-8 = 'cd /var/www/drupal8/sites/8.fdsu4'

fdsu5-8 = 'cd /var/www/drupal8/sites/8.fdsu5'

fdsu1-8alt = 'cd /var/www/drupal8alt/sites/8alt.fdsu1'

fdsu2-8alt = 'cd /var/www/drupal8alt/sites/8alt.fdsu2'

fdsu3-8alt = 'cd /var/www/drupal8alt/sites/8alt.fdsu3'

fdsu4-8alt = 'cd /var/www/drupal8alt/sites/8alt.fdsu4'

fdsu5-8alt = 'cd /var/www/drupal8alt/sites/8alt.fdsu5'

clr = 'clear'

cc = 'drush cc all'

updb = 'drush updb'

makedrush = 'drush make --working-copy --force-gitinfofile --no-core -y --contrib-destination=. makefile/site.make'