Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Commit

Permalink
Prepare v1.1.3 release (#36)
Browse files Browse the repository at this point in the history
* Update cron to be hourly.
* Documentation consolidation and improvement. (#31)
* Added removal of dangling volumes on `ahoy down`. (#24)
* Fixed `ahoy refresh-db` command not using newly pulled DB image. (#34)
* New lagoon.yml for pre/post rollout task split. (#33)
* New lagoon.yml for pre/post rollout tasks
* Added 'ahoy info' command. (#23)
* Fixed 'ahoy run' requiring wrapping all arguments into quotes. (#25)
* Fail deployment on failed docker stack in 'ahoy build'. (#22)
* Added 'ahoy debug' command. (#21)
* Fixed 'ahoy debug' command rebuilds DB container.
* Update .version.yml
  • Loading branch information
SRowlands authored Dec 16, 2019
1 parent a7f462c commit c3b6bd2
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 112 deletions.
26 changes: 21 additions & 5 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ commands:
usage: Delete project (CAUTION).
cmd: |
if [ "$1" == "y" ]; then
docker-compose down
docker-compose down --volumes
else
ahoy confirm "Running this command will destroy your current site, database and build? Are you sure you didn't mean ahoy stop?" &&
# Run this if confirm returns true
docker-compose down ||
docker-compose down --volumes ||
# Run this if confirm returns false
echo "OK, probably a wise choice..."
fi
build:
usage: Build project.
cmd: docker-compose up -d --build "$@"; ahoy govcms-deploy
cmd: docker-compose up -d --build "$@" && ahoy govcms-deploy && ahoy info

cli:
usage: Start a shell inside cli container.
cmd: docker-compose exec cli bash

run:
usage: Run command inside cli container.
cmd: docker-compose exec -T cli bash -c "$@"
cmd: docker-compose exec -T cli bash -c "$*"

govcms-deploy:
usage: Runs deployment commands (config import, updb, cr, set up file_stage_proxy)
Expand Down Expand Up @@ -120,14 +120,30 @@ commands:
cmd: |
ahoy confirm "Running this command will replace your current database. Are you sure?" &&
# Run this if confirm returns true
cat .env | grep MARIADB_DATA_IMAGE | cut -c20- | xargs -n1 docker pull && ahoy up ||
cat .env | grep MARIADB_DATA_IMAGE | cut -c20- | xargs -n1 docker pull && docker-compose rm -f -s -v mariadb && ahoy up ||
# Run this if confirm returns false
echo "OK, probably a wise choice..."
audit-site:
usage: Run site audit
cmd: docker-compose exec -T test drutiny profile:run ci @self "$@"

debug:
usage: Enable debug configuration.
cmd: |
{ ahoy run "php -v|grep -q Xdebug" && echo "Debug is already enabled"; } \
|| { export XDEBUG_ENABLE="true" && ahoy up cli test php && ahoy run "php -v|grep -q Xdebug" && echo "Enabled debug configuration. Use 'ahoy up' to disable."; }
info:
usage: Print information about this project.
cmd: |
echo "Project : " $(ahoy run "echo \$LAGOON_PROJECT")
echo "Site local URL : " $(ahoy run "echo \$LOCALDEV_URL")
echo "DB port on host : " $(docker port $(docker-compose ps -q mariadb) 3306 | cut -d : -f 2)
if [ "$1" ]; then
echo "One-time login : " $(ahoy login -- --no-browser)
fi
confirm:
cmd: |
read -r -p "$@ [y/N] " response
Expand Down
2 changes: 2 additions & 0 deletions .lagoon.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Do not remove. This location may be used by deployment scripts for database and config snapshots.
SNAPSHOTS=/app/web/sites/default/files/private/backups
81 changes: 72 additions & 9 deletions .lagoon.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,82 @@
docker-compose-yaml: docker-compose.yml

tasks:
post-rollout:
- run:
name: Deploy GovCMS
command: govcms-deploy
service: cli

environments:
master:
types:
mariadb: mariadb-shared

cronjobs:
- name: drush cron
schedule: "*/15 * * * *"
schedule: "0 * * * *"
command: 'drush cron --root=/app'
service: cli

# Note regarding tasks in the scaffold.
# Please avoid making scripts more than one or two lines, and avoid if/else logic.
# When PaaS users or the support team modify this file, it should be easy to turn things on and off.

tasks:
pre-rollout:
- run:
name: Ensure backup folder exists - not all current envs have one
command: mkdir -p /app/web/sites/default/files/private/backups
service: cli
shell: bash
- run:
name: Snapshot the database and store
command: if [[ "$LAGOON_ENVIRONMENT_TYPE" = "production" ]]; then drush sql:dump --root=/app --gzip --result-file=/app/web/sites/default/files/private/backups/pre-deploy-dump.sql; fi
service: cli
shell: bash
- run:
name: Snapshot the config and store
command: if [[ $(drush cex --root=/app sync -y --quiet --destination "$TMP"/config; echo "$?") = 0 ]]; then tar -czf /app/web/sites/default/files/private/backups/pre-deploy-config.tar.gz "$TMP"/config --remove-files; fi
service: cli
shell: bash

post-rollout:
- run:
name: Correct legacy drush alias if necessary
command: sed -i "s/%%PROJECT_NAME%%/\${env.LAGOON_PROJECT}/g" /app/drush/sites/govcms.site.yml
service: cli
shell: bash
- run:
name: Ensure backup folder exists
command: mkdir -p /app/web/sites/default/files/private/backups
service: cli
shell: bash
- run:
name: If a new environment populate database from master
command: drush status db-status | grep Connected || if [[ "$LAGOON_ENVIRONMENT_TYPE" != "production" ]]; then drush sql:sync @govcms.prod @self -y; fi
service: cli
shell: bash
- run:
name: Perform database updates
command: drush -y updatedb
service: cli
shell: bash
- run:
name: Perform config import (uncomment to enable)
command: |
# drush cim -y sync && if [[ "$LAGOON_ENVIRONMENT_TYPE" != "production" ]]; then drush cim -y --partial --source=../config/dev; fi
service: cli
shell: bash
- run:
name: Perform cache rebuild
command: drush -y cr
service: cli
shell: bash
- run:
name: Ensure GovCMS/Lagoon modules are enabled
command: drush en -y govcms_lagoon && drush pmu -y govcms_lagoon
service: cli
shell: bash
- run:
name: Enable any non-production modules
command: if [[ "$LAGOON_ENVIRONMENT_TYPE" != "production" ]]; then drush en stage_file_proxy -y; fi
service: cli
shell: bash
- run:
name: Preserve the last successful backup
command: export BACKUP="/app/web/sites/default/files/private/backups/pre-deploy-dump" && mv "$BACKUP.sql.gz" "$BACKUP-last-good.sql.gz" || true
service: cli
shell: bash

2 changes: 1 addition & 1 deletion .version.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version: 8
type: saas
scaffold: 1.1.2
scaffold: 1.1.3
112 changes: 15 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,104 +1,22 @@
# GovCMS8 Project Scaffolding
# GovCMS8 SaaS Project Scaffolding

## Known Issues
This is a composer project which builds a Drupal 8 GovCMS **SaaS** site ready for
hosting on the GovCMS platform (Lagoon).

* This repository is still a Work-in-Progress, and may be subject to slight alterations
**Note**: If you are a new GovCMS customer visiting this page on
[Github](https://github.com/govCMS/govcms8-scaffold)
you may prefer to wait for the GovCMS service desk to create your project in Gitlab.

## Requirements and Preliminary Setup
For testing GovCMS separately to the GovCMS platform, we recommend that you try
our [PaaS scaffold](https://github.com/govCMS/govcms8-scaffold-paas)
which has a more conventional Drupal 8 structure.

* [Docker](https://docs.docker.com/install/) - Follow documentation at https://docs.amazee.io/local_docker_development/local_docker_development.html to configure local development environment.
## Next steps

* [Mac/Linux](https://docs.amazee.io/local_docker_development/pygmy.html) - Make sure you don't have anything running on port 80 on the host machine (like a web server):
* [Drupal/GovCMS distribution](https://govcms.gov.au/wiki_distro)
* [GovCMS Platform](https://govcms.gov.au/wiki_platform)

gem install pygmy
pygmy up
## Customising this README

* [Windows](https://docs.amazee.io/local_docker_development/windows.html):

git clone https://github.com/amazeeio/amazeeio-docker-windows amazeeio-docker-windows; cd amazeeio-docker-windows
docker-compose up -d; cd ..

* [Ahoy (optional)](http://ahoy-cli.readthedocs.io/en/latest/#installation) - The commands are listed in `.ahoy.yml` all include their docker-compose versions for use on Windows, or on systems without Ahoy.

## Project Setup

1. Checkout project repo and confirm the path is in Docker's file sharing config (https://docs.docker.com/docker-for-mac/#file-sharing):

Mac/Linux: git clone https://www.github.com/govcms/govcms8-scaffold.git {INSERT_PROJECT_NAME} && cd $_
Windows: git clone https://www.github.com/govcms/govcms8-scaffold.git {INSERT_PROJECT_NAME}; cd {INSERT_PROJECT_NAME}

2. Build and start the containers:

Mac/Linux: ahoy up
Windows: docker-compose up -d

3. Install GovCMS (only do this if you are building a new site - otherwise see the Databases section below):

Mac/Linux: ahoy install
Windows: docker-compose exec -T test drush si -y govcms

4. Login to Drupal:

Mac/Linux: ahoy login
Windows: docker-compose exec -T test drush uli

## Commands

Additional commands are listed in `.ahoy.yml`, or available from the command line `ahoy -v`

## Databases

The GovCMS projects have been designed to be able to import a nightly copy of the latest `master` branch database in two ways:

1: Using the GitLab container registry nightly backup
* these instructions are for https://projects.govcms.gov.au/{org}/{project}/container_registry
* copy the .env.default file to .env on your local
* remove the # from in front of #MARIADB_DATA_IMAGE=gitlab-registry-production.govcms.amazee.io/{org}/{project}/mariadb-drupal-data
* add a GitLab Personal Access Token with `read_registry` scope (profile/personal_access_tokens)
* `docker login gitlab-registry-production.govcms.amazee.io` (and use the PAT created above as the password)
* `ahoy up` (or the docker-compose equivalent)
* to refresh the db with a newer version, run `ahoy up` again

2: Use the backups accessible via the UI
* head to https://dashboard.govcms.gov.au/backups?name={project}-master
* click "Prepare download" for the most recent mysql backup you want - note that you will have to refresh the page to see when it is complete.
* download that backup into your project folder.
* `ahoy mysql-import` to import the dump you just saved

## Development

* You should create your theme(s) in folders under `/themes`
* Tests specific to your site can be committed to the `/tests` folders
* The files folder is not (currently) committed to GitLab.
* Do not make changes to `docker-compose.yml`, `lagoon.yml`, `.gitlab-ci.yml` or the Dockerfiles under `/.docker` - these will result in your project being unable to deploy to GovCMS SaaS

## Image inheritance

This project is designed to provision a Drupal 8 project onto GovCMS SaaS, using the GovCMS8 distribution, and has been prepared thus

1. The vanilla GovCMS8 Distribution is available at [Github Source](https://github.com/govcms/govcms8) and as [Public DockerHub images](https://hub.docker.com/r/govcms8)
2. Those GovCMS8 images are then customised for Lagoon and GovCMS, and are available at [Github Source](https://github.com/govcms/govcms8lagoon) and as [Public DockerHub images](https://hub.docker.com/r/govcms8lagoon)
3. Those GovCMS8lagoon images are then retrieved in this scaffold repository.

## Configuration management

GovCMS8 has default configuration management built in. It assumes all configuration is tracked (in `config/default`).

1. Export latest configuration to `config/default`:

Mac/Linux: ahoy cex
Windows: docker-compose exec -T test drush cex sync

2. Import any configuration changes from `config/default`:

Mac/Linux: ahoy cim
Windows: docker-compose exec -T test drush cim sync

3. Import development environment configuration overrides:

Mac/Linux: ahoy cim dev
Windows: docker-compose exec -T test drush cim dev --partial


*Note*: Configuration overrides are snippets of configuration that may be imported over the base configuration. These (optional) files should exist in `config/dev`.
For example a development project may include a file such as `config/dev/shield.settings.yml` which provides Shield authentication configuration that would only apply to a development environment, not production.
If you have cloned this project from GovCMS Gitlab, you may customise this README
with specific information about your site.
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ x-environment:
GOVCMS_IMAGE_VERSION: ${GOVCMS_IMAGE_VERSION:-latest}
DEV_MODE: ${DEV_MODE:-false}
X_FRAME_OPTIONS: ${X_FRAME_OPTIONS:-SameOrigin}
# Allow to override docker host used from the inside of the containers.
DOCKERHOST: ${DOCKERHOST:-}
XDEBUG_ENABLE: ${XDEBUG_ENABLE:-}

services:

Expand Down

0 comments on commit c3b6bd2

Please sign in to comment.