Skip to content

Docker stack to run the trendsa.org.au drupal site

Notifications You must be signed in to change notification settings

ternandsparrow/trendsa-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drupal stack to run the TrendSA website

To run

Dependencies:

  1. docker 18.09
  2. docker-compose 1.17
  3. a drush dump (files and DB) of the site

Steps:

  1. copy the runner script
    cp start-or-restart.sh.example start-or-restart.sh
    chmod +x start-or-restart.sh
  2. edit the runner script start-or-restart.sh to define the needed sensitive environmental variables
    vim start-or-restart.sh
  3. start the stack
    ./start-or-restart.sh
    # or if you need to force a rebuild of the child docker images, which you should do after a `git pull`
    ./start-or-restart.sh --build
  4. copy the drush dump archive into the drush container
    docker cp /path/to/website.20181127_053515.tar.gz trend_drush:/tmp/
  5. exec into the drush container
    docker exec -it trend_drush sh
  6. create the mysql DB
    # in drush container
    echo 'CREATE DATABASE website;' | mysql -u root -p$MYSQL_PASS -h mysql
  7. restore the drush archive
    # still in drush container
    drush arr /tmp/website.20181127_053515.tar.gz \
      --db-url=mysql://root:$MYSQL_PASS@mysql/website \
      --destination=$DRUPAL_DIR \
      --overwrite
  8. delete the dump archive
    # still in drush container
    rm /tmp/website.20181127_053515.tar.gz
  9. exit the drush container
    # still in drush container
    exit
    # (no longer in drush container)
  10. copy the settings.php file out to the host, so we can edit it
    docker cp trend_drush:/var/www/html/sites/default/settings.php /tmp/settings.php
    sudo chown `id -u` /tmp/settings.php
    chmod 644 /tmp/settings.php
  11. edit the /tmp/settings.php file you have on your host to replace the old DB config (top of the file) with the new DB config at the bottom of the file. Then save it.
  12. copy the settings.php file from the host back into the container
    docker cp /tmp/settings.php trend_drush:/var/www/html/sites/default/settings.php
  13. open your browser on the host to view the Drupal site: http://localhost:8080, or whatever you set EXTERNAL_LISTEN_PORT to

Stopping the stack

The stack is designed to always keep running, even after a server restart, until you manually stop it. The data for mysql, drupal and the backups are stored in Docker data volumes. This means you can stop and destroy the stack, but keep the data with:

docker-compose down

If you want to completely clean up and have the data volumes also removed, you can do this with:

docker-compose down --volumes

Creating a static copy of the site

In the case where we need to keep the site running but we don't expect any new content, we can dump it to a static copy and run that on something simple like AWS S3.

You can get the static site by:

wget --mirror http://localhost:8080

This will write the site to a localhost:8080 directory. You can then upload the data to S3 with something like (not tested):

# upload all the top level HTML pages and force content-type
find . -type f -maxdepth 1 -exec aws s3 cp '{}' s3://trendsa.org.au --content-type="text/html; charset=utf-8" --acl=public-read \;
# upload the rest, which does ok with guessing content-type
aws s3 sync . s3://trendsa.org.au --acl=public-read

Then make sure that S3 bucket is enabled as a static website and set the home page to index.html.

This isn't perfect but it's pretty good. It doesn't handle redirects from querystrings like the footer links to copyright, disclaimer, etc. The content is there but the links don't work. Oh well.

About

Docker stack to run the trendsa.org.au drupal site

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published