commit 4b8f449b206f100090d826c4adc25d11dbd22457 Author: bach Date: Thu Sep 3 22:33:16 2026 +0200 Set up Docker stack for figli_compta (Drupal + MariaDB + nginx) Mirrors the leshed project's Docker layout. src/ is a git submodule containing the Drupal codebase. Co-Authored-By: Claude Sonnet 5 diff --git a/.env b/.env new file mode 100644 index 0000000..04fe22f --- /dev/null +++ b/.env @@ -0,0 +1,11 @@ +COMPOSE_PROJECT_NAME=figli_compta + +PROJECT_ROOT=./src +LOG_ROOT=./log + +DB_ROOT_PASSWORD=figli_compta +DB_NAME=figli_compta +DB_USERNAME=figli_compta +DB_PASSWORD=figli_compta + +XDEBUG_INI=./ressources/xdebug.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a81383 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +src/* +log/* +*.sql +*/*.gz diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ee1903d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src"] + path = src + url = https://figureslibres.io/gitea/bachir/drupal-figli-compta.git diff --git a/Docker/mysql/mysql.cnf b/Docker/mysql/mysql.cnf new file mode 100644 index 0000000..8d6fb74 --- /dev/null +++ b/Docker/mysql/mysql.cnf @@ -0,0 +1,2 @@ +[mysqld] +max_allowed_packet=500M diff --git a/Docker/nginx/Dockerfile b/Docker/nginx/Dockerfile new file mode 100644 index 0000000..020da33 --- /dev/null +++ b/Docker/nginx/Dockerfile @@ -0,0 +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 \ No newline at end of file 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 new file mode 100644 index 0000000..387d074 --- /dev/null +++ b/Docker/nginx/default.conf @@ -0,0 +1,41 @@ +server { + listen 80; + root /var/www/figli_compta/web; + index index.html index.php; + server_name dev.figli-compta.local; + + 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/figli_compta/error.log error; + + sendfile off; + + client_max_body_size 100m; + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass php: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; + } + + location ~ \.mjs$ { + default_type application/javascript; + } +} 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-8.4-fpm/Dockerfile b/Docker/php-8.4-fpm/Dockerfile new file mode 100644 index 0000000..cdf56d3 --- /dev/null +++ b/Docker/php-8.4-fpm/Dockerfile @@ -0,0 +1,65 @@ +FROM php:8.4-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 && \ +RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \ + 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 + + +RUN apt-get install -y git vim + +RUN pecl install redis && \ + docker-php-ext-enable redis + +RUN pecl install xdebug && \ + docker-php-ext-enable xdebug + +RUN export COMPOSER_HOME=/usr/local/composer && \ + curl -sS https://getcomposer.org/installer \ + | php -- --install-dir=/usr/local/bin --filename=composer && \ + 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 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-8.4-fpm/bashrc b/Docker/php-8.4-fpm/bashrc new file mode 100644 index 0000000..6c45676 --- /dev/null +++ b/Docker/php-8.4-fpm/bashrc @@ -0,0 +1,4 @@ + +PS1='\e[36m\e[1mPHP-8.1\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-8.4-fpm/inputrc b/Docker/php-8.4-fpm/inputrc new file mode 100644 index 0000000..db8d91d --- /dev/null +++ b/Docker/php-8.4-fpm/inputrc @@ -0,0 +1,2 @@ +set show-all-if-ambiguous on +set completion-ignore-case on diff --git a/Docker/php-8.4-fpm/php-custom.ini b/Docker/php-8.4-fpm/php-custom.ini new file mode 100644 index 0000000..ac5669b --- /dev/null +++ b/Docker/php-8.4-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-8.4-fpm/rsyslog-drupal.conf b/Docker/php-8.4-fpm/rsyslog-drupal.conf new file mode 100644 index 0000000..145f7bb --- /dev/null +++ b/Docker/php-8.4-fpm/rsyslog-drupal.conf @@ -0,0 +1 @@ +local6.* /var/log/drupal.log diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..00fd7b4 --- /dev/null +++ b/Makefile @@ -0,0 +1,76 @@ +#!/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 + + +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 + +crd: + docker exec figli_compta-php-1 /bin/bash -c "drush cache-clear drush" + +composer_install: + docker exec figli_compta-php-1 /bin/bash -c "composer install --no-dev" + +updb: + docker exec figli_compta-php-1 /bin/bash -c "drush updb -y" + +cim: + docker exec figli_compta-php-1 /bin/bash -c "drush config-import -y" + +cex: + docker exec figli_compta-php-1 /bin/bash -c "drush config-export -y" + +cr: + docker exec figli_compta-php-1 /bin/bash -c "drush cr" + +restart_nginx: + docker compose restart nginx + +restart_php: + docker compose restart php + +down: + docker compose down + +exec_nginx: + docker exec -it figli_compta-nginx-1 bash + +exec_php: + docker exec -it figli_compta-php-1 bash + +exec_mysql: + docker exec -it figli_compta-mysql-1 bash + +dump_db: + docker exec figli_compta-mysql-1 sh -c 'exec mariadb-dump -uroot -pfigli_compta figli_compta' > ./ressources/figli_compta-$(DATE_NOW)-local.sql diff --git a/README.md b/README.md new file mode 100644 index 0000000..008c8a6 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# figli_compta + +Outil métier interne pour la SAS Figures Libres : suivi des entrées/sorties +et du solde de chaque associé (Sandrine, Maud, Ouidade, Chloé, Bachir, +Valentin, EXT., EXT.WEB, Provision EPAU), et par client. + +Stack : Drupal 11 (content model + validation + auth + saisie) en decoupled +progressif, avec un dashboard Vue 3 (`/dashboard`) qui interroge JSON:API et +fait tous les calculs côté client. + +## Démarrage + +``` +make build +make up +``` + +Le code Drupal (`src/`) est un sous-module git séparé. + +- Site : http://localhost:8990 +- phpMyAdmin : http://localhost:8991 +- Identifiants admin de dev : admin / admin (à changer avant tout usage réel) + +## Structure + +- `Docker/` : Dockerfiles (php-8.4-fpm, nginx, config mysql) +- `src/` : code Drupal (sous-module git séparé) +- `ressources/` : templates settings.php/settings.local.php, xdebug.ini +- `log/` : logs nginx/php (non versionnés) + +## Modèle de données + +- Content type **Ligne comptable** : date, type (entrée/charge/versement/achat/ouverture), + client, montant HT/TTC, répartition. +- Paragraph **Répartition** : compte + montant. La somme des répartitions + doit toujours être égale au montant HT (contrôle automatique à la saisie). +- Taxonomies **Compte** (9 comptes) et **Client** (liste unifiée). diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8e5a3ec --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,66 @@ +services: + + mysql: + image: mariadb:latest + volumes: + - db-data:/var/lib/mysql + - ./Docker/mysql/mysql.cnf:/etc/mysql/conf.d/custom.cnf:ro + networks: + - database + environment: + MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}" + MYSQL_DATABASE: "${DB_NAME}" + MYSQL_USER: "${DB_USERNAME}" + MYSQL_PASSWORD: "${DB_PASSWORD}" + + php: + build: ./Docker/php-8.4-fpm/ + user: ${USER_UID}:${USER_GID} + volumes: + - php-user-data:/home/${USER_UNAME} + - "${PROJECT_ROOT}:/var/www/figli_compta" + - "${LOG_ROOT}/php:/var/log:rw" + - "${XDEBUG_INI}:/usr/local/etc/php/conf.d/xdebug.ini" + working_dir: "/var/www/figli_compta/" + environment: + - APP_ENV=development + - XDEBUG_MODE=debug + networks: + - database + - server + extra_hosts: + - host.docker.internal:host-gateway + depends_on: + - mysql + + phpmyadmin: + image: phpmyadmin/phpmyadmin + ports: + - 8991:80 + networks: + - database + depends_on: + - mysql + environment: + PMA_HOSTS: mysql + + nginx: + build: ./Docker/nginx/ + ports: + - 8990:80 + working_dir: "/var/www" + volumes: + - "${PROJECT_ROOT}:/var/www/figli_compta" + - "${LOG_ROOT}:/var/log:rw" + networks: + - server + depends_on: + - php + +volumes: + db-data: + php-user-data: + +networks: + database: + server: diff --git a/ressources/drupal/settings.local.php b/ressources/drupal/settings.local.php new file mode 100644 index 0000000..bfe061d --- /dev/null +++ b/ressources/drupal/settings.local.php @@ -0,0 +1,151 @@ +