Skip to content

Commit

Permalink
Merge branch 'tuxgasy:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
freechelmi authored Jul 2, 2024
2 parents b5161d6 + 35b0ef2 commit a5ada89
Show file tree
Hide file tree
Showing 24 changed files with 919 additions and 34 deletions.
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ Docker image for Dolibarr with auto installer on first boot.

* 15.0.3-php7.4 15.0.3 15
* 16.0.5-php8.1 16.0.5 16
* 17.0.3-php8.1 17.0.3 17
* 18.0.2-php8.1 18.0.2 18 latest
* 17.0.4-php8.1 17.0.4 17
* 18.0.5-php8.1 18.0.5 18
* 19.0.2-php8.2 19.0.2 19 latest
* develop

**End of support for PHP < 7.4**
Expand Down Expand Up @@ -102,6 +103,9 @@ When setup this way, to upgrade version the use of the web interface is mandator
| **DOLI_ADMIN_LOGIN** | *admin* | Admin's login create on the first boot
| **DOLI_ADMIN_PASSWORD** | *admin* | Admin'password
| **DOLI_URL_ROOT** | *http://localhost* | Url root of the Dolibarr installation
| **DOLI_ENABLE_MODULES** | | Comma-separated list of modules to be activated at install. modUser will always be activated. (Ex: `Societe,Facture,Stock`)
| **DOLI_COMPANY_NAME** | | Set the company name of Dolibarr at container init
| **DOLI_COMPANY_COUNTRYCODE** | | Set the company and Dolibarr country at container init. Need 2-letter codes like "FR", "GB", "US",...
| **PHP_INI_DATE_TIMEZONE** | *UTC* | Default timezone on PHP
| **PHP_INI_MEMORY_LIMIT** | *256M* | PHP Memory limit
| **PHP_INI_UPLOAD_MAX_FILESIZE** | *2M* | PHP Maximum allowed size for uploaded files
Expand Down Expand Up @@ -135,3 +139,40 @@ Environment variables that are compatible with docker secrets:
* `DOLI_CRON_KEY` => `DOLI_CRON_KEY_FILE`
* `DOLI_CRON_USER` => `DOLI_CRON_USER_FILE`
* `DOLI_INSTANCE_UNIQUE_ID` => `DOLI_INSTANCE_UNIQUE_ID_FILE`

## Add post-deployment scripts
It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end of deployment by mounting a volume in `/var/www/scripts/docker-init.d`
```
\docker-init.d
|- custom_script.sql
|- custom_script.php
|- custom_script.sh
```
Mount the volume with compose file :
```yaml
version: "3"
services:
mariadb:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: dolibarr
web:
image: tuxgasy/dolibarr
environment:
DOLI_DB_HOST: mariadb
DOLI_DB_USER: root
DOLI_DB_PASSWORD: root
DOLI_DB_NAME: dolibarr
DOLI_URL_ROOT: 'http://0.0.0.0'
PHP_INI_DATE_TIMEZONE: 'Europe/Paris'
volumes :
- volume-scripts:/var/www/scripts/docker-init.d
ports:
- "80:80"
links:
- mariadb
```
40 changes: 40 additions & 0 deletions README.template
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ When setup this way, to upgrade version the use of the web interface is mandator
| **DOLI_ADMIN_LOGIN** | *admin* | Admin's login create on the first boot
| **DOLI_ADMIN_PASSWORD** | *admin* | Admin'password
| **DOLI_URL_ROOT** | *http://localhost* | Url root of the Dolibarr installation
| **DOLI_ENABLE_MODULES** | | Comma-separated list of modules to be activated at install. modUser will always be activated. (Ex: `Societe,Facture,Stock`)
| **DOLI_COMPANY_NAME** | | Set the company name of Dolibarr at container init
| **DOLI_COMPANY_COUNTRYCODE** | | Set the company and Dolibarr country at container init. Need 2-letter codes like "FR", "GB", "US",...
| **PHP_INI_DATE_TIMEZONE** | *UTC* | Default timezone on PHP
| **PHP_INI_MEMORY_LIMIT** | *256M* | PHP Memory limit
| **PHP_INI_UPLOAD_MAX_FILESIZE** | *2M* | PHP Maximum allowed size for uploaded files
Expand Down Expand Up @@ -130,3 +133,40 @@ Environment variables that are compatible with docker secrets:
* `DOLI_CRON_KEY` => `DOLI_CRON_KEY_FILE`
* `DOLI_CRON_USER` => `DOLI_CRON_USER_FILE`
* `DOLI_INSTANCE_UNIQUE_ID` => `DOLI_INSTANCE_UNIQUE_ID_FILE`

