Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DEVOPS-394] Upgraded to docker compose v2. #79

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,110 +5,110 @@ commands:
up:
usage: Build project.
cmd: |
docker-compose up -d "$@" &&
docker-compose exec -T test dockerize -wait tcp://mariadb:3306 -timeout 2m &&
docker compose up -d "$@" &&
docker compose exec -T test dockerize -wait tcp://mariadb:3306 -timeout 2m &&
ahoy info;

down:
usage: Delete project (CAUTION).
cmd: |
if [ "$1" == "y" ]; then
docker-compose down --volumes
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 --volumes ||
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 "$@" &&
docker-compose exec -T test dockerize -wait tcp://mariadb:3306 -timeout 2m &&
docker compose up -d --build "$@" &&
docker compose exec -T test dockerize -wait tcp://mariadb:3306 -timeout 2m &&
ahoy govcms-deploy && ahoy info;

cli:
usage: Start a shell inside cli container.
cmd: docker-compose exec cli bash
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 (e.g. config import, updb, cr, set up file_stage_proxy).
cmd: |
docker-compose exec -T cli mkdir -p /app/web/sites/default/files/private/tmp && \
docker-compose exec -T cli /app/vendor/bin/govcms-db-update && \
docker-compose exec -T cli /app/vendor/bin/govcms-config-import && \
docker-compose exec -T cli /app/vendor/bin/govcms-cache-rebuild && \
docker-compose exec -T cli /app/vendor/bin/govcms-enable_modules
docker compose exec -T cli mkdir -p /app/web/sites/default/files/private/tmp && \
docker compose exec -T cli /app/vendor/bin/govcms-db-update && \
docker compose exec -T cli /app/vendor/bin/govcms-config-import && \
docker compose exec -T cli /app/vendor/bin/govcms-cache-rebuild && \
docker compose exec -T cli /app/vendor/bin/govcms-enable_modules

drush:
usage: Run drush commands in cli container.
cmd: docker-compose exec -T cli drush "$@"
cmd: docker compose exec -T cli drush "$@"

logs:
usage: Show Docker logs.
cmd: docker-compose logs "$@"
cmd: docker compose logs "$@"

ps:
usage: List running Docker containers.
cmd: docker-compose ps
cmd: docker compose ps

restart:
usage: Restart Docker containers.
cmd: docker-compose restart
cmd: docker compose restart

stop:
usage: Stop Docker containers.
cmd: docker-compose stop "$@"
cmd: docker compose stop "$@"

install:
usage: Install the profile.
cmd: docker-compose exec -T cli drush si -y govcms "$@" && ahoy govcms-deploy
cmd: docker compose exec -T cli drush si -y govcms "$@" && ahoy govcms-deploy

login:
usage: Login to a website.
cmd: |
docker-compose exec -T cli drush -y cset tfa.settings reset_pass_skip_enabled true && \
docker-compose exec -T cli drush uinf --uid 1 --field name | xargs docker-compose exec -T cli drush uublk && \
docker-compose exec -T cli drush uli
docker compose exec -T cli drush -y cset tfa.settings reset_pass_skip_enabled true && \
docker compose exec -T cli drush uinf --uid 1 --field name | xargs docker compose exec -T cli drush uublk && \
docker compose exec -T cli drush uli

unloop:
usage: Fix local redirect loop
cmd: |
docker-compose exec -T cli drush ev '$u=\Drupal\user\Entity\User::load(1); $u->set("field_password_expiration", "0"); $u->save()' && \
docker-compose exec -T cli drush ev '$u=\Drupal\user\Entity\User::load(1); $u->set("field_last_password_reset", date("Y-m-d\TH:i:s")); $u->save()'
docker compose exec -T cli drush ev '$u=\Drupal\user\Entity\User::load(1); $u->set("field_password_expiration", "0"); $u->save()' && \
docker compose exec -T cli drush ev '$u=\Drupal\user\Entity\User::load(1); $u->set("field_last_password_reset", date("Y-m-d\TH:i:s")); $u->save()'

