From c097c63b40ce91f4f07fc83523c3b21ee261fa75 Mon Sep 17 00:00:00 2001 From: Ricardo Sanz Date: Sun, 7 Jan 2024 13:46:20 +0100 Subject: [PATCH 1/6] Issue #129: Use a variable for the docker compose plugin command --- .env.example | 8 ++++++++ Makefile | 30 +++++++++++++++--------------- docker.mk | 24 ++++++++++++------------ 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/.env.example b/.env.example index f9d6f16..aa55fd7 100644 --- a/.env.example +++ b/.env.example @@ -18,6 +18,14 @@ DB_HOST=mariadb DB_PORT=3306 DB_DRIVER=mysql + +### --- Docker Compose --- +# V1 +# DOCKER_COMPOSE_CMD=docker-compose +# V2 +DOCKER_COMPOSE_CMD=docker compose + + ### --- MARIADB ---- MARIADB_TAG=10.5-3.10.0 diff --git a/Makefile b/Makefile index 213cce8..0cb4159 100644 --- a/Makefile +++ b/Makefile @@ -17,27 +17,27 @@ info: ## test : Run Unit tests. Pass the path to a file or directory with the Unit test. Example: make test web/modules/contrib/devel/tests/src/Unit .PHONY: test test: - docker-compose exec php phpunit $(filter-out $@,$(MAKECMDGOALS)) + $(DOCKER_COMPOSE_CMD) exec php phpunit $(filter-out $@,$(MAKECMDGOALS)) ## behat : Run project Behat tests .PHONY: behat behat: - docker-compose exec php ${BEHAT} --colors + $(DOCKER_COMPOSE_CMD) exec php ${BEHAT} --colors ## ngrok : Setup a ngrok tunnel to make the site available .PHONY: ngrok ngrok: - docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.ngrok.yml up -d && docker-compose exec php curl http://ngrok:4040/api/tunnels | grep -Po "https"://[^\"]+ + $(DOCKER_COMPOSE_CMD) -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.ngrok.yml up -d && $(DOCKER_COMPOSE_CMD) exec php curl http://ngrok:4040/api/tunnels | grep -Po "https"://[^\"]+ ## ngrok-stop : Stop the created ngrok tunnel .PHONY: ngrok-stop ngrok-stop: - docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.ngrok.yml stop ngrok && docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.ngrok.yml rm -fsv ngrok + $(DOCKER_COMPOSE_CMD) -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.ngrok.yml stop ngrok && $(DOCKER_COMPOSE_CMD) -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.ngrok.yml rm -fsv ngrok ## frontend : Generate frontend assets like compiling scss .PHONY: frontend frontend: - docker-compose exec -w ${FRONTEND_BASE_PATH}/$(frontend_target) node sh ${DOCKER_PROJECT_ROOT}/scripts/frontend-build.sh $(filter-out $@,$(MAKECMDGOALS)) + $(DOCKER_COMPOSE_CMD) exec -w ${FRONTEND_BASE_PATH}/$(frontend_target) node sh ${DOCKER_PROJECT_ROOT}/scripts/frontend-build.sh $(filter-out $@,$(MAKECMDGOALS)) ## backstopjs-reference : Generate BackstopJS reference files ## An optional parameter is available to generate only scenarios matching it. @@ -48,7 +48,7 @@ frontend: ## Example: make backstopjs_type=environment/pro backstopjs-test .PHONY: backstopjs-reference backstopjs-reference: - docker-compose exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop reference --filter='$(filter-out $@,$(MAKECMDGOALS))'" + $(DOCKER_COMPOSE_CMD) exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop reference --filter='$(filter-out $@,$(MAKECMDGOALS))'" ## backstopjs-test : Run BackstopJS tests ## An optional parameter is available to generate only scenarios matching it. @@ -59,7 +59,7 @@ backstopjs-reference: ## Example: make backstopjs_type=environment/pro backstopjs-test .PHONY: backstopjs-test backstopjs-test: - docker-compose exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop test --filter='$(filter-out $@,$(MAKECMDGOALS))'" + $(DOCKER_COMPOSE_CMD) exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop test --filter='$(filter-out $@,$(MAKECMDGOALS))'" ## setup-init : Prepares the site .PHONY: setup-init @@ -69,18 +69,18 @@ setup-init: cp docker-compose.override.yml.dist docker-compose.override.yml cp web/sites/${SITE}/example.settings.local.php web/sites/${SITE}/settings.local.php cp web/sites/${SITE}/example.local.drush.yml web/sites/${SITE}/local.drush.yml - docker-compose up -d - docker-compose exec -T php composer install - docker-compose run -e'PHP_ERROR_REPORTING=E_ALL & ~E_DEPRECATED' --rm -T php 'vendor/bin/grumphp' 'git:init' + $(DOCKER_COMPOSE_CMD) up -d + $(DOCKER_COMPOSE_CMD) exec -T php composer install + $(DOCKER_COMPOSE_CMD) run -e'PHP_ERROR_REPORTING=E_ALL & ~E_DEPRECATED' --rm -T php 'vendor/bin/grumphp' 'git:init' ## setup : Prepares the site and installs it using the Drupal configuration files .PHONY: setup setup: make setup-init - docker-compose exec -T php drush @${SITE}.local si ${PROFILE} --existing-config --sites-subdir=${SITE} -y - docker-compose exec -T php drush @${SITE}.local cim -y - docker-compose exec -T php drush @${SITE}.local cr - docker-compose exec -T php drush @${SITE}.local uli + $(DOCKER_COMPOSE_CMD) exec -T php drush @${SITE}.local si ${PROFILE} --existing-config --sites-subdir=${SITE} -y + $(DOCKER_COMPOSE_CMD) exec -T php drush @${SITE}.local cim -y + $(DOCKER_COMPOSE_CMD) exec -T php drush @${SITE}.local cr + $(DOCKER_COMPOSE_CMD) exec -T php drush @${SITE}.local uli ## setup-from-environment : Prepares the site and loads it with data from the reference site .PHONY: setup-from-environment @@ -96,4 +96,4 @@ solr-sync: ## solr-rebuild : Re-creates the Solr core .PHONY: solr-rebuild solr-rebuild: - docker-compose stop solr && docker-compose rm -f solr && docker-compose up -d solr && make solr-sync + $(DOCKER_COMPOSE_CMD) stop solr && $(DOCKER_COMPOSE_CMD) rm -f solr && $(DOCKER_COMPOSE_CMD) up -d solr && make solr-sync diff --git a/docker.mk b/docker.mk index 6eebec9..ffce7cb 100644 --- a/docker.mk +++ b/docker.mk @@ -16,12 +16,12 @@ help : .PHONY: up up: @echo "Starting up containers for $(PROJECT_NAME)..." - docker-compose pull - docker-compose up -d --remove-orphans + $(DOCKER_COMPOSE_CMD) pull + $(DOCKER_COMPOSE_CMD) up -d --remove-orphans .PHONY: mutagen mutagen: - docker-compose up -d mutagen + $(DOCKER_COMPOSE_CMD) up -d mutagen mutagen project start -f mutagen/config.yml ## down : Stop containers. @@ -32,13 +32,13 @@ down: stop .PHONY: start start: @echo "Starting containers for $(PROJECT_NAME) from where you left off..." - @docker-compose start + @$(DOCKER_COMPOSE_CMD) start ## stop : Stop containers. .PHONY: stop stop: @echo "Stopping containers for $(PROJECT_NAME)..." - @docker-compose stop + @$(DOCKER_COMPOSE_CMD) stop ## prune : Remove containers and their volumes. ## You can optionally pass an argument with the service name to prune single container @@ -47,7 +47,7 @@ stop: .PHONY: prune prune: @echo "Removing containers for $(PROJECT_NAME)..." - @docker-compose down -v $(filter-out $@,$(MAKECMDGOALS)) + @$(DOCKER_COMPOSE_CMD) down -v $(filter-out $@,$(MAKECMDGOALS)) ## ps : List running containers. .PHONY: ps @@ -80,23 +80,23 @@ drush: ## logs nginx php : View `nginx` and `php` containers logs. .PHONY: logs logs: - @docker-compose logs -f $(filter-out $@,$(MAKECMDGOALS)) + @$(DOCKER_COMPOSE_CMD) logs -f $(filter-out $@,$(MAKECMDGOALS)) ## xdebug : Enable xdebug. .PHONY: xdebug xdebug: @echo "Enabling xdebug in $(PROJECT_NAME)." @echo "¡¡CAUTION!! X-debug will only work if you have correctly configured docker-compose.xdebug.override.yml file." - docker-compose stop php - docker-compose pull php - docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.xdebug.override.yml up -d php + $(DOCKER_COMPOSE_CMD) stop php + $(DOCKER_COMPOSE_CMD) pull php + $(DOCKER_COMPOSE_CMD) -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.xdebug.override.yml up -d php ## xdebug-disable : Disable xdebug. .PHONY: xdebug-stop xdebug-stop: @echo "Disabling xdebug in $(PROJECT_NAME)." - docker-compose stop php - docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d php + $(DOCKER_COMPOSE_CMD) stop php + $(DOCKER_COMPOSE_CMD) -f docker-compose.yml -f docker-compose.override.yml up -d php # https://stackoverflow.com/a/6273809/1826109 %: From fb0a662ca8db4b6092f433f136c3cf1b50c207b5 Mon Sep 17 00:00:00 2001 From: Ricardo Sanz Date: Mon, 8 Jan 2024 10:05:27 +0100 Subject: [PATCH 2/6] Update doc with reference to docker compose v1 and v2 --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 80bd6fa..d2a5032 100644 --- a/readme.md +++ b/readme.md @@ -30,7 +30,7 @@ https://github.com/Metadrop/drupal-boilerplate/assets/776453/2b3d53c6-e2bf-4c48- ## Requisites - [Docker](https://docs.docker.com/get-docker/) - - [Docker Compose](https://docs.docker.com/compose/install/) + - [Docker Compose](https://docs.docker.com/compose/install/) with release 3.0.1 or previous. After 3.0.2 by default Docker Compose V2, [included in Docker](https://www.docker.com/blog/announcing-compose-v2-general-availability/), is used. The variable `DOCKER_COMPOSE_CMD=docker compose` can be used to select Docker Compose V1 if required. **Optionally** From ea44ad4a8b6a09d7fde64b73658d5856ff58907f Mon Sep 17 00:00:00 2001 From: Ricardo Sanz Date: Mon, 8 Jan 2024 10:07:07 +0100 Subject: [PATCH 3/6] Typos --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index d2a5032..6271970 100644 --- a/readme.md +++ b/readme.md @@ -21,7 +21,7 @@ Tools included out-of-the-box: It is based on [Docker4Drupal](https://wodby.com/docs/1.0/stacks/drupal/local/), which uses Docker and Docker Compose. To get all the information about available webservers, databases, PHP versions and other containers check their [wodby/docker4drupa repository](https://github.com/wodby/docker4drupal). -Because it uses Docker under the hood, you can customize whatever you want, add new containers or use any standard Docker funcionality to accomodate your project needs. +Because it uses Docker under the hood, you can customize whatever you want, add new containers or use any standard Docker functionality to accommodate your project needs. ## Quickview @@ -34,7 +34,7 @@ https://github.com/Metadrop/drupal-boilerplate/assets/776453/2b3d53c6-e2bf-4c48- **Optionally** - - Pyhton 3 with PyYAML installed for the `make info` command + - Python 3 with PyYAML installed for the `make info` command ## Usage @@ -50,11 +50,11 @@ Depending in the Drupal release you want you should use a different branch. | Drupal release | Boilerplate branch | Example command | |--- |--- |--- | -| 10.x | 3.x branch | composer create-project --ignore-platform-reqs metadrop/drupal-boilerplate my-project | +| 10.x | 3.x branch | composer create-project --ignore-platform-reqs metadrop/drupal-boilerplate my-project | | 9.x | 2.x branch | composer create-project --ignore-platform-reqs metadrop/drupal-boilerplate:^2 my-project | -NOTE: 2.x branch is minimally maintained because Drupal9 support ends Nomvember, 2023. +NOTE: 2.x branch is minimally maintained because Drupal9 support ends November, 2023. Because this boilerplate uses drupal/core-recommended under the hood you will get an updated release of the chosen core. From 1b9a9f9a82399f3813d58abe92c22d33ae87d47b Mon Sep 17 00:00:00 2001 From: Ricardo Sanz Date: Mon, 8 Jan 2024 11:17:18 +0100 Subject: [PATCH 4/6] Added Action for composer with token to avoid errors when running tests This is not relates to this issue but required because tests won't pass without this. --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d10b686..c89ff0f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,9 +9,16 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout repository uses: actions/checkout@v2 + - name: Add composer + uses: php-actions/composer@v6 + env: + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.PAT }}"} }' + + - name: Add HTTP basic auth credentials run: | echo "auth.json path: $GITHUB_WORKSPACE/auth.json" From 4f5156c750f9de0cf1e2cfeca24bc48dcbc5282c Mon Sep 17 00:00:00 2001 From: Ricardo Sanz Date: Mon, 8 Jan 2024 13:27:33 +0100 Subject: [PATCH 5/6] Use another secret (previous one seems to be expired) --- .github/workflows/tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c89ff0f..67bbdba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,16 +13,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Add composer - uses: php-actions/composer@v6 - env: - COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.PAT }}"} }' - - - name: Add HTTP basic auth credentials run: | echo "auth.json path: $GITHUB_WORKSPACE/auth.json" - echo '${{ secrets.auth_json_for_boierpalte_github_ci }}' > $GITHUB_WORKSPACE/auth.json + echo '${{ secrets.PAT }}' > $GITHUB_WORKSPACE/auth.json pwd - name: Prepare container for testing From faba94341c7b36ae638af887817f0511d52821e3 Mon Sep 17 00:00:00 2001 From: Ricardo Sanz Date: Mon, 8 Jan 2024 13:38:53 +0100 Subject: [PATCH 6/6] Previoue token dind't work, let's try to regenerate the previous one --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 67bbdba..5c681aa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: - name: Add HTTP basic auth credentials run: | echo "auth.json path: $GITHUB_WORKSPACE/auth.json" - echo '${{ secrets.PAT }}' > $GITHUB_WORKSPACE/auth.json + echo '${{ secrets.auth_json_for_boierpalte_github_ci }}' > $GITHUB_WORKSPACE/auth.json pwd - name: Prepare container for testing