Skip to content

Commit 368cb10

Browse files
authored
Merge pull request #130 from Metadrop/feature/docker-compose-plugin-v2
Feature/docker compose plugin v2
2 parents ba5685f + faba943 commit 368cb10

File tree

5 files changed

+41
-32
lines changed

5 files changed

+41
-32
lines changed

.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ DB_HOST=mariadb
1818
DB_PORT=3306
1919
DB_DRIVER=mysql
2020

21+
22+
### --- Docker Compose ---
23+
# V1
24+
# DOCKER_COMPOSE_CMD=docker-compose
25+
# V2
26+
DOCKER_COMPOSE_CMD=docker compose
27+
28+
2129
### --- MARIADB ----
2230

2331
MARIADB_TAG=10.5-3.10.0

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12+
1213
- name: Checkout repository
1314
uses: actions/checkout@v2
1415

Makefile

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ info:
1717
## 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
1818
.PHONY: test
1919
test:
20-
docker-compose exec php phpunit $(filter-out $@,$(MAKECMDGOALS))
20+
$(DOCKER_COMPOSE_CMD) exec php phpunit $(filter-out $@,$(MAKECMDGOALS))
2121

2222
## behat : Run project Behat tests
2323
.PHONY: behat
2424
behat:
25-
docker-compose exec php ${BEHAT} --colors
25+
$(DOCKER_COMPOSE_CMD) exec php ${BEHAT} --colors
2626

