# Engagement Qualite Logement Docker EQL powered by druapl 9 in docker environement (nginx, php:7.4-fpm+drush, mariadb, redis:6, phpmyadmin) ## Install docker ``` sudo pacman -S docker docker-compose docker-machine ``` start the docker service ``` sudo systemctl start docker ``` For all the following, DO NOT run docker or make commande as root or with sudo, use this setup: add your user to the docker user group, re-login, and restart docker.service. https://wiki.archlinux.org/index.php/Docker#Installation https://wiki.archlinux.org/title/Users_and_groups#Group_management ## Clone this repos this will clone this repos (main docker environement) and the popsu.arch.fr drupal 7 & 9 source code (without sites/default folder nor mysq ddbs) ``` git clone --recursive https://figureslibres.io/gogs/bachir/docker-eql.git ``` submodules : - https://figureslibres.io/gogs/bachir/eql-d9 ### setup drupal settings files ``` cp -r ressources/d9/settings.php src_d9/web/sites/default/ cp -r ressources/d9/settings.local.php src_d9/web/sites/default/ cp -r ressources/d9/services.yml src_d9/web/sites/default/ cp -r ressources/d9/development.services.yml src_d9/web/sites/default/ ``` ### get the sites/default/files folder rsync the files from "you know where" (if you don't, you don't) src_d9/web/sites/default/files/ ### xdebug copy ```ressources/xdebug.ini.exemple``` to ```ressources/xdebug.ini``` and edit the ```xdebug.remote_host``` ip to your host locale ip (e.g. : 192.168.0.23) (or once the docker is started to the host ip from the container point of vu e.g. 172.21.0.1) ## Mysql Copy your-sql-dump.sql file into ```./ressources/eql.sql``` It will be automaticly imported into the mysql containers db (only) on the first docker-compose up ## Hosts and reverse proxy add to your /etc/hosts : ``` 127.0.0.1 dev.eql.fr 127.0.0.1 dev.phpmyadmin.eql.fr ``` configure your vhosts to add a reverse proxy that will redirect the dev.materio.com to our container nginx ```nginx server { listen 80; server_name dev.eql.fr; access_log off; error_log /var/log/nginx/error-eql.log error; client_max_body_size 100m; location / { proxy_pass http://127.0.0.1:8987; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; } } server { listen 80; server_name dev.phpmyadmin.eql.fr; location / { proxy_pass http://127.0.0.1:8988; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; } } ``` or apache ```apache ServerName dev.eql.fr ProxyPass / http://127.0.0.1:8987/ ProxyPassReverse / http://127.0.0.1:8987/ ProxyRequests Off ProxyPreserveHost On proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; ServerName dev.phpmyadmin.eql.fr ProxyPass / http://127.0.0.1:8988/ ProxyPassReverse / http://127.0.0.1:8988/ ProxyRequests Off ProxyPreserveHost On proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; ``` ## Docker For all the following, DO NOT run docker or make commande as root or with sudo, use your regular user but first add your user to the docker user group, re-login, and restart docker.service. ```sh usermod -aG docker yourusername # https://wiki.archlinux.org/title/Docker#Installation restart ``` ### docker-compose pull pull the latest image of services ```sh make pull ``` ### build only before the first run (may take some time) /!\ DO NOT use ```docker-compose build```, it will fail (check Makefile for more info) ```sh make build ``` ### run then each time you want to launch the app ```sh make up ``` Be aware that a first up, since the db is empty, it will be populated with your files ressources/db_d7.sql and ressources/db_d9.sql. It may take some time depending of your db size. ## Drupal Composer install Only at first up, finish to install drupal 9 composer dependencies ```sh # option 1 # enter the container make exec_php # then once inside the container composer install # optiion 2 # or juste run make d9_composer_install ``` ## Visualize You can now visit http://dev.eql.fr on your browser ## Coding ### drush you can access to drush by loging into the php container ```sh make exec_php ``` once inside the php container in /var/www/html you can use drush as usual ## Updating code ```sh git pull origin master # then update all submodules git submodule update --recursive --checkout # then run d9 update make d9_maj_config ``` ## Updating manualy the mysql db copy your db backup into the mysql container ```sh docker cp path/to/your-db-file.sql eql-mysql-1:/root/ ``` log into mysql container ```sh make exec_mysql ``` once inside the mysql container you can use mysql command to drop then create and load the db with your file ``` cd /root/ mysql -uroot -peql > drop database eql; > create database eql; > exit; mysql -uroot -peql eql < your-db-file.sql ``` ## Makefile DO NOT use directly docker or docker-compose to run this instance instead use make like e.g. ```make up``` ```makefile #!/usr/bin/make SHELL = /bin/sh USER_UID := $(shell id -u) USER_UNAME := $(shell id -un) USER_GID := $(shell id -g) USER_GNAME := $(shell id -gn) DATE_NOW := $(shell date '+%Y-%m-%d_%H%M%S') export USER_UID export USER_UNAME export USER_GID export USER_GNAME # export DATE_NOW pull: docker-compose pull build: docker-compose build --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME) buildnc: docker-compose build --no-cache --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME) downbuildup: down build up up: docker-compose up -d ps: docker-compose ps logs: docker-compose logs -f d9_maj_config: d9_crd d9_composer_install d9_updb d9_cim d9_sync_struct d9_cr d9_pag d9_crd: docker exec eql-php-1 /bin/bash -c "drush cache-clear drush" d9_cr: docker exec eql-php-1 /bin/bash -c "drush cr" d9_updb: docker exec eql-php-1 /bin/bash -c "drush updb -y" d9_cim: docker exec eql-php-1 /bin/bash -c "drush config-import -y" d9_sync_struct: docker exec eql-php-1 /bin/bash -c "drush im --choice safe && drush ib --choice full" d9_pag: docker exec eql-php-1 /bin/bash -c "drush pag all canonical_entities:node && drush pag all canonical_entities:taxonomy_term" d9_composer_install: docker exec eql-php-1 /bin/bash -c "composer install --no-dev" down: docker-compose down exec_nginx: docker exec -it eql-nginx-1 bash exec_php: docker exec -it eql-php-1 bash exec_mysql: docker exec -it eql-mysql-1 bash dump_d9_db: docker exec eql-mysql_d9-1 sh -c 'exec mysqldump -uroot -peql eql' > ./ressources/eql-$(DATE_NOW)-local.sql ```