version: '3'
services:
web:
image: fpfis/httpd-php-dev:8.1
working_dir: /var/www/html
ports:
- 8080:8080
volumes:
- .:/var/www/html # Non Mac users.
# Forward local SSH agent.
# This allows Composer to access private repositories, such as the EWCMS profile.
# - $SSH_AUTH_SOCK:/ssh-auth.sock
# - nfsmount:/var/www/html # Mac Users with the nfsmount volume.
environment:
# SSH_AUTH_SOCK: "/ssh-auth.sock"
# No need to expose the credentials inside the container!
DRUPAL_BASE_URL: "https://8cbb708b4e084576a2070609ce1b15c6.vfs.cloud9.eu-west-1.amazonaws.com/web"
DRUSH_OPTIONS_URI: "https://8cbb708b4e084576a2070609ce1b15c6.vfs.cloud9.eu-west-1.amazonaws.com/web"
# ASDA CREDENTIALS
# ASDA_USER:
# ASDA_PASSWORD:
# EWCMS
#
# EWCMS_PROJECT_ID:
# e.g. TOOLKIT_PROJECT_ID: comm-ewcms-agriculture
TOOLKIT_PROJECT_ID: comm-ewcms-your-project
# By leaving these variables empty Docker Compose will set them to their host values.
# XDEBUG CONFIGURATION
XDEBUG_CONFIG: "remote_enable=1 remote_host=10.254.254.254 remote_port=9000 idekey=PHPSTORM remote_autostart=1"
PHP_IDE_CONFIG: "serverName=Docker"
# For Xdebug setup, run this command in the terminal:
# For Mac users: sudo ifconfig en0 alias 10.254.254.254 255.255.255.0
# For Linux users: sudo ip addr add 10.254.254.254/32 dev lo label lo:1
DRUPAL_FLUSH_CREDS: "flush:test"
DRUPAL_SITE_NAME: "ewcms"
DRUPAL_ENVIRONMENT: "local"
DRUPAL_VARNISH_HOSTS: "varnish"
DRUPAL_VARNISH_GROUP: "ewcms"
SEARCH_API_SERVER_SS_SOLR_HOST: "solr"
SEARCH_API_SERVER_SS_SOLR_PATH: /
SEARCH_API_SERVER_SS_SOLR_CORE: "comm-ewcms-local"
SEARCH_API_SERVER_SS_SOLR_PORT: 8983
DRUPAL_MEMCACHE_HOSTS: "memcached:11211"
# Check if this file exists in the document root
env_file:
- .env
mysql:
image: percona/percona-server:5.7
command: --innodb-log-file-size=1G --max_allowed_packet=1G --innodb-buffer-pool-size=512M --wait_timeout=3000 --net_write_timeout=3000 --log_error_verbosity=3
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# ports:
# - 3306:3306
# Database persitence. Check the volume below the doc
volumes:
- mysql-data:/var/lib/mysql
varnish:
image: registry.fpfis.eu/fpfis/varnish/docker:65-dev
ports:
- 80:80
environment:
- VARNISH_DEVOPS_EXTERNAL_IPS=172.0.0.0/8
- VARNISH_DOMAINS_PATH=/web
sparql:
image: openeuropa/triple-store-dev
environment:
- SPARQL_UPDATE=true
- DBA_PASSWORD=dba
ports:
- "8890:8890"
# docker run --rm -p 4444:4444 -p 5900:5900 --network="host" selenium/standalone-chrome-debug:latest
# Newer version of this image might run into this issue:
# @link https://github.com/elgalu/docker-selenium/issues/20
selenium:
image: selenium/standalone-chrome-debug:3
expose:
- '4444'
environment:
- DISPLAY=:99
- SE_OPTS=-debug
- SCREEN_WIDTH=1280
- SCREEN_HEIGHT=800
- VNC_NO_PASSWORD=1
ports:
- '4444:4444'
- "5900:5900"
volumes:
- /dev/shm:/dev/shm
shm_size: 2g
memcached:
image: memcached:latest
command: ["-m", "256m", "-c" , "4096"]
solr:
image: registry.fpfis.eu/fpfis/solr:8-ci
volumes:
- ./config/solr/conf:/cores/conf
environment:
SOLR_CORE_TYPE: custom
SOLR_CORE_NAME: comm-ewcms-local
SOLR_IMPORT_DUMP: 0
SOLR_SITE_CORE_PATH: "/cores/conf"
ports:
- 8983:8983
phpmyadmin:
image: phpmyadmin/phpmyadmin
environment:
PMA_HOST: mysql
PMA_USER: ${MYSQL_USER:-root}
PHP_UPLOAD_MAX_FILESIZE: 1G
PHP_MAX_INPUT_VARS: 1G
ports:
- 8082:80
redis:
image: redis
ports:
- 6379:6379
# Database persitence. Enable the volumes on mysql service
volumes:
mysql-data:
For cloning ASDA you need to add nextcloud_admin: true
after asda_type in runner.dist.yml
/L129
toolkit:
project_id: ${env.TOOLKIT_PROJECT_ID}
clone:
asda_type: 'nextcloud'
nextcloud_admin: true
Start up the containers
docker-compose up -d
Run the package manager
docker-compose exec web composer install
Do you want to store credentials for git.fpfis.tech.ec.europa.eu in /root/.config/composer/auth.json ? [Yn] Y
When using Solr of local stored service/software you need to connect to the local registry
docker login registry.fpfis.eu
Proceed to build stage, then clone
docker compose exec web vendor/bin/run toolkit:build-dev
docker compose exec web vendor/bin/run toolkit:download-dump --is-admin
docker compose exec web vendor/bin/run toolkit:install-clone
Post install configuration.
Setting correct ownership and permissions
cd comm-ewcms-agriculture
sudo chown -R ubuntu:ubuntu web/
docker compose exec web sudo chmod -R 777 /var/log/drupal
docker compose exec web chmod -R 777 web/sites/default/files
It happens when you can restore the database dump, but the new site is just a mess, no styling at all.
Untie the js/css aggregation.
docker compose exec web drush config-set system.performance css.preprocess 0
docker compose exec web drush config-set system.performance js.preprocess 0
docker compose exec web composer require drupal/stage_file_proxy
docker compose exec web drush en stage_file_proxy
docker compose exec web drush config-set stage_file_proxy.settings origin "https://www.your-production-url"
https://www.drupal.org/project/stage_file_proxy/issues/3490259
docker compose exec web composer require drupal/stage_file_proxy:^3.1
e.g. https://agriculture.ec.europa.eu
Get access to the website
docker-compose exec web drush -r build uli
docker system prune -a
Aggresive mode: killing dangling/orphans containers
docker volume rm $(docker volume ls -qf dangling=true)
Inspecting containers
docker logs
docker logs web
Debugging Drupal errors: add the following line to your settings.php
$config['system.logging']['error_level']='verbose';
Check errors in watchdog
docker-compose exec web drush wd-list
Clear cache
docker-compose exec web drush cr
Putting down the containers
docker-compose ps
docker-compose stop
or
docker-compose down
Add custom command aliases and credentials to your local environment
nano ~/.bashrc
Now, add the lines in this file. From now on you can use these aliases
instead of long commands
alias dc="docker compose"
alias dcweb="docker compose exec web"
alias dcrun="docker compose exec web vendor/bin/run"
alias dcbash="docker compose exec web bash"
alias dcdrush="docker compose exec web vendor/bin/drush"
alias dockerrmall='docker rm $(docker ps -a -q)'
alias dockerstopall='docker kill $(docker ps -q)'
alias dockerrmimgall='docker rmi $(docker images -q)'
alias dockerrmiorphans='docker volume rm $(docker volume ls -qf dangling=true)'
export GITLAB_USER="your-git-name"
export GITLAB_PASS="your-git-access-token"
export NEXTCLOUD_USER="your-nextcloud-name"
export NEXTCLOUD_PASS="your-app-token"
export BLACK_USER="your-username-mailaddress"
export BLACK_PASS="your-blackfire-pass"
Save and execute bashrc
source ~/.bashrc
[Recommended] Symlink .bashrc
for handyness
ln -s ~/.bashrc ~/environment/bashref
Export
docker-compose exec -T web drush cr
docker-compose exec -T web drush sql-dump --gzip --result-file=/path/to/db-file.sql
Drop current database
docker-compose exec -T web drush sql-drop -y
note: just in case drush path is not found: docker-compose exec -T web ./vendor/bin/drush sql-drop -y
Import
docker-compose exec -T web drush sql-cli < ~/path/to/db-file.sql
docker-compose exec -T web drush sql:query "SELECT * FROM users WHERE uid=1"
Run from query file and save to a file
docker-compose exec -T web drush sql:query --file=FILE --result-file[=RESULT-FILE]
--result-file[=RESULT-FILE]. Save to a file. The file should be relative to Drupal root.
--file=FILE
In case it is a new site:
docker compose exec web cp web/sites/default/default.settings.php web/sites/default/settings.php
docker compose exec web chmod a+w settings.php
If necessary
sudo chown root:root -R .git