diff --git a/.env.example b/.env.example index 594f637..ac750bf 100644 --- a/.env.example +++ b/.env.example @@ -20,14 +20,6 @@ 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.11-3.28.0 diff --git a/.github/shellspec/shellspec_spec/backstopjs___spec.sh b/.github/shellspec/shellspec_spec/backstopjs___spec.sh index 7f2a3b9..39d08c4 100644 --- a/.github/shellspec/shellspec_spec/backstopjs___spec.sh +++ b/.github/shellspec/shellspec_spec/backstopjs___spec.sh @@ -1,7 +1,7 @@ Describe 'BackstopJS' backstopjs It 'is installed and can be run' - When run command docker-compose exec -T backstopjs backstop + When run command docker compose exec -T backstopjs backstop The status should be success The output should include "Welcome to BackstopJS" End diff --git a/.github/shellspec/shellspec_spec/folders___spec.sh b/.github/shellspec/shellspec_spec/folders___spec.sh index e1ecae4..42da65d 100644 --- a/.github/shellspec/shellspec_spec/folders___spec.sh +++ b/.github/shellspec/shellspec_spec/folders___spec.sh @@ -22,8 +22,8 @@ Describe 'Boilerplate folder structure' folders It 'has main boilerplate files' The path 'composer.json' should be file The path 'behat.yml' should be file - The path 'docker-compose.yml' should be file - The path "docker-compose.override.yml" should be file + The path 'compose.yml' should be file + The path "compose.override.yml" should be file The path "web/sites/default/settings.local.php" should be file End diff --git a/.github/shellspec/shellspec_spec/phpqa___spec.sh b/.github/shellspec/shellspec_spec/phpqa___spec.sh index ec594ba..7d3a64e 100644 --- a/.github/shellspec/shellspec_spec/phpqa___spec.sh +++ b/.github/shellspec/shellspec_spec/phpqa___spec.sh @@ -7,7 +7,7 @@ Describe 'Phpqa' phpqa static-code-analisys # Test disabled because Radix includes a file with a phpqa error in the file # src/kits/radix_starterkit/includes/theme.inc # It 'should detect no errors' -# When run command docker-compose exec php phpqa +# When run command docker compose exec php phpqa # The status should be success # The output should include 'No failed tools' # The error should not include 'This is a dummy text to discard standard error output' diff --git a/.github/shellspec/shellspec_spec/spec_helper.sh b/.github/shellspec/shellspec_spec/spec_helper.sh index 4ec336f..8ca6590 100644 --- a/.github/shellspec/shellspec_spec/spec_helper.sh +++ b/.github/shellspec/shellspec_spec/spec_helper.sh @@ -30,7 +30,7 @@ spec_helper_configure() { # Checks if a given container is running. # $1: name of the container. container_is_alive() { - count=$(docker-compose ps --services --filter "status=running" | grep $1| wc -l) + count=$(docker compose ps --services --filter "status=running" | grep $1| wc -l) if [ $count -eq "1" ] then return 0 @@ -40,6 +40,6 @@ container_is_alive() { } container_count() { - docker-compose ps --services --filter "status=running" | wc -l + docker compose ps --services --filter "status=running" | wc -l } diff --git a/Makefile b/Makefile index afc79f9..c066b5d 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_CMD) exec php phpunit $(filter-out $@,$(MAKECMDGOALS)) + docker compose exec php phpunit $(filter-out $@,$(MAKECMDGOALS)) ## behat : Run project Behat tests .PHONY: behat behat: - $(DOCKER_COMPOSE_CMD) exec php ${BEHAT} --colors + docker compose exec php ${BEHAT} --colors ## ngrok : Setup a ngrok tunnel to make the site available .PHONY: ngrok ngrok: - $(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"://[^\"]+ + docker compose -f compose.yml -f compose.override.yml -f compose.ngrok.yml up -d && docker compose 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_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 + docker compose -f compose.yml -f compose.override.yml -f compose.ngrok.yml stop ngrok && docker compose -f compose.yml -f compose.override.yml -f compose.ngrok.yml rm -fsv ngrok ## frontend : Generate frontend assets like compiling scss .PHONY: frontend frontend: - $(DOCKER_COMPOSE_CMD) exec -w ${FRONTEND_BASE_PATH}/$(frontend_target) node sh ${DOCKER_PROJECT_ROOT}/scripts/frontend-build.sh $(filter-out $@,$(MAKECMDGOALS)) + docker compose 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_CMD) exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop reference --filter='$(filter-out $@,$(MAKECMDGOALS))'" + docker compose 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,28 +59,28 @@ backstopjs-reference: ## Example: make backstopjs_type=environment/pro backstopjs-test .PHONY: backstopjs-test backstopjs-test: - $(DOCKER_COMPOSE_CMD) exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop test --filter='$(filter-out $@,$(MAKECMDGOALS))'" + docker compose exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop test --filter='$(filter-out $@,$(MAKECMDGOALS))'" ## setup-init : Prepares the site .PHONY: setup-init setup-init: mkdir -p web/sites/default/files/behat/errors chmod u+w web/sites/${SITE} -R - cp docker-compose.override.yml.dist docker-compose.override.yml + cp compose.override.yml.dist 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_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' + 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' ## setup : Prepares the site and installs it using the Drupal configuration files .PHONY: setup setup: make setup-init - $(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 + 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 ## setup-from-environment : Prepares the site and loads it with data from the reference site .PHONY: setup-from-environment @@ -96,16 +96,16 @@ solr-sync: ## solr-rebuild : Re-creates the Solr core .PHONY: solr-rebuild solr-rebuild: - $(DOCKER_COMPOSE_CMD) stop solr && $(DOCKER_COMPOSE_CMD) rm -f solr && $(DOCKER_COMPOSE_CMD) up -d solr && make solr-sync + docker compose stop solr && docker compose rm -f solr && docker compose up -d solr && make solr-sync ## pa11y: Run pa11y tests .PHONY: pa11y pa11y: - $(DOCKER_COMPOSE_CMD) run --rm -T pa11y $(filter-out $@,$(MAKECMDGOALS)) + docker compose run --rm -T pa11y $(filter-out $@,$(MAKECMDGOALS)) ## lighthouse: Run lighthouse tests .PHONY: lighthouse lighthouse: - $(DOCKER_COMPOSE_CMD) exec -T lighthouse lhci autorun || true - $(DOCKER_COMPOSE_CMD) exec -T lighthouse sh -c 'tar -cf - *.json *.html' | tar -xvf - -C reports/lighthouse/ + docker compose exec -T lighthouse lhci autorun || true + docker compose exec -T lighthouse sh -c 'tar -cf - *.json *.html' | tar -xvf - -C reports/lighthouse/ ls -l reports/lighthouse/ diff --git a/docker-compose.ngrok.yml b/compose.ngrok.yml similarity index 100% rename from docker-compose.ngrok.yml rename to compose.ngrok.yml diff --git a/docker-compose.override.yml.dist b/compose.override.yml.dist similarity index 100% rename from docker-compose.override.yml.dist rename to compose.override.yml.dist diff --git a/docker-compose.xdebug.override.yml.dist b/compose.xdebug.override.yml.dist similarity index 100% rename from docker-compose.xdebug.override.yml.dist rename to compose.xdebug.override.yml.dist diff --git a/docker-compose.yml b/compose.yml similarity index 100% rename from docker-compose.yml rename to compose.yml diff --git a/composer.json b/composer.json index fc2865d..fbacb57 100644 --- a/composer.json +++ b/composer.json @@ -41,8 +41,8 @@ "metadrop/drupal-artifact-builder": "^1.4" }, "require-dev": { - "metadrop/drupal-dev": "^1.1.0", - "metadrop/drupal-boilerplate-assistant": "^2.0@beta" + "metadrop/drupal-dev": "^2.0", + "metadrop/drupal-boilerplate-assistant": "^3.0@beta" }, "conflict": { "drupal/drupal": "*" diff --git a/docker.mk b/docker.mk index ffce7cb..d21b4db 100644 --- a/docker.mk +++ b/docker.mk @@ -16,12 +16,12 @@ help : .PHONY: up up: @echo "Starting up containers for $(PROJECT_NAME)..." - $(DOCKER_COMPOSE_CMD) pull - $(DOCKER_COMPOSE_CMD) up -d --remove-orphans + docker compose pull + docker compose up -d --remove-orphans .PHONY: mutagen mutagen: - $(DOCKER_COMPOSE_CMD) up -d mutagen + docker compose 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_CMD) start + @docker compose start ## stop : Stop containers. .PHONY: stop stop: @echo "Stopping containers for $(PROJECT_NAME)..." - @$(DOCKER_COMPOSE_CMD) stop + @docker compose 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_CMD) down -v $(filter-out $@,$(MAKECMDGOALS)) + @docker compose 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_CMD) logs -f $(filter-out $@,$(MAKECMDGOALS)) + @docker compose 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_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 + @echo "¡¡CAUTION!! X-debug will only work if you have correctly configured compose.xdebug.override.yml file." + docker compose stop php + docker compose pull php + docker compose -f compose.yml -f compose.override.yml -f compose.xdebug.override.yml up -d php ## xdebug-disable : Disable xdebug. .PHONY: xdebug-stop xdebug-stop: @echo "Disabling xdebug in $(PROJECT_NAME)." - $(DOCKER_COMPOSE_CMD) stop php - $(DOCKER_COMPOSE_CMD) -f docker-compose.yml -f docker-compose.override.yml up -d php + docker compose stop php + docker compose -f compose.yml -f compose.override.yml up -d php # https://stackoverflow.com/a/6273809/1826109 %: diff --git a/readme.md b/readme.md index 57317c2..d92c20a 100644 --- a/readme.md +++ b/readme.md @@ -32,7 +32,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/) 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. + - [Docker Compose](https://docs.docker.com/compose/install/), version [V2](https://www.docker.com/blog/announcing-compose-v2-general-availability/). **Optionally** diff --git a/scripts/parse_yml.py b/scripts/parse_yml.py index f07c388..7215f46 100755 --- a/scripts/parse_yml.py +++ b/scripts/parse_yml.py @@ -15,7 +15,7 @@ class Informer(object): def __init__(self): - source_file = "docker-compose.override.yml" + source_file = "compose.override.yml" self.parse_env() self.parse_docker_info() @@ -36,7 +36,7 @@ def get_env_value(self, key): def parse_docker_info(self): - docker_info_stream = subprocess.check_output(['docker-compose', 'config']) + docker_info_stream = subprocess.check_output(['docker', 'compose', 'config']) # print(docker_info_stream ) self.info = yaml.safe_load(docker_info_stream)