## Add post-deployment scripts
It is possible to execute `*.sh`, `*.sql` and/or `*.php` custom file at the end of deployment by mounting a volume in `/var/www/scripts/docker-init.d`
```
\docker-init.d
|- custom_script.sql
|- custom_script.php
|- custom_script.sh
```

Mount the volume with compose file :
```yaml
version: "3"

services:
mariadb:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: dolibarr

web:
image: tuxgasy/dolibarr
environment:
DOLI_DB_HOST: mariadb
DOLI_DB_USER: root
DOLI_DB_PASSWORD: root
DOLI_DB_NAME: dolibarr
DOLI_URL_ROOT: 'http://0.0.0.0'
PHP_INI_DATE_TIMEZONE: 'Europe/Paris'
volumes :
- volume-scripts:/var/www/scripts/docker-init.d
ports:
- "80:80"
links:
- mariadb
```
46 changes: 43 additions & 3 deletions docker-init.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
#!/usr/bin/env php
<?php
require_once '../htdocs/master.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modUser.class.php';
$mod = new modUser($db);
$mod->init();
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';

printf("Activating module User... ");
activateModule('modUser');
printf("OK\n");

if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
} else {
printf('Unable to find country '.$countryCode."\n");
}
}

if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
}

if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
printf("Activating module ".$mod." ...");
try {
$res = activateModule('mod' . $mod);
if ($res < 0) {
print(" FAILED. Unable to load module. Be sure to check the case\n");
} else {
printf(" OK\n");
}
} catch (Throwable $t) {
print(" FAILED. Unable to load module. Be sure to check the case\n");
}
}
}
23 changes: 23 additions & 0 deletions docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@ function initializeDatabase()

echo "Enable user module ..."
php /var/www/scripts/docker-init.php

if [ -d /var/www/scripts/docker-init.d ] ; then
for file in /var/www/scripts/docker-init.d/*; do
[ ! -f $file ] && continue

# If extension is not in PHP SQL SH, we loop
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
[ -z "$isExec" ] && continue

echo "Importing custom ${isExec} from `basename ${file}` ..."
if [ "$isExec" == "SQL" ] ; then
sed -i 's/--.*//g;' ${file}
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
elif [ "$isExec" == "PHP" ] ; then
php $file
elif [ "$isExec" == "SH" ] ; then
/bin/bash $file
fi
done
fi

# Update ownership after initialisation of modules
chown -R www-data:www-data /var/www/documents
}

function migrateDatabase()
Expand Down
46 changes: 43 additions & 3 deletions images/15.0.3-php7.4/docker-init.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
#!/usr/bin/env php
<?php
require_once '../htdocs/master.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modUser.class.php';
$mod = new modUser($db);
$mod->init();
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';

printf("Activating module User... ");
activateModule('modUser');
printf("OK\n");

if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
} else {
printf('Unable to find country '.$countryCode."\n");
}
}

if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
}

if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
printf("Activating module ".$mod." ...");
try {
$res = activateModule('mod' . $mod);
if ($res < 0) {
print(" FAILED. Unable to load module. Be sure to check the case\n");
} else {
printf(" OK\n");
}
} catch (Throwable $t) {
print(" FAILED. Unable to load module. Be sure to check the case\n");
}
}
}
23 changes: 23 additions & 0 deletions images/15.0.3-php7.4/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@ function initializeDatabase()

