Go to file
Bachir Soussi Chiadmi e74b3ed02e update 2024-03-15 12:04:51 +01:00
Docker update 2024-03-15 12:04:51 +01:00
log first commit 2024-02-20 11:18:05 +01:00
ressources re-enabled salt 2024-02-21 22:09:38 +01:00
src@1f8059afbd update 2024-03-15 12:04:51 +01:00
.env first commit 2024-02-20 11:18:05 +01:00
.gitignore first commit 2024-02-20 11:18:05 +01:00
.gitmodules first commit 2024-02-20 11:18:05 +01:00
Makefile removed drush launcher 2024-02-23 16:42:47 +01:00
README.md first commit 2024-02-20 11:18:05 +01:00
docker-compose.yml first commit 2024-02-20 11:18:05 +01:00

README.md

Quartiers de demain Docker

Quartiers de demain powered by druapl 10 in docker environement (nginx, php:8.1-fpm+drush, mariadb, redis:4, phpmyadmin, x-debug)

Install docker

sudo pacman -S docker docker-compose docker-machine

art 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 quartiers-de-demain.archi.fr drupal 10 source code (without sites/default folder nor mysq ddbs)

git clone --recursive -o figli https://figureslibres.io/gitea/bachir/docker-quartiersdedemain

submodules :

touch log file

touch log/nginx/error.log
touch log/nginx/q2d/error.log

setup /sites/default/settings.php

cp -r ressources/drupal/settings.php src/web/sites/default/
cp -r ressources/drupal/settings.local.php src/web/sites/default/
cp -r ressources/drupal/services.yml src/web/sites/default/

get the sites/default/salt.txt file (if you don't have it, you don't)

get the sites/default/files folder

rsync the files from you know where (if you don't, you don't) to src/sites/default/files/

Mysql

Copy your-sql-dump.sql files into ./ressources/q2d.sql They will be automaticly imported into the mysql containers dbs (only) on the first docker-compose up

Hosts and reverse proxy

add to your /etc/hosts :

127.0.0.1	dev.d2d.fr
127.0.0.1	dev.phpmyadmin.q2d.fr

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

nginx

sudo mkdir /etc/var/log/q2d
server {
     listen 80;
     server_name dev.q2d.fr;

     access_log off;
     error_log  /var/log/nginx/q2d/error.log error;

     client_max_body_size 100m;

     location / {
         proxy_pass http://127.0.0.1:8980;
         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.q2d.fr;

     location / {
         proxy_pass http://127.0.0.1:8981;
         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;
     }
 }

apache

<Virtualhost *:80>
  ServerName dev.q2d.fr
  ProxyPass / http://127.0.0.1:8980/
  ProxyPassReverse / http://127.0.0.1:8980/
  ProxyRequests Off
  ProxyPreserveHost On
  proxy_buffer_size          128k;
  proxy_buffers              4 256k;
  proxy_busy_buffers_size    256k;
</Virtualhost>
<Virtualhost *:80>
  ServerName dev.phpmyadmin.q2d.fr
  ProxyPass / http://127.0.0.1:8981/
  ProxyPassReverse / http://127.0.0.1:8981/
  ProxyRequests Off
  ProxyPreserveHost On
  proxy_buffer_size          128k;
  proxy_buffers              4 256k;
  proxy_busy_buffers_size    256k;
</Virtualhost>

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.

usermod -aG docker yourusername
# https://wiki.archlinux.org/title/Docker#Installation
restart

docker-compose pull

pull the latest image of services

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)

make build

run

then each time you want to launch the app

make up

Be aware that a first up, since the db is empty, it will be populated with your files ressources/q2d.sql. It may take some time depending of your db size.

Drupal Composer install

Only at first up, finish to install drupal composer dependencies

make exec_php
composer install
# or juste
make composer_install

Visualize

You can now visit http://dev.q2d.fr on your browser After the first run

Coding

drush

you can access to drush by loging into the php container

make exec_php

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

Updating code

git pull figli master
# then update all submodules
git submodule update --recursive --checkout
# if you updated d9 code then run
make maj_config

Updating manualy the mysql db

copy your db backup into the mysql container

docker cp your-db-file.sql q2d-mysql-1:/root/

log into mysql container

make exec_mysql

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

mysql -uroot -pq2d
> drop database q2d;
> create database q2d;
> exit;
mysql -uroot -pq2d q2d < your-db-file-name.sql

Makefile

DO NOT use directly docker or docker-compose to run this instance

use make instead like make up

#!/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

maj_config: crd composer_install updb cim cr pag #dev.phpmyadmin.q2d.fr

crd:
		docker exec q2d-php-1 /bin/bash -c "drush cache-clear drush"

composer_install:
		docker exec q2d-php-1 /bin/bash -c "composer install --no-dev"

updb:
		docker exec q2d-php-1 /bin/bash -c "drush updb -y"

cim:
		docker exec q2d-php-1 /bin/bash -c "drush config-import -y"

# sync_struct:
# 		docker exec q2d-php-1 /bin/bash -c "drush im --choice safe && drush ib --choice full"

cr:
		docker exec q2d-php-1 /bin/bash -c "drush cr"

pag:
		docker exec q2d-php-1 /bin/bash -c "drush pag all canonical_entities:node && drush pag all canonical_entities:taxonomy_term"

restart_nginx:
		docker-compose restart nginx

restart_php:
		docker-compose restart php

down:
		docker-compose down

exec_nginx:
		docker exec -it q2d-nginx-1 bash

exec_php:
		docker exec -it q2d-php-1 bash

exec_mysql:
		docker exec -it q2d-mysql-1 bash

dump_db:
	docker exec q2d-mysql-1 sh -c 'exec mysqldump -uroot -pq2d q2d' > ./ressources/q2d-$(DATE_NOW)-local.sql