2019-02-01 12:07:39 +01:00
2025-03-21 14:46:28 +01:00
2026-09-20 00:46:18 +02:00
2025-03-21 15:34:21 +01:00
2018-11-01 21:45:40 +01:00

Materio 8.x Docker Environement

Materio powered by druapl 8 in docker environement (nginx, php:7-fpm+drush, phpmyadmin, redis)

Install docker

sudo pacman -S docker docker-compose docker-machine

Clone this repos

this will clone this repos (main docker environement) and the edlp drupal 8 source code (without sites/default folder)

git clone --recursive -o figli https://figureslibres.io/gogs/bachir/docker-materio-d8.git

setup /sites/default/settings.php

cp -r ressources/default public_html/sites/

get the sites/default/files folder

get the files from where you have it and rsync it to public_html/sites/default/files/

Mysql

Copy your-sql-dump.sql into ./ressources/materio_d8.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.materio.com
127.0.0.1	dev.phpmyadmin.materio.com

configure your apache vhosts to add a reverse proxy that will redirect the dev.materio.com to our container

<Virtualhost *:80>
  ServerName dev.materio.com
  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;
</Virtualhost>
<Virtualhost *:80>
   ServerName dev.phpmyadmin.materio.com
   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;
</Virtualhost>

Docker

build

only before the first run (may take some time)

sudo docker-compose build

run

then each time you want to launch the app

sudo docker-compose up -d

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.

Druapal Composer install

Only at first up, finish to install drupal composer dependencies

sudo docker exec -it materiod8_php_1 bash
composer install

Visualize

You can now visit http://dev.materio.com on your browser

Coding

drush

you can access to drush by loging into the php container

sudo docker exec -it materiod8_php_1 bash

once inside the php container in /var/www/html you can use drush as usual

Xdebug

Xdebug is installed in the php container, listening for your IDE on host.docker.internal:9001 (see ressources/xdebug.ini, .vscode/launch.json in public_html).

Web and CLI behave differently on purpose, because leaving xdebug.mode=debug on all the time makes every drush/composer command noticeably slower (Xdebug hooks every function call as soon as the mode is active, whether or not a debugger actually connects):

  • Browser requests (php-fpm): Xdebug is always on (xdebug.mode=debug, xdebug.start_with_request=yes). Just start listening in your IDE and load the page, no trigger needed.
  • CLI (drush, composer, ...): Xdebug is off by default (xdebug.mode=off) so commands stay fast. To debug a specific command, turn it on for the current shell first:
    xdebugon
    drush some:command
    xdebugoff
    
    xdebugon/xdebugoff are shell aliases defined in /etc/bash.bashrc inside the php container (they set/unset XDEBUG_MODE=debug and XDEBUG_TRIGGER=1). You can also do it inline for a single command:
    XDEBUG_MODE=debug XDEBUG_TRIGGER=1 drush some:command
    

This split is implemented as two extra ini files loaded per-SAPI, see Docker/php/Dockerfile:

  • /usr/local/etc/php/conf.d/zz-xdebug-cli.ini → loaded by both CLI and php-fpm (default conf.d), sets xdebug.mode=off.
  • /usr/local/etc/php/fpm-conf.d/zz-xdebug-fpm.ini → only loaded by php-fpm (via PHP_INI_SCAN_DIR in /start.sh), overrides back to xdebug.mode=debug for web requests.

If you change any of these files, rebuild the php image (make buildphp) and recreate the container (make up) — do not use raw docker-compose up, it won't pick up USER_UID/USER_GID and the container will run as root (see Makefile section below).

gulp

Dev process needs gulp to run in:

  • public_html/sites/all/modules/custom/materio/
  • public_html/sites/all/themes/custom/materio/ if you have to modifie js or scss source code, you need to do in each of these 2 folder:
npm install
gulp

updateding manualy mysql db

copy your db backup into the mysql container

sudo docker cp your-db-file.sql materiod8_mysql_1:/root/

log into mysql container

sudo docker exec -it materiod8_mysql_1 bash

once inside the mysql container you can use mysql command to drop then create and load the db with your file

Makefile

do not use directly docker or docker-compose to run this instance use make instead like make up

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)

up:
		docker-compose up -d

upbuild:
		docker-compose up -d --build

ps:
		docker-compose ps

logs:
		docker-compose logs -f

down:
		docker-compose down

php:
		docker exec -it materiod8_php_1 bash

phplegacy:
		docker exec -it materiod8_php-legacy_1 bash

sources

https://www.ostraining.com/blog/drupal/docker/

http://tech.osteel.me/posts/2017/01/15/how-to-use-docker-for-local-web-development-an-update.html

https://mmenozzi.github.io/2016/01/22/php-web-development-with-docker/

https://dzone.com/articles/continuous-drupal-maintaining-a-drupal-website-wit//

https://github.com/glaux/drupal8docker

https://www.jeffgeerling.com/blogs/jeff-geerling/drupal-8-redis-php-7-nginx-and

https://chromatichq.com/blog/configuring-redis-caching-drupal-8

S
Description
No description provided
Readme
1.6 MiB
Languages
PHP 32.4%
XSLT 24.4%
JavaScript 22.9%
Dockerfile 7.7%
CSS 3.8%
Other 8.8%