echo "Enable user module ..."
php /var/www/scripts/docker-init.php

if [ -d /var/www/scripts/docker-init.d ] ; then
for file in /var/www/scripts/docker-init.d/*; do
[ ! -f $file ] && continue

# If extension is not in PHP SQL SH, we loop
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
[ -z "$isExec" ] && continue

echo "Importing custom ${isExec} from `basename ${file}` ..."
if [ "$isExec" == "SQL" ] ; then
sed -i 's/--.*//g;' ${file}
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
elif [ "$isExec" == "PHP" ] ; then
php $file
elif [ "$isExec" == "SH" ] ; then
/bin/bash $file
fi
done
fi

# Update ownership after initialisation of modules
chown -R www-data:www-data /var/www/documents
}

function migrateDatabase()
Expand Down
46 changes: 43 additions & 3 deletions images/16.0.5-php8.1/docker-init.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
#!/usr/bin/env php
<?php
require_once '../htdocs/master.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/modules/modUser.class.php';
$mod = new modUser($db);
$mod->init();
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';

printf("Activating module User... ");
activateModule('modUser');
printf("OK\n");

if (!empty(getenv('DOLI_COMPANY_COUNTRYCODE'))) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
$countryCode = getenv('DOLI_COMPANY_COUNTRYCODE');
$country = new Ccountry($db);
$res = $country->fetch(0,$countryCode);
if ($res > 0 ) {
$s = $country->id.':'.$country->code.':'.$country->label;
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_COUNTRY", $s, 'chaine', 0, '', $conf->entity);
printf('Configuring for country : '.$s."\n");
activateModulesRequiredByCountry($country->code);
} else {
printf('Unable to find country '.$countryCode."\n");
}
}

if (!empty(getenv('DOLI_COMPANY_NAME'))) {
$compname = getenv('DOLI_COMPANY_NAME');
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", $compname, 'chaine', 0, '', $conf->entity);
}

if (!empty(getenv('DOLI_ENABLE_MODULES'))) {
$mods = explode(',', getenv('DOLI_ENABLE_MODULES'));
foreach ($mods as $mod) {
printf("Activating module ".$mod." ...");
try {
$res = activateModule('mod' . $mod);
if ($res < 0) {
print(" FAILED. Unable to load module. Be sure to check the case\n");
} else {
printf(" OK\n");
}
} catch (Throwable $t) {
print(" FAILED. Unable to load module. Be sure to check the case\n");
}
}
}
23 changes: 23 additions & 0 deletions images/16.0.5-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@ function initializeDatabase()

echo "Enable user module ..."
php /var/www/scripts/docker-init.php

if [ -d /var/www/scripts/docker-init.d ] ; then
for file in /var/www/scripts/docker-init.d/*; do
[ ! -f $file ] && continue

# If extension is not in PHP SQL SH, we loop
isExec=$(echo "PHP SQL SH" | grep -wio ${file##*.})
[ -z "$isExec" ] && continue

echo "Importing custom ${isExec} from `basename ${file}` ..."
if [ "$isExec" == "SQL" ] ; then
sed -i 's/--.*//g;' ${file}
mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${file} > /dev/null 2>&1
elif [ "$isExec" == "PHP" ] ; then
php $file
elif [ "$isExec" == "SH" ] ; then
/bin/bash $file
fi
done
fi

# Update ownership after initialisation of modules
chown -R www-data:www-data /var/www/documents
}

function migrateDatabase()
Expand Down
6 changes: 0 additions & 6 deletions images/17.0.3-php8.1/docker-init.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM ${ARCH}php:8.1-apache-buster

LABEL maintainer="Garcia MICHEL <[email protected]>"

ENV DOLI_VERSION 17.0.3
ENV DOLI_VERSION 17.0.4
ENV DOLI_INSTALL_AUTO 1
ENV DOLI_PROD 1

Expand Down
Loading

0 comments on commit a5ada89

Please sign in to comment.