Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@andypost
Last active December 17, 2023 18:43
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save andypost/f8e359f2e80cb7d4737350189f009646 to your computer and use it in GitHub Desktop.
Save andypost/f8e359f2e80cb7d4737350189f009646 to your computer and use it in GitHub Desktop.
drupal 10 core contributor docker kickstarter
version: "2.1"
services:
php:
image: skilldlabs/php:82-fpm
container_name: core9
restart: always
working_dir: /var/www/html/web
volumes:
- .:/var/www/html/web
- ./.cache/composer:/home/www-data/.composer/cache
command: php-fpm82 -F -dzend.assertions=1 -d assert.exception=1
# command: php-fpm82 -F -dzend.assertions=1 -dopcache.jit_buffer_size=20M
# Uncomment next line if you need PHP Xdebug.
# command: php-fpm82 -F -d display_errors=0 -dzend_extension=xdebug -dxdebug.mode=debug
environment:
PHP_IDE_CONFIG: serverName=server_name
COMPOSER_CACHE_DIR: /home/www-data/.composer/cache
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://chrome:4444"]'
SIMPLETEST_BASE_URL: http://nginx
SIMPLETEST_DB: sqlite://./db/tests.db
# BROWSERTEST_OUTPUT_DIRECTORY: sites/simpletest
networks:
- front
nginx:
image: skilldlabs/nginx:1.22
container_name: "core9_nginx"
restart: always
depends_on:
- php
volumes:
- ./:/var/www/html/web
networks:
- front
# logging:
# driver: "journald"
# options:
# tag: "{{.Name}}"
chrome:
image: drupalci/webdriver-chromedriver:production
ulimits:
core:
soft: -1
hard: -1
cap_add:
- SYS_ADMIN
volumes:
- /dev/shm:/dev/shm
ports:
- "4444:4444"
entrypoint:
- chromedriver
- "--port=4444"
- "--no-sandbox"
- "--whitelisted-ips="
# - "--log-path=/tmp/chromedriver.log"
- "--log-level=INFO"
# - "--verbose"
networks:
- front
networks:
front:
driver: bridge
.PHONY: up upx log down exec exec0 h t
CUID := $(shell id -u)
CGID := $(shell id -g)
IMAGEPHP := skilldlabs/php:8
all: | exec
up:
docker run --rm --name core9 \
-u $(CUID):$(CGID) \
-v $(shell pwd):/srv \
-p 8080:8080 -d \
$(IMAGEPHP) php -S 0.0.0.0:8080 \
.ht.router.php
docker exec -u 0:0 core9 adduser -D www
h:
docker exec -u $(CUID):$(CGID) core9 composer global require -o --update-no-dev --no-suggest "hirak/prestissimo:^0.3"
upx:
docker run --rm --name core9 \
-u $(CUID):$(CGID) \
-v $(shell pwd):/srv \
-p 8080:8080 \
$(IMAGEPHP) php -d zend_extension=xdebug.so -S 0.0.0.0:8080 \
.ht.router.php
docker exec core9 adduser -D www
log:
docker logs -f --tail=10 core9
down:
docker stop core9
exec:
docker exec -it -u $(CUID):$(CGID) core9 ash
exec0:
docker exec -it -u 0:0 core9 ash
t:
docker exec \
-e SIMPLETEST_BASE_URL=http://localhost:8080 \
-e SIMPLETEST_DB=sqlite://./db/d8.db \
core9 vendor/bin/phpunit -c core/phpunit.xml.dist --debug ${t}
# Docker compose related goals
# -e SIMPLETEST_BASE_URL=http://nginx \
# -e SIMPLETEST_DB=sqlite://./db/tests.db \
# -e BROWSERTEST_OUTPUT_DIRECTORY=db \
t:
docker exec \
-u $(CUID):$(CGID) \
-e BROWSERTEST_OUTPUT_DIRECTORY='db' \
$(COMPOSE_PROJECT_NAME) \
vendor/bin/phpunit -c core/phpunit.xml.dist --colors=always \
${t}
info:
$(info Containers for "$(COMPOSE_PROJECT_NAME)" info:)
$(eval CONTAINERS = $(shell docker ps -f name=$(COMPOSE_PROJECT_NAME) --format "{{ .ID }}"))
@echo 'Containers list' $(CONTAINERS)
$(foreach CONTAINER, $(CONTAINERS),$(info http://$(shell printf '%-19s \n' $(shell docker inspect --format='{{(index .NetworkSettings.Networks "$(COMPOSE_PROJECT_NAME)_front").IPAddress}}:{{index .Config.Labels "traefik.port"}} {{range $$p, $$conf := .NetworkSettings.Ports}}{{$$p}}{{end}} {{.Name}}' $(CONTAINER) | rev | sed "s/pct\//,pct:/g" | sed "s/,//" | rev | awk '{ print $0}')) ))
@echo "$(RESULT)"
start:
docker-compose up -d php nginx
stop:
docker-compose down -v --remove-orphans
@andypost
Copy link
Author

For MacOS it needs to add :cached to -v mounts https://docker4drupal.readthedocs.io/en/latest/macos/

@andypost
Copy link
Author

Code sniffers

alias pcbf='docker run --rm -v $(pwd):/work skilldlabs/docker-phpcs-drupal phpcbf --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info .'
alias pcs='docker run --rm -v $(pwd):/work skilldlabs/docker-phpcs-drupal phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info .'

@andypost
Copy link
Author

andypost commented Nov 7, 2017

Running tests

core8$ make t t=core/modules/taxonomy/tests/src/Unit/Menu/TaxonomyLocalTasksTest.php

@AnnMatrosova
Copy link

AnnMatrosova commented Oct 10, 2018

To run Functional javascript tests follow next steps:

  1. make steps from core/tests/README.md (Functional javascript tests part): install selenium-server-standalone, chromedriver. Then run selenium server
  2. export MINK_DRIVER_ARGS_WEBDRIVER='["chrome", null, "http://localhost:4444/wd/hub"]'
  3. export SIMPLETEST_BASE_URL='http://localhost:8080'
    To run test (example):
    vendor/bin/phpunit -c core core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php --testsuite functional-javascript

@andypost
Copy link
Author

@andypost
Copy link
Author

Did update to use docker-compose to run chromium from drupal.org CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment