Skip to content

Commit

Permalink
docker compose v2 tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood committed Nov 2, 2023
1 parent 301ee63 commit c0fb331
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.)

Expand All @@ -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

Expand All @@ -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`
Expand Down
64 changes: 32 additions & 32 deletions TESTING_dockercompose.md
Original file line number Diff line number Diff line change
@@ -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
--------------
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
```
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit c0fb331

Please sign in to comment.