2727
## ngrok : Setup a ngrok tunnel to make the site available
2828
.PHONY: ngrok
2929
ngrok:
30-
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"://[^\"]+
30+
$(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"://[^\"]+
3131

3232
## ngrok-stop : Stop the created ngrok tunnel
3333
.PHONY: ngrok-stop
3434
ngrok-stop:
35-
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
35+
$(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
3636

3737
## frontend : Generate frontend assets like compiling scss
3838
.PHONY: frontend
3939
frontend:
40-
docker-compose exec -w ${FRONTEND_BASE_PATH}/$(frontend_target) node sh ${DOCKER_PROJECT_ROOT}/scripts/frontend-build.sh $(filter-out $@,$(MAKECMDGOALS))
40+
$(DOCKER_COMPOSE_CMD) exec -w ${FRONTEND_BASE_PATH}/$(frontend_target) node sh ${DOCKER_PROJECT_ROOT}/scripts/frontend-build.sh $(filter-out $@,$(MAKECMDGOALS))
4141

4242
## backstopjs-reference : Generate BackstopJS reference files
4343
## An optional parameter is available to generate only scenarios matching it.
@@ -48,7 +48,7 @@ frontend:
4848
## Example: make backstopjs_type=environment/pro backstopjs-test
4949
.PHONY: backstopjs-reference
5050
backstopjs-reference:
51-
docker-compose exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop reference --filter='$(filter-out $@,$(MAKECMDGOALS))'"
51+
$(DOCKER_COMPOSE_CMD) exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop reference --filter='$(filter-out $@,$(MAKECMDGOALS))'"
5252

5353
## backstopjs-test : Run BackstopJS tests
5454
## An optional parameter is available to generate only scenarios matching it.
@@ -59,7 +59,7 @@ backstopjs-reference:
5959
## Example: make backstopjs_type=environment/pro backstopjs-test
6060
.PHONY: backstopjs-test
6161
backstopjs-test:
62-
docker-compose exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop test --filter='$(filter-out $@,$(MAKECMDGOALS))'"
62+
$(DOCKER_COMPOSE_CMD) exec -T backstopjs sh -c "cd tests/${backstopjs_type}/backstopjs && backstop test --filter='$(filter-out $@,$(MAKECMDGOALS))'"
6363

6464
## setup-init : Prepares the site
6565
.PHONY: setup-init
@@ -69,18 +69,18 @@ setup-init:
6969
cp docker-compose.override.yml.dist docker-compose.override.yml
7070
cp web/sites/${SITE}/example.settings.local.php web/sites/${SITE}/settings.local.php
7171
cp web/sites/${SITE}/example.local.drush.yml web/sites/${SITE}/local.drush.yml
72-
docker-compose up -d
73-
docker-compose exec -T php composer install
74-
docker-compose run -e'PHP_ERROR_REPORTING=E_ALL & ~E_DEPRECATED' --rm -T php 'vendor/bin/grumphp' 'git:init'
72+
$(DOCKER_COMPOSE_CMD) up -d
73+
$(DOCKER_COMPOSE_CMD) exec -T php composer install
74+
$(DOCKER_COMPOSE_CMD) run -e'PHP_ERROR_REPORTING=E_ALL & ~E_DEPRECATED' --rm -T php 'vendor/bin/grumphp' 'git:init'
7575

7676
## setup : Prepares the site and installs it using the Drupal configuration files
7777
.PHONY: setup
7878
setup:
7979
make setup-init
80-
docker-compose exec -T php drush @${SITE}.local si ${PROFILE} --existing-config --sites-subdir=${SITE} -y
81-
docker-compose exec -T php drush @${SITE}.local cim -y
82-
docker-compose exec -T php drush @${SITE}.local cr
83-
docker-compose exec -T php drush @${SITE}.local uli
80+
$(DOCKER_COMPOSE_CMD) exec -T php drush @${SITE}.local si ${PROFILE} --existing-config --sites-subdir=${SITE} -y
81+
$(DOCKER_COMPOSE_CMD) exec -T php drush @${SITE}.local cim -y
82+
$(DOCKER_COMPOSE_CMD) exec -T php drush @${SITE}.local cr
83+
$(DOCKER_COMPOSE_CMD) exec -T php drush @${SITE}.local uli
8484

8585
## setup-from-environment : Prepares the site and loads it with data from the reference site
8686
.PHONY: setup-from-environment
@@ -96,4 +96,4 @@ solr-sync:
9696
## solr-rebuild : Re-creates the Solr core
9797
.PHONY: solr-rebuild
9898
solr-rebuild:
99-
docker-compose stop solr && docker-compose rm -f solr && docker-compose up -d solr && make solr-sync
99+
$(DOCKER_COMPOSE_CMD) stop solr && $(DOCKER_COMPOSE_CMD) rm -f solr && $(DOCKER_COMPOSE_CMD) up -d solr && make solr-sync

docker.mk

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ help :
1616
.PHONY: up
1717
up:
1818
@echo "Starting up containers for $(PROJECT_NAME)..."
19-
docker-compose pull
20-
docker-compose up -d --remove-orphans
19+
$(DOCKER_COMPOSE_CMD) pull
20+
$(DOCKER_COMPOSE_CMD) up -d --remove-orphans
2121

2222
.PHONY: mutagen
2323
mutagen:
24-
docker-compose up -d mutagen
24+
$(DOCKER_COMPOSE_CMD) up -d mutagen
2525
mutagen project start -f mutagen/config.yml
2626

2727
## down : Stop containers.
@@ -32,13 +32,13 @@ down: stop
3232
.PHONY: start
3333
start:
3434
@echo "Starting containers for $(PROJECT_NAME) from where you left off..."
35-
@docker-compose start
35+
@$(DOCKER_COMPOSE_CMD) start
3636

3737
## stop : Stop containers.
3838
.PHONY: stop
3939
stop:
4040
@echo "Stopping containers for $(PROJECT_NAME)..."
41-
@docker-compose stop
41+
@$(DOCKER_COMPOSE_CMD) stop
4242

4343
## prune : Remove containers and their volumes.
4444
## You can optionally pass an argument with the service name to prune single container
@@ -47,7 +47,7 @@ stop:
4747
.PHONY: prune
4848
prune:
4949
@echo "Removing containers for $(PROJECT_NAME)..."
50-
@docker-compose down -v $(filter-out $@,$(MAKECMDGOALS))
50+
@$(DOCKER_COMPOSE_CMD) down -v $(filter-out $@,$(MAKECMDGOALS))
5151

5252
## ps : List running containers.
5353
.PHONY: ps
@@ -80,23 +80,23 @@ drush:
8080
## logs nginx php : View `nginx` and `php` containers logs.
8181
.PHONY: logs
8282
logs:
83-
@docker-compose logs -f $(filter-out $@,$(MAKECMDGOALS))
83+
@$(DOCKER_COMPOSE_CMD) logs -f $(filter-out $@,$(MAKECMDGOALS))
8484

8585
## xdebug : Enable xdebug.
8686
.PHONY: xdebug
8787
xdebug:
8888
@echo "Enabling xdebug in $(PROJECT_NAME)."
8989
@echo "¡¡CAUTION!! X-debug will only work if you have correctly configured docker-compose.xdebug.override.yml file."
90-
docker-compose stop php
91-
docker-compose pull php
92-
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.xdebug.override.yml up -d php
90+
$(DOCKER_COMPOSE_CMD) stop php
91+
$(DOCKER_COMPOSE_CMD) pull php
92+
$(DOCKER_COMPOSE_CMD) -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.xdebug.override.yml up -d php
9393

9494
## xdebug-disable : Disable xdebug.
9595
.PHONY: xdebug-stop
9696
xdebug-stop:
9797
@echo "Disabling xdebug in $(PROJECT_NAME)."
98-
docker-compose stop php
99-
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d php
98+
$(DOCKER_COMPOSE_CMD) stop php
99+
$(DOCKER_COMPOSE_CMD) -f docker-compose.yml -f docker-compose.override.yml up -d php
100100

101101
# https://stackoverflow.com/a/6273809/1826109
102102
%:

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Tools included out-of-the-box:
2121

2222
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).
2323

24-
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.
24+
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.
2525

2626
## Quickview
2727

@@ -30,11 +30,11 @@ https://github.com/Metadrop/drupal-boilerplate/assets/776453/2b3d53c6-e2bf-4c48-
3030
## Requisites
3131

3232
- [Docker](https://docs.docker.com/get-docker/)
33-
- [Docker Compose](https://docs.docker.com/compose/install/)
33+
- [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.
3434

3535
**Optionally**
3636

37-
- Pyhton 3 with PyYAML installed for the `make info` command
37+
- Python 3 with PyYAML installed for the `make info` command
3838

3939
## Usage
4040

@@ -50,11 +50,11 @@ Depending in the Drupal release you want you should use a different branch.
5050

5151
| Drupal release | Boilerplate branch | Example command |
5252
|--- |--- |--- |
53-
| 10.x | 3.x branch | composer create-project --ignore-platform-reqs metadrop/drupal-boilerplate my-project |
53+
| 10.x | 3.x branch | composer create-project --ignore-platform-reqs metadrop/drupal-boilerplate my-project |
5454
| 9.x | 2.x branch | composer create-project --ignore-platform-reqs metadrop/drupal-boilerplate:^2 my-project |
5555

5656

57-
NOTE: 2.x branch is minimally maintained because Drupal9 support ends Nomvember, 2023.
57+
NOTE: 2.x branch is minimally maintained because Drupal9 support ends November, 2023.
5858

5959

6060
Because this boilerplate uses drupal/core-recommended under the hood you will get an updated release of the chosen core.

0 commit comments

Comments
 (0)