mysql-import:
usage: Pipe in a sql file. `ahoy mysql-import local.sql`
cmd: |
if [ -e "$@" ] ; then
docker-compose exec cli bash -c 'drush sql-drop' &&
docker-compose exec -T cli bash -c 'drush sql-cli' < "$@"
docker compose exec cli bash -c 'drush sql-drop' &&
docker compose exec -T cli bash -c 'drush sql-cli' < "$@"
else echo "Provided sql file" "$@" "does not exist"
fi

mysql-dump:
usage: Dump data out into a file. `ahoy mysql-dump local.sql`
cmd: docker-compose exec -T cli bash -c 'drush sql-dump --ordered-dump' > "$@"
cmd: docker compose exec -T cli bash -c 'drush sql-dump --ordered-dump' > "$@"

lint:
usage: Lint code
cmd: |
docker-compose exec -T test ./vendor/bin/govcms-lint web/modules/custom
docker-compose exec -T test ./vendor/bin/govcms-lint web/themes/custom
docker compose exec -T test ./vendor/bin/govcms-lint web/modules/custom
docker compose exec -T test ./vendor/bin/govcms-lint web/themes/custom

test-behat:
usage: Run Behat tests.
cmd: docker-compose exec -T test ./vendor/bin/govcms-behat "$@"
cmd: docker compose exec -T test ./vendor/bin/govcms-behat "$@"

test-phpunit:
usage: Run phpunit tests
cmd: docker-compose exec -T test ./vendor/bin/govcms-phpunit --testsuite govcms
cmd: docker compose exec -T test ./vendor/bin/govcms-phpunit --testsuite govcms

pull:
usage: Pull latest docker images.
Expand All @@ -119,14 +119,14 @@ 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; docker-compose rm -f -s -v mariadb && 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..."

ship-shape:
usage: Run site validation scripts locally
cmd: |
docker-compose exec -T cli shipshape -f /app/vendor/govcms/scaffold-tooling/shipshape.yml --exclude-db --error-code "$@"
docker compose exec -T cli shipshape -f /app/vendor/govcms/scaffold-tooling/shipshape.yml --exclude-db --error-code "$@"

debug:
usage: Enable debug configuration.
Expand All @@ -139,7 +139,7 @@ commands:
cmd: |
echo "Project : " $(ahoy run "echo \$LAGOON_PROJECT")
echo "Site local URL : " $(ahoy run "echo \$LAGOON_ROUTE")
echo "DB port on host : " $(docker port $(docker-compose ps -q mariadb) 3306 | cut -d : -f 2)
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
Expand Down
2 changes: 1 addition & 1 deletion .docker/config/test/sample.profile.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: 'Drupal 8 Sample Audit - run with docker-compose exec -T test drutiny profile:run sample @self'
title: 'Drupal 8 Sample Audit - run with docker compose exec -T test drutiny profile:run sample @self'
format:
html:
template: govcms-page
Expand Down
2 changes: 1 addition & 1 deletion .env.default
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# This file contains per-project environment variables.
# It is used by Ahoy, Docker-compose, Lagoon, and other scripts to read default values.
# Copy this file to '.env' to make docker-compose use overridden values.
# Copy this file to '.env' to make docker compose use overridden values.
#

# https://govcms.gov.au/wiki-vars#COMPOSE_PROJECT_NAME
Expand Down
2 changes: 1 addition & 1 deletion custom/ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ commands:

drush-local:
usage: Return the output without line wrapping.
cmd: docker-compose exec -e 120 -T cli drush "$@"
cmd: docker compose exec -e 120 -T cli drush "$@"

# mycustomcommand:
# cmd: |
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '2.3'

# This value intentionally matches the project name on Lagoon.
# It is used to name the CLI_IMAGE to use as a build arg locally.
x-lagoon-project: &lagoon-project
Expand Down Expand Up @@ -133,7 +131,7 @@ services:
lagoon.type: mariadb
lagoon.image: govcms/mariadb-drupal:{{ GOVCMS_VERSION }}.x-latest
ports:
- "3306" # Find port on host with `docker-compose port mariadb 3306`
- "3306" # Find port on host with `docker compose port mariadb 3306`
environment:
<< : *default-environment

Expand All @@ -152,7 +150,7 @@ services:
# labels:
# lagoon.type: solr
# ports:
# - "8983" # Find port on host with `docker-compose port solr 8983`
# - "8983" # Find port on host with `docker compose port solr 8983`
# depends_on:
# - cli
# environment:
Expand Down