From 6c8e6196043b5b6053ac4f60afd14afa5896ac26 Mon Sep 17 00:00:00 2001 From: Steven Dubois Date: Wed, 3 Nov 2021 12:00:00 +0100 Subject: [PATCH] Switch to docker compose v2 --- Makefile | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 2094638..ab45a9f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # ==> https://github.com/EmakinaFR/docker-magento2/wiki/Makefile SHELL := /bin/bash -PHP_SERVICE := docker-compose exec -u www-data:www-data php sh -c +PHP_SERVICE := docker compose exec -u www-data:www-data php sh -c # Define a dynamic project name that will be prepended to each service name export COMPOSE_PROJECT_NAME := magento2_$(shell echo $${PWD\#\#*/} | tr '[:upper:]' '[:lower:]') @@ -22,50 +22,50 @@ export DOCKER_REDIS_IMAGE := $(shell grep DOCKER_REDIS_IMAGE ${MAKEFILE_DIRECTOR backup: ## Backup the "mysql" volume docker run --rm \ - --volumes-from $$(docker-compose ps -q mysql) \ + --volumes-from $$(docker compose ps -q mysql) \ --volume $$(pwd):/backup \ busybox sh -c "tar cvf /backup/backup.tar /var/lib/mysql" build: ## Build the environment - docker-compose build --pull + docker compose build --pull cache: ## Flush cache stored in Redis - docker-compose exec redis sh -c "redis-cli -n 1 FLUSHDB" - docker-compose exec redis sh -c "redis-cli -n 2 FLUSHDB" + docker compose exec redis sh -c "redis-cli -n 1 FLUSHDB" + docker compose exec redis sh -c "redis-cli -n 2 FLUSHDB" composer: ## Install Composer dependencies from the "php" container $(PHP_SERVICE) "composer install --optimize-autoloader --prefer-dist --working-dir=/var/www/html" logs: ## Follow logs generated by all containers - docker-compose logs -f --tail=0 + docker compose logs -f --tail=0 logs-full: ## Follow logs generated by all containers from the containers creation - docker-compose logs -f + docker compose logs -f mysql: ## Open a terminal in the "mysql" container - docker-compose exec mysql sh + docker compose exec mysql sh nginx: ## Open a terminal in the "nginx" container - docker-compose exec -u nginx:nginx nginx sh -l + docker compose exec -u nginx:nginx nginx sh -l php: ## Open a terminal in the "php" container - docker-compose exec -u www-data:www-data php sh -l + docker compose exec -u www-data:www-data php sh -l ps: ## List all containers managed by the environment - docker-compose ps + docker compose ps purge: ## Purge all services, associated volumes and the Mutagen session - docker-compose down --volumes + docker compose down --volumes mutagen sync terminate --label-selector='name==${COMPOSE_PROJECT_NAME}' restart: stop start ## Restart the environment restore: ## Restore the "mysql" volume docker run --rm \ - --volumes-from $$(docker-compose ps -q mysql) \ + --volumes-from $$(docker compose ps -q mysql) \ --volume $$(pwd):/backup \ busybox sh -c "tar xvf /backup/backup.tar var/lib/mysql/" - docker-compose restart mysql + docker compose restart mysql root: ## Display the commands to set up the environment for an advanced usage @echo "export COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}" @@ -80,7 +80,7 @@ root: ## Display the commands to set up the environment for an advanced usage @echo "# eval \$$(make root)" start: ## Start the environment - @docker-compose up --detach --remove-orphans + @docker compose up --detach --remove-orphans @if [[ ! "$$(mutagen sync list --label-selector='name==${COMPOSE_PROJECT_NAME}')" =~ "${COMPOSE_PROJECT_NAME}" ]]; then \ mutagen sync create \ @@ -98,7 +98,7 @@ start: ## Start the environment fi @echo "Fixing permissions on the shared SSH agent..." - @docker-compose exec -T php bash -c "chown www-data:www-data /run/host-services/ssh-auth.sock" + @docker compose exec -T php bash -c "chown www-data:www-data /run/host-services/ssh-auth.sock" @while [[ ! "$$(mutagen sync list --label-selector='name==${COMPOSE_PROJECT_NAME}')" =~ "Status: Watching for changes" ]]; do \ echo "Waiting for synchronization to complete..."; \ @@ -109,7 +109,7 @@ stats: ## Print real-time statistics about containers ressources usage docker stats $(docker ps --format={{.Names}}) stop: ## Stop the environment - @docker-compose stop + @docker compose stop @mutagen sync pause --label-selector='name==${COMPOSE_PROJECT_NAME}' yarn: ## Install Composer dependencies from the "php" container