From c0fb331bfd2139efcd0215896ce89932c46c45d9 Mon Sep 17 00:00:00 2001 From: Toby Bellwood Date: Thu, 2 Nov 2023 16:05:44 +1100 Subject: [PATCH] docker compose v2 tweaks --- README.md | 7 +++-- TESTING_dockercompose.md | 64 ++++++++++++++++++++-------------------- docker-compose.yml | 12 ++++---- 3 files changed, 42 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 4dfa2d4..4599cca 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Base template for Drupal projects hosted on Lagoon +# Base template for Drupal OpenSearch projects hosted on Lagoon This template includes everything necessary to run on [Lagoon](https://www.github.com/uselagoon/lagoon) (in both the local development environments or on hosted Lagoon clusters.) @@ -12,6 +12,7 @@ This example contains the following services: * PHP 8 * NGINX * MariaDB 10.11 +* OpenSearch 2 To see similar projects with additional services, please visit https://github.com/lagoon-examples and to find out more about the services, please visit the documentation at https://docs.lagoon.sh/lagoon @@ -37,8 +38,8 @@ To see similar projects with additional services, please visit https://github.co 3. Build and start the build images: ```bash - docker-compose up -d - docker-compose exec cli composer install + docker compose up -d + docker compose exec cli composer install ``` 4. Visit the new site @ `http://drupal-opensearch.docker.amazee.io` diff --git a/TESTING_dockercompose.md b/TESTING_dockercompose.md index 83130d0..5e45d5a 100644 --- a/TESTING_dockercompose.md +++ b/TESTING_dockercompose.md @@ -1,7 +1,7 @@ Docker Compose Drupal Opensearch option - php8, nginx, mariadb, opensearch ============================================================================ -This is a docker-compose version of the Lando example tests: +This is a docker compose version of the Lando example tests: Start up tests -------------- @@ -12,10 +12,10 @@ Run the following commands to get up and running with this example. # Should remove any previous runs and poweroff sed -i -e "/###/d" docker-compose.yml docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network -docker-compose down +docker compose down # Should start up our Lagoon Drupal site successfully -docker-compose build && docker-compose up -d +docker compose build && docker compose up -d # Ensure mariadb pod is ready to connect docker run --rm --net drupal-opensearch_default amazeeio/dockerize dockerize -wait tcp://mariadb:3306 -timeout 1m @@ -28,66 +28,66 @@ Run the following commands to validate things are rolling as they should. ```bash # Should be able to site install via Drush -docker-compose exec -T cli bash -c "drush si -y" -docker-compose exec -T cli bash -c "drush cr -y" -docker-compose exec -T cli bash -c "drush status" | grep "Drupal bootstrap" | grep "Successful" +docker compose exec -T cli bash -c "drush si -y" +docker compose exec -T cli bash -c "drush cr -y" +docker compose exec -T cli bash -c "drush status" | grep "Drupal bootstrap" | grep "Successful" # Should have all the services we expect -docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch_nginx_1 -docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch_mariadb_1 -docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch_php_1 -docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch_cli_1 -docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch_opensearch_1 +docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch-nginx-1 +docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch-mariadb-1 +docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch-php-1 +docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch-cli-1 +docker ps --filter label=com.docker.compose.project=drupal-opensearch | grep Up | grep drupal-opensearch-opensearch-1 # Should ssh against the cli container by default -docker-compose exec -T cli bash -c "env | grep LAGOON=" | grep cli-drupal +docker compose exec -T cli bash -c "env | grep LAGOON=" | grep cli-drupal # Should have the correct environment set -docker-compose exec -T cli bash -c "env" | grep LAGOON_ROUTE | grep drupal-opensearch.docker.amazee.io -docker-compose exec -T cli bash -c "env" | grep LAGOON_ENVIRONMENT_TYPE | grep development +docker compose exec -T cli bash -c "env" | grep LAGOON_ROUTE | grep drupal-opensearch.docker.amazee.io +docker compose exec -T cli bash -c "env" | grep LAGOON_ENVIRONMENT_TYPE | grep development # Should be running PHP 8 -docker-compose exec -T cli bash -c "php -v" | grep "PHP 8" +docker compose exec -T cli bash -c "php -v" | grep "PHP 8" # Should have composer -docker-compose exec -T cli bash -c "composer --version" +docker compose exec -T cli bash -c "composer --version" # Should have php cli -docker-compose exec -T cli bash -c "php --version" +docker compose exec -T cli bash -c "php --version" # Should have drush -docker-compose exec -T cli bash -c "drush --version" +docker compose exec -T cli bash -c "drush --version" # Should have npm -docker-compose exec -T cli bash -c "npm --version" +docker compose exec -T cli bash -c "npm --version" # Should have node -docker-compose exec -T cli bash -c "node --version" +docker compose exec -T cli bash -c "node --version" # Should have yarn -docker-compose exec -T cli bash -c "yarn --version" +docker compose exec -T cli bash -c "yarn --version" # Should have a running Drupal site served by nginx on port 8080 -docker-compose exec -T cli bash -c "curl -kL http://nginx:8080" | grep "Drush Site-Install" +docker compose exec -T cli bash -c "curl -kL http://nginx:8080" | grep "Drush Site-Install" # Should have Opensearch running -docker-compose exec -T cli bash -c "curl -kL http://opensearch:9200" | grep "docker-cluster" +docker compose exec -T cli bash -c "curl -kL http://opensearch:9200" | grep "docker-cluster" # Should have Opensearch cluster healthy -docker-compose exec -T cli bash -c "curl -kL http://opensearch:9200/_cluster/health" | json_pp | grep status | grep -v red +docker compose exec -T cli bash -c "curl -kL http://opensearch:9200/_cluster/health" | json_pp | grep status | grep -v red # Should be able to db-export and db-import the database -docker-compose exec -T cli bash -c "drush sql-dump --result-file /app/test.sql" -docker-compose exec -T cli bash -c "drush sql-drop -y" -docker-compose exec -T cli bash -c "drush sql-cli < /app/test.sql" -docker-compose exec -T cli bash -c "rm test.sql*" +docker compose exec -T cli bash -c "drush sql-dump --result-file /app/test.sql" +docker compose exec -T cli bash -c "drush sql-drop -y" +docker compose exec -T cli bash -c "drush sql-cli < /app/test.sql" +docker compose exec -T cli bash -c "rm test.sql*" # Should be able to show the drupal tables -docker-compose exec -T cli bash -c "drush sqlq \'show tables;\'" | grep users +docker compose exec -T cli bash -c "drush sqlq \'show tables;\'" | grep users # Should be able to rebuild and persist the database -docker-compose build && docker-compose up -d -docker-compose exec -T cli bash -c "drush sqlq \'show tables;\'" | grep users +docker compose build && docker compose up -d +docker compose exec -T cli bash -c "drush sqlq \'show tables;\'" | grep users ``` Destroy tests @@ -97,5 +97,5 @@ Run the following commands to trash this app like nothing ever happened. ```bash # Should be able to destroy our Drupal site with success -docker-compose down --volumes --remove-orphans +docker compose down --volumes --remove-orphans ``` diff --git a/docker-compose.yml b/docker-compose.yml index 43a6d46..a742e0d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ x-environment: LAGOON_ROUTE: &default-url http://${COMPOSE_PROJECT_NAME:-drupal-opensearch}.docker.amazee.io # Uncomment if you like to have the system behave like in production #LAGOON_ENVIRONMENT_TYPE: production - # Uncomment to enable xdebug and then restart via `docker-compose up -d` + # Uncomment to enable xdebug and then restart via `docker compose up -d` #XDEBUG_ENABLE: "true" x-user: @@ -58,10 +58,10 @@ services: lagoon.persistent: /app/web/sites/default/files/ # define where the persistent storage should be mounted too lando.type: nginx-drupal ports: - - "8080" # exposes the port 8080 with a random local port, find it with `docker-compose port nginx 8080` + - "8080" # exposes the port 8080 with a random local port, find it with `docker compose port nginx 8080` << : [*default-volumes, *default-user] depends_on: - - cli # basically just tells docker-compose to build the cli first + - cli # basically just tells docker compose to build the cli first environment: << : *default-environment # loads the defined environment variables from the top LAGOON_LOCALDEV_URL: *default-url @@ -82,7 +82,7 @@ services: lando.type: php-fpm << : [*default-volumes, *default-user] depends_on: - - cli # basically just tells docker-compose to build the cli first + - cli # basically just tells docker compose to build the cli first environment: << : *default-environment # loads the defined environment variables from the top @@ -92,7 +92,7 @@ services: lagoon.type: mariadb lando.type: mariadb-drupal ports: - - "3306" # exposes the port 3306 with a random local port, find it with `docker-compose port mariadb 3306` + - "3306" # exposes the port 3306 with a random local port, find it with `docker compose port mariadb 3306` << : *default-user # uses the defined user from top environment: << : *default-environment @@ -105,7 +105,7 @@ services: lagoon.type: opensearch lando.type: opensearch ports: - - "9200" # exposes the port 9200 with a random local port, find it with `docker-compose port opensearch 9200` + - "9200" # exposes the port 9200 with a random local port, find it with `docker compose port opensearch 9200` environment: << : *default-environment volumes: