diff --git a/.env b/.env index 964a7f3..e4f96b0 100644 --- a/.env +++ b/.env @@ -1,10 +1,15 @@ COMPOSE_PROJECT_NAME=popsu -PROJECT_ROOT=./public_html +PROJECT_ROOT_D7=./src_d7 +PROJECT_ROOT_D9=./src_d9 LOG_ROOT=./log -DB_IMPORTE_FILE=./ressources/db.sql +DB_IMPORTE_FILE_D7=./ressources/pospsu_d7.sql +DB_IMPORTE_FILE_D9=./ressources/pospsu_d9.sql DB_ROOT_PASSWORD=popsu -DB_NAME=popsu +DB_NAME_D7=popsu_d7 +DB_NAME_D9=popsu_d9 DB_USERNAME=popsu DB_PASSWORD=popsu + +XDEBUG_INI=./ressources/xdebug.ini diff --git a/.gitmodules b/.gitmodules index 0a9a858..088089e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ -[submodule "public_html"] - path = public_html +[submodule "src_d7"] + path = src_d7 url = https://figureslibres.io/gogs/bachir/popsu-d7.git +[submodule "src_d9"] + path = src_d9 + url = https://figureslibres.io/gogs/bachir/popsu-d9.git diff --git a/Docker/nginx/Dockerfile b/Docker/nginx/Dockerfile index f1acc2d..aa36a6e 100644 --- a/Docker/nginx/Dockerfile +++ b/Docker/nginx/Dockerfile @@ -1,3 +1,9 @@ FROM nginx:latest +RUN apt-get update \ + && apt-get install -y \ + vim + COPY ./default.conf /etc/nginx/conf.d/default.conf +COPY ./bashrc /root/.bashrc +COPY ./inputrc /root/.inputrc diff --git a/Docker/nginx/bashrc b/Docker/nginx/bashrc new file mode 100644 index 0000000..74d78f9 --- /dev/null +++ b/Docker/nginx/bashrc @@ -0,0 +1,3 @@ +PS1='\e[36m\e[1mNGINX\e[0m:\e[90m\w\e[0m\n$ ' +bind '"\e[A": history-search-backward' +bind '"\e[B": history-search-forward' diff --git a/Docker/nginx/default.conf b/Docker/nginx/default.conf index 83f32f4..658aafa 100644 --- a/Docker/nginx/default.conf +++ b/Docker/nginx/default.conf @@ -1,7 +1,8 @@ server { - listen 80 default_server; - root /var/www/html; + listen 80; + root /var/www/d7; index index.html index.php; + server_name dev.d7.popsu.archi.fr; charset utf-8; @@ -13,7 +14,7 @@ server { location = /robots.txt { access_log off; log_not_found off; } access_log on; - error_log /var/log/nginx/error.log error; + error_log /var/log/nginx/error-d7.log error; sendfile off; @@ -21,7 +22,45 @@ server { location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass php:9000; + fastcgi_pass php_d7:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_intercept_errors off; + fastcgi_buffer_size 16k; + fastcgi_buffers 4 16k; + } + + location ~ /\.ht { + deny all; + } +} + +server { + listen 80; + root /var/www/d9/web; + index index.html index.php; + server_name dev.d9.popsu.archi.fr; + + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location = /favicon.ico { access_log off; log_not_found off; } + location = /robots.txt { access_log off; log_not_found off; } + + access_log on; + error_log /var/log/nginx/error-d9.log error; + + sendfile off; + + client_max_body_size 100m; + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php_d9:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; diff --git a/Docker/nginx/inputrc b/Docker/nginx/inputrc new file mode 100644 index 0000000..db8d91d --- /dev/null +++ b/Docker/nginx/inputrc @@ -0,0 +1,2 @@ +set show-all-if-ambiguous on +set completion-ignore-case on diff --git a/Docker/php/Dockerfile b/Docker/php-5.6-fpm/Dockerfile similarity index 60% rename from Docker/php/Dockerfile rename to Docker/php-5.6-fpm/Dockerfile index 82cc8cb..5da3a85 100644 --- a/Docker/php/Dockerfile +++ b/Docker/php-5.6-fpm/Dockerfile @@ -23,3 +23,24 @@ RUN apt-get update && apt-get install -y \ composer global require drush/drush:6.5.0 && \ composer global install && \ ln -s /usr/local/composer/vendor/drush/drush/drush /usr/local/bin/drush + +ARG USER_UID +ARG USER_UNAME +ARG USER_GID +ARG USER_GNAME + +RUN if getent group ${USER_GNAME} ; then groupdel ${USER_GNAME}; fi &&\ + groupadd -g ${USER_GID} ${USER_GNAME} &&\ + useradd -l -u ${USER_UID} -g ${USER_GNAME} ${USER_UNAME} &&\ + install -d -m 0755 -o ${USER_UNAME} -g ${USER_GNAME} /home/${USER_UNAME} &&\ + chown --changes --silent --no-dereference --recursive \ + --from=33:33 ${USER_UID}:${USER_GID} \ + /home/${USER_UNAME} + # /.composer \ + # /var/run/php-fpm \ + # /var/lib/php/sessions \ + +COPY ./bashrc /home/${USER_UNAME}/.bashrc +COPY ./inputrc /home/${USER_UNAME}/.inputrc + +USER ${USER_UNAME} diff --git a/Docker/php-5.6-fpm/bashrc b/Docker/php-5.6-fpm/bashrc new file mode 100644 index 0000000..b2998d2 --- /dev/null +++ b/Docker/php-5.6-fpm/bashrc @@ -0,0 +1,4 @@ + +PS1='\e[36m\e[1mPHP-5.6\e[0m:\e[90m\w\e[0m\n$ ' +bind '"\e[A": history-search-backward' +bind '"\e[B": history-search-forward' diff --git a/Docker/php-5.6-fpm/inputrc b/Docker/php-5.6-fpm/inputrc new file mode 100644 index 0000000..db8d91d --- /dev/null +++ b/Docker/php-5.6-fpm/inputrc @@ -0,0 +1,2 @@ +set show-all-if-ambiguous on +set completion-ignore-case on diff --git a/Docker/php/php-custom.ini b/Docker/php-5.6-fpm/php-custom.ini similarity index 100% rename from Docker/php/php-custom.ini rename to Docker/php-5.6-fpm/php-custom.ini diff --git a/Docker/php-7.3-fpm/Dockerfile b/Docker/php-7.3-fpm/Dockerfile new file mode 100644 index 0000000..e78bde8 --- /dev/null +++ b/Docker/php-7.3-fpm/Dockerfile @@ -0,0 +1,70 @@ +FROM php:7.3-fpm + +RUN apt-get update && apt-get install -y \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + mariadb-client \ + zip \ + libzip-dev && \ + # docker-php-ext-install -j$(nproc) iconv && \ + docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \ + apt-get install -y imagemagick libmagickwand-dev && \ + pecl install imagick && docker-php-ext-enable imagick && \ + docker-php-ext-install -j$(nproc) gd && \ + docker-php-ext-install pdo_mysql zip && \ + docker-php-ext-install opcache && \ + docker-php-ext-install bcmath && \ + apt-get install -y git vim && \ + pecl install redis-4.3.0 && \ + pecl install xdebug-2.7.0 && \ + docker-php-ext-enable redis xdebug + +RUN export COMPOSER_HOME=/usr/local/composer && \ + curl -sS https://getcomposer.org/installer \ + | php -- --install-dir=/usr/local/bin --filename=composer && \ + curl https://drupalconsole.com/installer \ + -L -o /usr/local/bin/drupal && \ + chmod +x /usr/local/bin/drupal && \ + curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar \ + -L -o /usr/local/bin/drush && \ + chmod +x /usr/local/bin/drush + +RUN apt-get install -y curl && \ + curl -sL https://deb.nodesource.com/setup_11.x | bash - && \ + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ + apt-get update && \ + apt-get install -y nodejs yarn + +RUN apt-get install -y rsyslog +COPY ./rsyslog-drupal.conf /etc/rsyslog.d/drupal.conf +# ENTRYPOINT ["sh", "-c", "service rsyslog start ; tail -f /dev/null"] + +COPY ./php-custom.ini /usr/local/etc/php/conf.d/php-custom.ini +# COPY ./php-fpm-custom.conf /usr/local/etc/php-fpm.d/php-fpm-custom.conf + +# COPY ./bashrc /root/.bashrc +# COPY ./inputrc /root/.inputrc + +ARG USER_UID +ARG USER_UNAME +ARG USER_GID +ARG USER_GNAME + +RUN if getent group ${USER_GNAME} ; then groupdel ${USER_GNAME}; fi &&\ + groupadd -g ${USER_GID} ${USER_GNAME} &&\ + useradd -l -u ${USER_UID} -g ${USER_GNAME} ${USER_UNAME} &&\ + install -d -m 0755 -o ${USER_UNAME} -g ${USER_GNAME} /home/${USER_UNAME} &&\ + chown --changes --silent --no-dereference --recursive \ + --from=33:33 ${USER_UID}:${USER_GID} \ + /home/${USER_UNAME} + # /.composer \ + # /var/run/php-fpm \ + # /var/lib/php/sessions \ + +COPY ./bashrc /home/${USER_UNAME}/.bashrc +COPY ./inputrc /home/${USER_UNAME}/.inputrc + +USER ${USER_UNAME} diff --git a/Docker/php-7.3-fpm/bashrc b/Docker/php-7.3-fpm/bashrc new file mode 100644 index 0000000..70f55f9 --- /dev/null +++ b/Docker/php-7.3-fpm/bashrc @@ -0,0 +1,4 @@ + +PS1='\e[36m\e[1mPHP-7.3\e[0m:\e[90m\w\e[0m\n$ ' +bind '"\e[A": history-search-backward' +bind '"\e[B": history-search-forward' diff --git a/Docker/php-7.3-fpm/inputrc b/Docker/php-7.3-fpm/inputrc new file mode 100644 index 0000000..db8d91d --- /dev/null +++ b/Docker/php-7.3-fpm/inputrc @@ -0,0 +1,2 @@ +set show-all-if-ambiguous on +set completion-ignore-case on diff --git a/Docker/php-7.3-fpm/php-custom.ini b/Docker/php-7.3-fpm/php-custom.ini new file mode 100644 index 0000000..ac5669b --- /dev/null +++ b/Docker/php-7.3-fpm/php-custom.ini @@ -0,0 +1,9 @@ +memory_limit = 8192M +upload_max_filesize = 50M +post_max_size = 50M +max_execution_time = 150 + +; Log level +; Possible Values: alert, error, warning, notice, debug +; Default Value: notice +log_level = debug diff --git a/Docker/php-7.3-fpm/php-fpm-custom.conf b/Docker/php-7.3-fpm/php-fpm-custom.conf new file mode 100644 index 0000000..8c6ab5d --- /dev/null +++ b/Docker/php-7.3-fpm/php-fpm-custom.conf @@ -0,0 +1 @@ +request_terminate_timeout = 150 diff --git a/Docker/php-7.3-fpm/rsyslog-drupal.conf b/Docker/php-7.3-fpm/rsyslog-drupal.conf new file mode 100644 index 0000000..145f7bb --- /dev/null +++ b/Docker/php-7.3-fpm/rsyslog-drupal.conf @@ -0,0 +1 @@ +local6.* /var/log/drupal.log diff --git a/Docker/php-7.3-fpm/rsyslog.service b/Docker/php-7.3-fpm/rsyslog.service new file mode 100644 index 0000000..19ac9dd --- /dev/null +++ b/Docker/php-7.3-fpm/rsyslog.service @@ -0,0 +1,17 @@ +[Unit] +Description=rsyslog +After=docker.service +Requires=docker.service + +[Service] +ExecStartPre=-/usr/bin/docker rm %n +ExecStart=/usr/bin/docker run --rm \ + --name %n \ + -h %H \ + jumanjiman/rsyslog +ExecStop=/usr/bin/docker stop %n +RestartSec=5s +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..10e294b --- /dev/null +++ b/Makefile @@ -0,0 +1,68 @@ +#!/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) + +export USER_UID +export USER_UNAME +export USER_GID +export USER_GNAME + +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_cr + +d9_crd: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "drush cache-clear drush" + +d9_cr: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "drush cr" + +d9_updb: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "drush updb -y" + +d9_cim: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "drush config-import -y" + +d9_composer_install: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "composer install --no-dev" + +down: + docker-compose down + +exec_nginx: + docker exec -it popsu_nginx_1 bash + +exec_php_d7: + docker exec -it popsu_php_d7_1 bash + +exec_php_d9: + docker exec -it popsu_php_d9_1 sh + +exec_mysql_d7: + docker exec -it popsu_mysql_d7_1 bash + +exec_mysql_d9: + docker exec -it popsu_mysql_d9_1 bash diff --git a/README.md b/README.md index ac3ea06..34d3d1f 100644 --- a/README.md +++ b/README.md @@ -7,97 +7,286 @@ Popsu powered by druapl 7 in docker environement (nginx, php:5.6-fpm+drush, mar 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 + ## Clone this repos -this will clone this repos (main docker environement) and the materio-base drupal 7 source code (without sites/default folder) +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 -o figli https://figureslibres.io/gogs/bachir/docker-popsu-d7.git +git clone --recursive -o figli https://figureslibres.io/gogs/bachir/docker-popsu.git ``` +submodules : +- https://figureslibres.io/gogs/bachir/popsu-d7 +- https://figureslibres.io/gogs/bachir/popsu-d9 + ### setup /sites/default/settings.php -```cp -r ressources/default public_html/sites/``` +``` +cp -r ressources/d7/settings.php src_d7/sites/default/ +cp -r ressources/d9/settings.php src_d9/sites/default/ +``` ### get the sites/default/files folder -get the files from where you have it and rsync it to public_html/sites/default/files/ +get the files from where you have it and rsync it to src_d7/sites/default/files/ and src_d9/web/sites/default/files/ ## Mysql -Copy your-sql-dump.sql into ./ressources/db.sql +Copy your-sql-dump.sql into ./ressources/db_d7.sql or ./ressources/db_d9.sql It will be automaticly imported into the mysql container db (only) on the first docker-compose up ## Hosts and reverse proxy add to your /etc/hosts : ``` -127.0.0.1 dev.popsu.archi.fr +127.0.0.1 dev.d7.popsu.archi.fr +127.0.0.1 dev.d9.popsu.archi.fr 127.0.0.1 dev.phpmyadmin.popsu.archi.fr ``` configure your apache vhosts to add a reverse proxy that will redirect the dev.materio.com to our container -``` +```apache - ServerName dev.popsu.archi.fr - ProxyPass / http://127.0.0.1:8880/ - ProxyPassReverse / http://127.0.0.1:8880/ - ProxyRequests Off + ServerName dev.d7.popsu.archi.fr + ProxyPass / http://127.0.0.1:8880/ + ProxyPassReverse / http://127.0.0.1:8880/ + ProxyRequests Off + ProxyPreserveHost On + proxy_buffer_size 128k; + proxy_buffers 4 256k; + proxy_busy_buffers_size 256k; + + + ServerName dev.d9.popsu.archi.fr + ProxyPass / http://127.0.0.1:8880/ + ProxyPassReverse / http://127.0.0.1:8880/ + ProxyRequests Off + ProxyPreserveHost On + proxy_buffer_size 128k; + proxy_buffers 4 256k; + proxy_busy_buffers_size 256k; + + + ServerName dev.phpmyadmin.popsu.archi.fr + ProxyPass / http://127.0.0.1:8881/ + ProxyPassReverse / http://127.0.0.1:8881/ + ProxyRequests Off + ProxyPreserveHost On + proxy_buffer_size 128k; + proxy_buffers 4 256k; + proxy_busy_buffers_size 256k; ``` +nginx +```nginx +server { + listen 80; + server_name dev.d7.popsu.archi.fr dev.d9.popsu.archi.fr; + + access_log off; + error_log /var/log/nginx/popsu/error.log error; + + client_max_body_size 100m; + + location / { + proxy_pass http://127.0.0.1:8880; + 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.popsu.archi.fr; + + location / { + proxy_pass http://127.0.0.1:8881; + 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; + } + } ``` - - ServerName dev.phpmyadmin.popsu.archi.fr - ProxyPass / http://127.0.0.1:8881/ - ProxyPassReverse / http://127.0.0.1:8881/ - ProxyRequests Off - -``` + ## 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. + +### docker-compose pull +pull the latest image of services +``` +make pull +``` + ### build only before the first run (may take some time) ``` -sudo docker-compose build +make build ``` +/!\ DO NOT use ```docker-compose build```, it will faile + ### run then each time you want to launch the app ``` -sudo docker-compose up -d +make up ``` -Be aware that a first up, since the db is empty, it will be populated with your file db.sql. It may take some time depending of your db size. +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. -### loging in +## Drupal Composer install +Only at first up, finish to install drupal 9 composer dependencies +but first we need to downgrade composer to version 1 +(you'll need to do this downgrade every time you make_down then make_up) ``` -sudo docker exec -it popsu_php_1 bash +docker exec -u 0 -it popsu_php_d9_1 /bin/bash +composer selfupdate --1 +``` +ctrl+d +``` +make exec_php_d9 +composer install ``` ## Visualize -You can now visit http://dev.popsu.archi.fr on your browser +You can now visit http://dev.d7.popsu.archi.fr and http://dev.d9.popsu.archi.fr on your browser After the first run ## Coding ### drush you can access to drush by loging into the php container ``` -sudo docker exec -it popsu_php_1 bash +make exec_php_d7 +# or +make exec_php_d9 ``` once inside the php container in /var/www/html you can use drush as usual -## updateding manualy mysql db -copy your db backup into the mysql container + +## Updating code + ``` -sudo docker cp your-db-file.sql popsu_mysql_1:/root/ +git pull figli master +# then update all submodules +git submodule update --recursive --checkout +# or only one +git submodule update --checkout src_d7/ +# or +git submodule update --checkout src_d9/ +make d9_maj_config +``` + +## Updating manualy mysql db +copy your db backup into the mysql container +```sh +docker cp your-db-file.sql popsu_mysql_d7_1:/root/ +# or +docker cp your-db-file.sql popsu_mysql_d9_1:/root/ ``` log into mysql container -``` -sudo docker exec -it popsu_php_1 bash +```sh +make exec_mysql_d7 +# or +make exec_mysql_d9 ``` once inside the mysql container you can use mysql command to drop then create and load the db with your file +``` +mysql -uroot -ppopsu +> drop database popsu_d7; +> create database popsu_d7; +> exit; +mysql -uroot -ppopsu popsu_d7 < your-db-file.sql +# or +mysql -uroot -ppopsu +> drop database popsu_d9; +> create database popsu_d9; +> exit; +mysql -uroot -ppopsu popsu_d9 < your-db-file.sql +``` -# sources -https://www.ostraining.com/blog/drupal/docker/ +## Makefile -http://tech.osteel.me/posts/2017/01/15/how-to-use-docker-for-local-web-development-an-update.html +DO NOT use directly docker or docker-compose to run this instance +use make instead like ```make up``` -https://mmenozzi.github.io/2016/01/22/php-web-development-with-docker/ +```makefile +#!/usr/bin/make -https://dzone.com/articles/continuous-drupal-maintaining-a-drupal-website-wit +SHELL = /bin/sh + +USER_UID := $(shell id -u) +USER_UNAME := $(shell id -un) +USER_GID := $(shell id -g) +USER_GNAME := $(shell id -gn) + +export USER_UID +export USER_UNAME +export USER_GID +export USER_GNAME + +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_cr + +d9_crd: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "drush cache-clear drush" + +d9_cr: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "drush cr" + +d9_updb: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "drush updb -y" + +d9_cim: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "drush config-import -y" + +d9_composer_install: + docker exec enfrancais_pgp_d9_1 /bin/bash -c "composer install --no-dev" + +down: + docker-compose down + +exec_php_d7: + docker exec -it popsu_php_d7_1 bash + +exec_php_d9: + docker exec -it popsu_php_d9_1 sh + +exec_mysql_d7: + docker exec -it popsu_mysql_d7 bash + +exec_mysql_d9: + docker exec -it popsu_mysql_d9 bash + +``` diff --git a/docker-compose.yml b/docker-compose.yml index 5a61d7c..e57141f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,31 @@ version: "3.5" services: - mysql: + mysql_d7: image: mariadb:latest volumes: - - db-data:/var/lib/mysql + - db-data-d7:/var/lib/mysql - ./Docker/mysql/mysql.cnf:/etc/mysql/conf.d/custom.cnf:ro - - "${DB_IMPORTE_FILE}:/docker-entrypoint-initdb.d/db.sql" + - "${DB_IMPORTE_FILE_D7}:/docker-entrypoint-initdb.d/popsu_d7.sql" networks: - database environment: MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}" - MYSQL_DATABASE: "${DB_NAME}" + MYSQL_DATABASE: "${DB_NAME_D7}" + MYSQL_USER: "${DB_USERNAME}" + MYSQL_PASSWORD: "${DB_PASSWORD}" + + mysql_d9: + image: mariadb:latest + volumes: + - db-data-d9:/var/lib/mysql + - ./Docker/mysql/mysql.cnf:/etc/mysql/conf.d/custom.cnf:ro + - "${DB_IMPORTE_FILE_D9}:/docker-entrypoint-initdb.d/popsu_d9.sql" + networks: + - database + environment: + MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}" + MYSQL_DATABASE: "${DB_NAME_D9}" MYSQL_USER: "${DB_USERNAME}" MYSQL_PASSWORD: "${DB_PASSWORD}" @@ -24,19 +38,40 @@ services: ports: - "6379" - php: - build: ./Docker/php/ - expose: - - 9000 + php_d7: + build: ./Docker/php-5.6-fpm/ + # expose: + # - 9000 volumes: - - php-root-data:/root - - "${PROJECT_ROOT}:/var/www/html" + - php-d7-user-data:/home/${USER_UNAME} + - "${PROJECT_ROOT_D7}:/var/www/d7" + working_dir: "/var/www/d7" networks: - database - server - redis depends_on: - - mysql + - mysql_d7 + - redis + + php_d9: + build: ./Docker/php-7.3-fpm/ + # expose: + # - 8999 + user: ${USER_UID}:${USER_GID} + volumes: + - php-d9-user-data:/home/${USER_UNAME} + - "${PROJECT_ROOT_D9}:/var/www/d9" + - "${LOG_ROOT}/php:/var/log:rw" + - "${XDEBUG_INI}:/usr/local/etc/php/conf.d/xdebug.ini" + working_dir: "/var/www/d9" + networks: + - database + - redis + - server + depends_on: + - mysql_d9 + - redis phpmyadmin: image: phpmyadmin/phpmyadmin @@ -45,26 +80,32 @@ services: networks: - database depends_on: - - mysql + - mysql_d7 + - mysql_d9 environment: - PMA_HOST: mysql + PMA_HOST: mysql_d7, mysql_d9 nginx: build: ./Docker/nginx/ ports: - 8880:80 + working_dir: "/var/www" volumes: - - "${PROJECT_ROOT}:/var/www/html" + - "${PROJECT_ROOT_D7}:/var/www/d7" + - "${PROJECT_ROOT_D9}:/var/www/d9" - "${LOG_ROOT}:/var/log:rw" networks: - server depends_on: - - php + - php_d7 + - php_d9 volumes: - db-data: + db-data-d7: + db-data-d9: redis-data: - php-root-data: + php-d7-user-data: + php-d9-user-data: networks: database: diff --git a/public_html b/public_html deleted file mode 160000 index a8891db..0000000 --- a/public_html +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a8891db0143cdea55b911f1fc2e04a1e119ede32 diff --git a/ressources/default/settings.php b/ressources/d7/settings.php similarity index 71% rename from ressources/default/settings.php rename to ressources/d7/settings.php index 9adf1f5..61481d2 100644 --- a/ressources/default/settings.php +++ b/ressources/d7/settings.php @@ -1,5 +1,4 @@ array( + * 'big_selects' => 'SET SQL_BIG_SELECTS=1', + * ), + * 'pdo' => array( + * PDO::ATTR_TIMEOUT => 5, + * ), + * ); + * @endcode + * + * WARNING: These defaults are designed for database portability. Changing them + * may cause unexpected behavior, including potential data loss. + * + * @see DatabaseConnection_mysql::__construct + * @see DatabaseConnection_pgsql::__construct + * @see DatabaseConnection_sqlite::__construct + * * Database configuration format: * @code * $databases['default']['default'] = array( @@ -178,15 +200,21 @@ * ); * @endcode */ -$databases['default']['default'] = array( - 'driver' => 'mysql', - 'database' => 'materio_base_d7', - 'username' => 'root', - 'password' => 'materio', - 'host' => 'mysql', - 'prefix' => '', - 'collation' => 'utf8_general_ci', - ); +$databases = array ( + 'default' => + array ( + 'default' => + array ( + 'database' => 'popsu_d7', + 'username' => 'root', + 'password' => 'popsu', + 'host' => 'mysql_d7', + 'port' => '', + 'driver' => 'mysql', + 'prefix' => 'dbprefix_', + ), + ), +); /** * Access control for update.php script. @@ -205,10 +233,10 @@ $update_free_access = FALSE; * Salt for one-time login links and cancel links, form tokens, etc. * * This variable will be set to a random value by the installer. All one-time - * login links will be invalidated if the value is changed. Note that this - * variable must have the same value on every web server. If this variable is - * empty, a hash of the serialized database credentials will be used as a - * fallback salt. + * login links will be invalidated if the value is changed. Note that if your + * site is deployed on a cluster of web servers, you must ensure that this + * variable has the same value on each server. If this variable is empty, a hash + * of the serialized database credentials will be used as a fallback salt. * * For enhanced security, you may set this variable to a value using the * contents of a file outside your docroot that is never saved together @@ -218,7 +246,7 @@ $update_free_access = FALSE; * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); * */ -$drupal_hash_salt = ''; +$drupal_hash_salt = '0Zxsn2w4iHq1rq-nN7QvU-qaoGU8MaycbJciaHqLJGk'; /** * Base URL (optional). @@ -240,7 +268,7 @@ $drupal_hash_salt = ''; * It is not allowed to have a trailing slash; Drupal will add it * for you. */ -// $base_url = 'http://dev.materio.com'; // NO trailing slash! +# $base_url = 'http://www.example.com'; // NO trailing slash! /** * PHP settings: @@ -248,7 +276,7 @@ $drupal_hash_salt = ''; * To see what PHP settings are possible, including whether they can be set at * runtime (by using ini_set()), read the PHP documentation: * http://www.php.net/manual/en/ini.list.php - * See drupal_initialize_variables() in includes/bootstrap.inc for required + * See drupal_environment_initialize() in includes/bootstrap.inc for required * runtime settings and the .htaccess file for non-runtime settings. Settings * defined there should not be duplicated here so as to avoid conflict issues. */ @@ -290,13 +318,14 @@ ini_set('session.cookie_lifetime', 2000000); /** * Drupal automatically generates a unique session cookie name for each site - * based on on its full domain name. If you have multiple domains pointing at - * the same Drupal site, you can either redirect them all to a single domain - * (see comment in .htaccess), or uncomment the line below and specify their - * shared base domain. Doing so assures that users remain logged in as they - * cross between your various domains. + * based on its full domain name. If you have multiple domains pointing at the + * same Drupal site, you can either redirect them all to a single domain (see + * comment in .htaccess), or uncomment the line below and specify their shared + * base domain. Doing so assures that users remain logged in as they cross + * between your various domains. Make sure to always start the $cookie_domain + * with a leading dot, as per RFC 2109. */ -$cookie_domain = 'dev.materio.com'; +# $cookie_domain = '.example.com'; /** * Variable overrides: @@ -315,7 +344,7 @@ $cookie_domain = 'dev.materio.com'; * - anonymous: Defines the human-readable name of anonymous users. * Remove the leading hash signs to enable. */ - $conf['site_name'] = "materiO'"; +# $conf['site_name'] = 'My Drupal site'; # $conf['theme_default'] = 'garland'; # $conf['anonymous'] = 'Visitor'; @@ -330,42 +359,50 @@ $cookie_domain = 'dev.materio.com'; # $conf['maintenance_theme'] = 'bartik'; /** - * Enable this setting to determine the correct IP address of the remote - * client by examining information stored in the X-Forwarded-For headers. - * X-Forwarded-For headers are a standard mechanism for identifying client - * systems connecting through a reverse proxy server, such as Squid or - * Pound. Reverse proxy servers are often used to enhance the performance + * Reverse Proxy Configuration: + * + * Reverse proxy servers are often used to enhance the performance * of heavily visited sites and may also provide other site caching, - * security or encryption benefits. If this Drupal installation operates - * behind a reverse proxy, this setting should be enabled so that correct - * IP address information is captured in Drupal's session management, - * logging, statistics and access management systems; if you are unsure - * about this setting, do not have a reverse proxy, or Drupal operates in - * a shared hosting environment, this setting should remain commented out. + * security, or encryption benefits. In an environment where Drupal + * is behind a reverse proxy, the real IP address of the client should + * be determined such that the correct client IP address is available + * to Drupal's logging, statistics, and access management systems. In + * the most simple scenario, the proxy server will add an + * X-Forwarded-For header to the request that contains the client IP + * address. However, HTTP headers are vulnerable to spoofing, where a + * malicious client could bypass restrictions by setting the + * X-Forwarded-For header directly. Therefore, Drupal's proxy + * configuration requires the IP addresses of all remote proxies to be + * specified in $conf['reverse_proxy_addresses'] to work correctly. + * + * Enable this setting to get Drupal to determine the client IP from + * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set). + * If you are unsure about this setting, do not have a reverse proxy, + * or Drupal operates in a shared hosting environment, this setting + * should remain commented out. + * + * In order for this setting to be used you must specify every possible + * reverse proxy IP address in $conf['reverse_proxy_addresses']. + * If a complete list of reverse proxies is not available in your + * environment (for example, if you use a CDN) you may set the + * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. + * Be aware, however, that it is likely that this would allow IP + * address spoofing unless more advanced precautions are taken. */ # $conf['reverse_proxy'] = TRUE; /** - * Set this value if your proxy server sends the client IP in a header other - * than X-Forwarded-For. - * - * The "X-Forwarded-For" header is a comma+space separated list of IP addresses, - * only the last one (the left-most) will be used. - */ -# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; - -/** - * reverse_proxy accepts an array of IP addresses. - * - * Each element of this array is the IP address of any of your reverse - * proxies. Filling this array Drupal will trust the information stored - * in the X-Forwarded-For headers only if Remote IP address is one of - * these, that is the request reaches the web server from one of your - * reverse proxies. Otherwise, the client could directly connect to - * your web server spoofing the X-Forwarded-For headers. + * Specify every reverse proxy IP address in your environment. + * This setting is required if $conf['reverse_proxy'] is TRUE. */ # $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...); +/** + * Set this value if your proxy server sends the client IP in a header + * other than X-Forwarded-For. + */ +# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + /** * Page caching: * @@ -377,8 +414,7 @@ $cookie_domain = 'dev.materio.com'; * the cache. If the site has mostly anonymous users except a few known * editors/administrators, the Vary header can be omitted. This allows for * better caching in HTTP proxies (including reverse proxies), i.e. even if - * clients send different cookies, they still get content served from the cache - * if aggressive caching is enabled and the minimum cache time is non-zero. + * clients send different cookies, they still get content served from the cache. * However, authenticated users should access the site directly (i.e. not use an * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid * getting cached pages from the proxy. @@ -437,6 +473,42 @@ $cookie_domain = 'dev.materio.com'; # 'a.b.c.d', # ); +/** + * Fast 404 pages: + * + * Drupal can generate fully themed 404 pages. However, some of these responses + * are for images or other resource files that are not displayed to the user. + * This can waste bandwidth, and also generate server load. + * + * The options below return a simple, fast 404 page for URLs matching a + * specific pattern: + * - 404_fast_paths_exclude: A regular expression to match paths to exclude, + * such as images generated by image styles, or dynamically-resized images. + * If you need to add more paths, you can add '|path' to the expression. + * - 404_fast_paths: A regular expression to match paths that should return a + * simple 404 page, rather than the fully themed 404 page. If you don't have + * any aliases ending in htm or html you can add '|s?html?' to the expression. + * - 404_fast_html: The html to return for simple 404 pages. + * + * Add leading hash signs if you would like to disable this functionality. + */ +$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//'; +$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +$conf['404_fast_html'] = '404 Not Found

