From e1da6dd789c30ff997617a82d4ca70f8ca4c0848 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:41 +0100 Subject: [PATCH 1/9] docker-dev: fix paths for docker-compose volumes The folder was moved in c9519a1a5a2508fb08ea1b717bc4a9893cd60678 but the paths in 9a61a6e6c904cbd19ccade141340a7d3b8684647 were not updated afterwards. --- dev/build/docker-dev/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/build/docker-dev/docker-compose.yml b/dev/build/docker-dev/docker-compose.yml index cc2988a67d1..8a5c2a4b241 100644 --- a/dev/build/docker-dev/docker-compose.yml +++ b/dev/build/docker-dev/docker-compose.yml @@ -37,8 +37,8 @@ services: PHP_INI_DATE_TIMEZONE: $PHP_INI_DATE_TIMEZONE PHP_INI_MEMORY_LIMIT: $PHP_INI_MEMORY_LIMIT volumes: - - ../../htdocs:/var/www/html/ - - ../../documents:/var/documents + - ../../../htdocs:/var/www/html/ + - ../../../documents:/var/www/documents ports: - "80:80" - "9000:9000" From 2e7b90a31c27126eb527ed4e8580142b65fa8c65 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:44 +0100 Subject: [PATCH 2/9] docker-dev: fix LDAP configuration The libraries are not in /usr/lib/x86_64-gnu-linux anymore, multilib not being enabled. --- dev/build/docker-dev/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/build/docker-dev/Dockerfile b/dev/build/docker-dev/Dockerfile index 5cd4c60673b..601878c0211 100644 --- a/dev/build/docker-dev/Dockerfile +++ b/dev/build/docker-dev/Dockerfile @@ -27,7 +27,7 @@ RUN apt-get update -y \ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \ - && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ + && docker-php-ext-configure ldap \ && docker-php-ext-install -j$(nproc) ldap && \ mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini From 19d69eaac957912b93ac8d6a29941faf54fa580c Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:46 +0100 Subject: [PATCH 3/9] docker-dev: add support for postgresql database The PostgreSQL database can be used as the following: docker compose -f docker-compose.yml -f docker-compose.postgres.yml up This allows a bit more modularity and ensuring people can start a PostgreSQL development setup quickly. --- dev/build/docker-dev/Dockerfile | 3 ++- dev/build/docker-dev/postgres.yml | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 dev/build/docker-dev/postgres.yml diff --git a/dev/build/docker-dev/Dockerfile b/dev/build/docker-dev/Dockerfile index 601878c0211..f98726d4f8c 100644 --- a/dev/build/docker-dev/Dockerfile +++ b/dev/build/docker-dev/Dockerfile @@ -23,10 +23,11 @@ RUN apt-get update -y \ msmtp \ msmtp-mta \ mailutils \ + libpq-dev \ && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \ + && docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql pgsql gd soap zip \ && docker-php-ext-configure ldap \ && docker-php-ext-install -j$(nproc) ldap && \ mv ${PHP_INI_DIR}/php.ini-development ${PHP_INI_DIR}/php.ini diff --git a/dev/build/docker-dev/postgres.yml b/dev/build/docker-dev/postgres.yml new file mode 100644 index 00000000000..ab740658894 --- /dev/null +++ b/dev/build/docker-dev/postgres.yml @@ -0,0 +1,18 @@ +--- +networks: + internal-pod: + internal: true + external-pod: + internal: false + +services: + postgres: + image: postgres:latest + environment: + POSTGRES_PASSWORD: rootpassfordev + networks: + - internal-pod + - external-pod + web: + depends_on: + - postgres From 57ccb41c6ef5b26c9392388fdce514efaf772a98 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:47 +0100 Subject: [PATCH 4/9] docker-dev: remove files rights change in docker-run.sh File rights from the whole environment should not change since the files are belonging to the git tree. In addition, setting www-data to the same user id as the user (or likewise, setting a userns remapping) remove the need to change the rights. --- dev/build/docker-dev/docker-run.sh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dev/build/docker-dev/docker-run.sh b/dev/build/docker-dev/docker-run.sh index 07bc35947cf..7b78b2b1e65 100755 --- a/dev/build/docker-dev/docker-run.sh +++ b/dev/build/docker-dev/docker-run.sh @@ -2,19 +2,14 @@ # Script used by the Dockerfile. # See README.md to know how to create a Dolibarr env with docker +if [ "${HOST_USER_ID}" == "" ]; then + echo "Define HOST_USER_ID to your user ID before starting" + exit 1 +fi + usermod -u "${HOST_USER_ID}" www-data groupmod -g "${HOST_USER_ID}" www-data -chgrp -hR www-data /var/www/html -chmod g+rwx /var/www/html/conf - -if [ ! -d /var/documents ]; then - echo "[docker-run] => create volume directory /var/documents ..." - mkdir -p /var/documents -fi -echo "[docker-run] => Set Permission to www-data for /var/documents" -chown -R www-data:www-data /var/documents - echo "[docker-run] => update '${PHP_INI_DIR}/conf.d/dolibarr-php.ini'" cat < "${PHP_INI_DIR}/conf.d/dolibarr-php.ini" date.timezone = ${PHP_INI_DATE_TIMEZONE:-UTC} From f3613f0425d982539540e99e133ae8aa2c59bf90 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:49 +0100 Subject: [PATCH 5/9] docker-dev: compose: fix warnings version is deprecated and yaml document starts after --- marker. --- dev/build/docker-dev/docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/build/docker-dev/docker-compose.yml b/dev/build/docker-dev/docker-compose.yml index 8a5c2a4b241..4339b473258 100644 --- a/dev/build/docker-dev/docker-compose.yml +++ b/dev/build/docker-dev/docker-compose.yml @@ -1,5 +1,4 @@ -version: '3' - +--- networks: internal-pod: internal: true From 2b9deda89b4a85a9d24aa62087f8245d1406154f Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:50 +0100 Subject: [PATCH 6/9] docker-dev: README: set document width to 80 Improve terminal reading experience by limiting the document width to 80. On the web interface, markdown with merge every line into a single paragraph. --- dev/build/docker-dev/README.md | 15 +++++++++------ dev/build/docker-dev/docker-run.sh | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dev/build/docker-dev/README.md b/dev/build/docker-dev/README.md index bb5c82391f1..111d9f6b941 100644 --- a/dev/build/docker-dev/README.md +++ b/dev/build/docker-dev/README.md @@ -1,8 +1,9 @@ # How to use it ? -The docker-compose.yml file is a sample of a config file to use to build and run Dolibarr in the current workspace with Docker. -This docker image is intended for development usage. -For production usage you should consider other contributor reference like https://hub.docker.com/r/dolibarr/dolibarr +The docker-compose.yml file is a sample of a config file to use to build and run +Dolibarr in the current workspace with Docker. This docker image is intended for +**development usage**. For production usage you should consider other +contributor reference like https://hub.docker.com/r/dolibarr/dolibarr. Before build/run, define the variable HOST_USER_ID as following: @@ -26,9 +27,11 @@ The URL to go to PhpMyAdmin is (login/password is root/root) : http://0.0.0.0:8080 -In Dolibarr configuration Email let PHP mail function, To see all mail send by Dolibarr go to maildev +In Dolibarr configuration Email let PHP mail function, To see all mail send by +Dolibarr go to maildev http://0.0.0.0:8081 -Setup the database connection during the installation process, please use mariadb (name of the database container) as database host. -Setup documents folder, during the installation process, to /var/documents +Setup the database connection during the installation process, please use +mariadb (name of the database container) as database host. Setup documents +folder, during the installation process, to /var/documents. diff --git a/dev/build/docker-dev/docker-run.sh b/dev/build/docker-dev/docker-run.sh index 7b78b2b1e65..a3a1123c1f2 100755 --- a/dev/build/docker-dev/docker-run.sh +++ b/dev/build/docker-dev/docker-run.sh @@ -1,6 +1,7 @@ #!/bin/bash # Script used by the Dockerfile. # See README.md to know how to create a Dolibarr env with docker +set -ex if [ "${HOST_USER_ID}" == "" ]; then echo "Define HOST_USER_ID to your user ID before starting" @@ -14,6 +15,7 @@ echo "[docker-run] => update '${PHP_INI_DIR}/conf.d/dolibarr-php.ini'" cat < "${PHP_INI_DIR}/conf.d/dolibarr-php.ini" date.timezone = ${PHP_INI_DATE_TIMEZONE:-UTC} memory_limit = ${PHP_INI_MEMORY_LIMIT:-256M} +display_errors = Off EOF exec apache2-foreground From 99d9d991157612075d1348016736ea6d60b92200 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:51 +0100 Subject: [PATCH 7/9] docker-dev: README: use new docker compose subcommand docker-compose has been replaced by docker compose. --- dev/build/docker-dev/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/build/docker-dev/README.md b/dev/build/docker-dev/README.md index 111d9f6b941..820b9f3da3b 100644 --- a/dev/build/docker-dev/README.md +++ b/dev/build/docker-dev/README.md @@ -15,7 +15,7 @@ Go in repository build/docker : And then, you can run : - docker-compose up + docker compose up This will run 4 containers Docker : Dolibarr, MariaDB, PhpMyAdmin and MailDev. From e6516f06a4e339b111023741f039786d1f605c82 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:53 +0100 Subject: [PATCH 8/9] docker-dev: extract mariadb.yml from docker compose file This extracts the mariadb part to be able to compose different docker-compose manifests and use PostgreSQL instead for module development and debugging. --- dev/build/docker-dev/docker-compose.yml | 14 ---------- dev/build/docker-dev/mariadb.yml | 34 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 dev/build/docker-dev/mariadb.yml diff --git a/dev/build/docker-dev/docker-compose.yml b/dev/build/docker-dev/docker-compose.yml index 4339b473258..84a48d00f48 100644 --- a/dev/build/docker-dev/docker-compose.yml +++ b/dev/build/docker-dev/docker-compose.yml @@ -16,19 +16,6 @@ services: networks: - internal-pod - external-pod - - phpmyadmin: - image: phpmyadmin/phpmyadmin - environment: - PMA_HOST: mariadb - depends_on: - - mariadb - ports: - - "8080:80" - networks: - - internal-pod - - external-pod - web: build: . environment: @@ -42,7 +29,6 @@ services: - "80:80" - "9000:9000" depends_on: - - mariadb - mail networks: - internal-pod diff --git a/dev/build/docker-dev/mariadb.yml b/dev/build/docker-dev/mariadb.yml new file mode 100644 index 00000000000..c9b2e78ac18 --- /dev/null +++ b/dev/build/docker-dev/mariadb.yml @@ -0,0 +1,34 @@ +--- +networks: + internal-pod: + internal: true + external-pod: + internal: false + +services: + mariadb: + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: rootpassfordev + MYSQL_DATABASE: dolibarr + ports: + - "3306:3306" + networks: + - internal-pod + - external-pod + web: + depends_on: + - mariadb + phpmyadmin: + image: phpmyadmin/phpmyadmin + environment: + PMA_HOST: mariadb + depends_on: + - mariadb + ports: + - "8080:80" + networks: + - internal-pod + - external-pod + + From 39e07232147788e5a3fae9680eac4d668e8ea3b7 Mon Sep 17 00:00:00 2001 From: Alexandre Janniaux Date: Sun, 2 Feb 2025 20:09:54 +0100 Subject: [PATCH 9/9] docker-dev: README: improve usage documentation This commit adds more documentation on how to use the docker-compose setup in different environment (postgres / mariadb) as well as how to setup it for module development. --- dev/build/docker-dev/README.md | 39 ++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/dev/build/docker-dev/README.md b/dev/build/docker-dev/README.md index 820b9f3da3b..22a1a671121 100644 --- a/dev/build/docker-dev/README.md +++ b/dev/build/docker-dev/README.md @@ -13,11 +13,18 @@ Go in repository build/docker : cd dev/build/docker -And then, you can run : +And then, depending on whether you want to run with a MariaDB database or +PostgreSQL database, you can run: - docker compose up + docker compose -f docker-compose.yml -f mariadb.yml up + +or + + docker compose -f docker-compose.yml -f postgres.yml up This will run 4 containers Docker : Dolibarr, MariaDB, PhpMyAdmin and MailDev. +In the case of PostgreSQL, only Dolibarr, MailDev and the PostgreSQL database +will be running. The URL to go to the Dolibarr is : @@ -33,5 +40,29 @@ Dolibarr go to maildev http://0.0.0.0:8081 Setup the database connection during the installation process, please use -mariadb (name of the database container) as database host. Setup documents -folder, during the installation process, to /var/documents. +mariadb or postgres (name of the database container) as database host. + +## Setup your custom modules + +You can setup your own modules from your development folder by using volume +mounts and docker compose override. For instance for your module "yourmodule" +located in `/path/to/your/module_folder`, you can edit `yourmodule.yml` and +write: + + --- + services: + web: + volumes: + - /path/to/your/module_folder:/var/www/html/custom/yourmodule/ + +This will add your module at runtime inside the dolibarr custom plugins and it +will automatically be synced with your development environment. + +Then, you can start by extending one of the commands above, for instance for +mariadb: + + docker compose \ + -f docker-compose.yml \ + -f postgres.yml \ + -f yourmodule.yml \ + up