Not Found

The requested URL "@path" was not found on this server.

'; + +/** + * By default, fast 404s are returned as part of the normal page request + * process, which will properly serve valid pages that happen to match and will + * also log actual 404s to the Drupal log. Alternatively you can choose to + * return a 404 now by uncommenting the following line. This will reduce server + * load, but will cause even valid pages that happen to match the pattern to + * return 404s, rather than the actual page. It will also prevent the Drupal + * system log entry. Ensure you understand the effects of this before enabling. + * + * To enable this functionality, remove the leading hash sign below. + */ +# drupal_fast_404(); + /** * Authorized file system operations: * @@ -452,32 +524,3 @@ $cookie_domain = 'dev.materio.com'; * Remove the leading hash signs to disable. */ # $conf['allow_authorize_operations'] = FALSE; - -// $conf['cache'] = 0; -$conf['preprocess_js'] = 0; -$conf['preprocess_css'] = 0; - -$conf['session_limit_max'] = 10; - -$conf['maillog_send'] = 0; -$conf['enforce_limit'] = 'no'; - - -$conf['search_api_solr_overrides'] = array( - 'materio_solr3_en' => array( - 'name' => t('Materio EN Solr Server (Overridden)'), - 'options' => array( - 'host' => 'solr', - 'port' => 8983, - 'path' => '/solr/materio_base_en', - ), - ), - 'materio_solr3_fr' => array( - 'name' => t('Materio FR Solr Server (Overridden)'), - 'options' => array( - 'host' => 'solr', - 'port' => 8983, - 'path' => '/solr/materio_base_fr', - ), - ), -); diff --git a/ressources/xdebug.ini b/ressources/xdebug.ini new file mode 100644 index 0000000..cacbdbe --- /dev/null +++ b/ressources/xdebug.ini @@ -0,0 +1,18 @@ +[xdebug] +xdebug.remote_enable=1 +;Should use host.docker.internal but not working on linux +xdebug.remote_host=172.20.0.1 +;Not working on docker context +xdebug.remote_connect_back=0 +;9000 is already bound by php-fpm +xdebug.remote_port=9001 +xdebug.remote_handler=dbgp +xdebug.remote_mode=req +xdebug.remote_autostart=true +; ?=XDEBUG_SESSION_START=1 +;Log file is mounted on volume so you can follow it +xdebug.remote_log=/var/log/xdebug-error.log +xdebug.profiler_enable_trigger=1 +xdebug.profiler_enable=0 +xdebug.profiler_output_dir=/var/log/ +; Example: http://localhost:8080/test?XDEBUG_PROFILE=1 diff --git a/src_d7 b/src_d7 new file mode 160000 index 0000000..be8cceb --- /dev/null +++ b/src_d7 @@ -0,0 +1 @@ +Subproject commit be8ccebfacf2255f28bc0f5a192272ad87d115d6 diff --git a/src_d9 b/src_d9 new file mode 160000 index 0000000..baea2a0 --- /dev/null +++ b/src_d9 @@ -0,0 +1 @@ +Subproject commit baea2a05ddd02a55f06f9690238a79a63a2f691c