FIX Several trouble with demo docker packages. More secured way to use

the force_password in setup process.
This commit is contained in:
Laurent Destailleur 2026-03-07 14:52:53 +01:00
parent f4109abe56
commit 6b9d5a59d9
11 changed files with 122 additions and 124 deletions

View file

@ -3,19 +3,30 @@
# See README.md to know how to create a Dolibarr env with docker
set -ex
if [ "${PHP_INI_DIR}" == "" ]; then
echo
echo This script must not be run directly. It is used by the Dockerfile
echo See README.md
echo
exit
fi
if [ "${HOST_USER_ID}" == "" ]; then
echo "Define HOST_USER_ID to your user ID before starting"
echo "Define HOST_USER_ID to your user ID before starting (example: www-data)"
exit 1
fi
if [ "${HOST_GROUP_ID}" == "" ]; then
echo "Define HOST_GROUP_ID to your group ID before starting (example: www-data)"
exit 1
fi
usermod -u "${HOST_USER_ID}" www-data
groupmod -g "${HOST_USER_ID}" www-data
groupmod -g "${HOST_GROUP_ID}" www-data
echo "[docker-run] => update '${PHP_INI_DIR}/conf.d/dolibarr-php.ini'"
cat <<EOF > "${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

View file

@ -1,24 +1,51 @@
# How to use or run Dolibarr with Docker ?
# How to build and run your local version of Dolibarr, quickly with Docker ?
## For a fast run of a demo of the local version, you can build the docker image from the source repository by running
## For a fast run of a demo of the local version, you can build a docker image pointing to your source repository
This process using the Dockerfile and docker-compose.yml file is a config file to use to build and run Dolibarr in the
current workspace with Docker. This docker image is intended for **development usage** (See next chapter for a production usage).
Warning: There is no persistency of database. This process is for dev purpose only.
Build the containers:
git clone https://github.com/Dolibarr/dolibarr.git dolibarr
cd dolibarr/docker
cd dolibarr/dev/build/docker
sudo docker-compose build
sudo docker-compose build [--no-cache]
or
sudo docker compose build [--no-cache]
Launch the containers:
sudo -s
export HOST_USER_ID=$(id -u)
export HOST_GROUP_ID=$(id -g)
export MYSQL_ROOT_PWD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13; echo)
docker-compose up -d
or
docker compose up -d
Check that server process is on:
docker compose ps
Warning: There is no persistency of data. This process is for dev purpose only.
Check also logs of starting container:
docker logs dolibarr-web-dev
The URL to go to the installed Dolibarr is :
http://0.0.0.0:8080
To delete processes:
docker compose kill stop
## For a more robust or a production usage

View file

@ -1,28 +1,27 @@
version: "3"
services:
mariadb-prod:
container_name: dolibarr-mariadb-prod
mariadb-dev:
container_name: dolibarr-mariadb-dev
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PWD
MYSQL_DATABASE: "dolibarr-prod"
MARIADB_ROOT_PASSWORD: $MYSQL_ROOT_PWD
MARIADB_DATABASE: "dolibarr-dev"
web:
container_name: dolibarr-web-prod
container_name: dolibarr-web-dev
build: .
volumes:
- ../../htdocs:/var/www/html/
- ../../documents:/var/www/html/documents
- ../../../htdocs:/var/www/html/
- ../../../documents:/var/www/documents
depends_on:
- mariadb-prod
- mariadb-dev
environment:
HOST_USER_ID: $HOST_USER_ID
HOST_GROUP_ID: $HOST_GROUP_ID
DOLI_ROOT_PASSWORD: $MYSQL_ROOT_PWD
DOLI_DATABASE: "dolibarr-prod"
DOLI_DB_SERVER: "mariadb-prod"
DOLI_DATABASE: "dolibarr-dev"
DOLI_DB_SERVER: "mariadb-dev"
DOLI_DB_USER: "root"
DOLI_DB_PASSWORD: $MYSQL_ROOT_PWD
ports:
- "8080:80"

View file

@ -10,6 +10,16 @@ if [ "${PHP_INI_DIR}" == "" ]; then
exit
fi
if [ "${HOST_USER_ID}" == "" ]; then
echo "Define HOST_USER_ID to your user ID before starting (example: www-data)"
exit 1
fi
if [ "${HOST_GROUP_ID}" == "" ]; then
echo "Define HOST_GROUP_ID to your group ID before starting (example: www-data)"
exit 1
fi
usermod -u "${HOST_USER_ID}" www-data
groupmod -g "${HOST_GROUP_ID}" www-data
@ -29,6 +39,7 @@ date.timezone = ${PHP_INI_DATE_TIMEZONE:-UTC}
memory_limit = ${PHP_INI_MEMORY_LIMIT:-256M}
EOF
cp /var/www/html/install/install.forced.docker.php /var/www/html/install/install.forced.php
echo cp /var/www/html/install/install.forced.sample.php /var/www/html/install/install.forced.php
cp /var/www/html/install/install.forced.sample.php /var/www/html/install/install.forced.php
exec apache2-foreground

View file

@ -89,6 +89,9 @@ dolibarr_install_syslog("- fileconf: entering fileconf.php page");
// install.forced.php into directory htdocs/install (This is the case with some wizard
// installer like DoliWamp, DoliMamp or DoliBuntu).
// We first init "forced values" to nothing.
if (!isset($force_install_distrib)) {
$force_install_distrib = 'undefined';
}
if (!isset($force_install_noedit)) {
$force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters, 3 to block all technical parameters excepted main_url
}
@ -152,6 +155,10 @@ if (!is_writable($conffile)) {
exit;
}
if (!empty($force_install_distrib)) {
print '<!-- $force_install_distrib = '.dol_escape_htmltag($force_install_distrib).' -->';
}
if (!empty($force_install_message)) {
print '<div><br>'.$langs->trans($force_install_message).'</div>';

View file

@ -1,78 +0,0 @@
<?php
/* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2024 Yann Le Doaré <services@linuxconsole.org>
* Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** @var boolean $force_install_nophpinfo Hide PHP information */
$force_install_nophpinfo = true;
/** @var int $force_install_noedit 1 = Lock and hide environment variables, 2 = Lock all set variables */
$force_install_noedit = 3;
/** @var string $force_install_message Information message */
$force_install_message = 'Welcome to your Dolibarr Docker install';
/** @var string $force_install_main_data_root Data root absolute path (documents folder) */
$force_install_main_data_root = null;
/** @var boolean $force_install_mainforcehttps Force HTTPS */
$force_install_mainforcehttps = true;
/** @var string $force_install_database Database name */
$force_install_database = getenv('DOLI_DATABASE', true) ?: getenv('DOLI_DATABASE');
/** @var string $force_install_type Database driver (mysql|mysqli|pgsql|mssql|sqlite|sqlite3) */
$force_install_type = 'mysqli';
/** @var string $force_install_dbserver Database server host */
$force_install_dbserver = getenv('DOLI_DB_SERVER', true) ?: getenv('DOLI_DB_SERVER');
/** @var int $force_install_port Database server port */
$force_install_port = 3306;
/** @var string $force_install_prefix Database tables prefix */
$force_install_prefix = 'llx_';
/** @var bool $force_install_createdatabase Force database creation */
$force_install_createdatabase = false;
/** @var string $force_install_databaselogin Database username */
$force_install_databaselogin = 'root';
/** @var string $force_install_databasepass Database password */
$force_install_databasepass = getenv('DOLI_ROOT_PASSWORD', true) ?: getenv('DOLI_ROOT_PASSWORD');
/** @var bool $force_install_createuser Force database user creation */
$force_install_createuser = false;
/** @var string $force_install_databaserootlogin Database root username */
$force_install_databaserootlogin = 'root';
/** @var string $force_install_databaserootpass Database root password */
$force_install_databaserootpass = getenv('DOLI_ROOT_PASSWORD', true) ?: getenv('DOLI_ROOT_PASSWORD');
/** @var string $force_install_dolibarrlogin Dolibarr super-administrator username */
$force_install_dolibarrlogin = 'admin';
/** @var string $force_install_dolibarrpassword Dolibarr super-administrator password */
$force_install_dolibarrpassword = '';
/** @var bool $force_install_lockinstall Force install locking */
$force_install_lockinstall = true;
/** @var string $force_install_module Enable module(s) (Comma separated class names list) */
$force_install_module = '';

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2024 Yann Le Doaré <services@linuxconsole.org>
* Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
*
* This program is free software; you can redistribute it and/or modify
@ -16,14 +17,17 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** @var boolean $force_install_distrib Set the way the installis done to "custom" value */
$force_install_distrib = 'custom';
/** @var boolean $force_install_nophpinfo Hide PHP information */
$force_install_nophpinfo = true;
/** @var int $force_install_noedit 1 = Lock and hide environment variables, 2 = Lock all set variables */
$force_install_noedit = 2;
/** @var string $force_install_message Information message */
$force_install_message = 'Welcome to your Dolibarr install';
/** @var string $force_install_message Information message to add on the page to setup parameters */
$force_install_message = 'Welcome to your Dolibarr install...';
/** @var string $force_install_main_data_root Data root absolute path (documents folder) */
$force_install_main_data_root = null;
@ -32,13 +36,13 @@ $force_install_main_data_root = null;
$force_install_mainforcehttps = true;
/** @var string $force_install_database Database name */
$force_install_database = 'dolibarr';
$force_install_database = getenv('DOLI_DATABASE', true) ?: 'dolibarr';
/** @var string $force_install_type Database driver (mysql|mysqli|pgsql|mssql|sqlite|sqlite3) */
$force_install_type = 'mysqli';
/** @var string $force_install_dbserver Database server host */
$force_install_dbserver = 'localhost';
$force_install_dbserver = getenv('DOLI_DB_SERVER', true) ?: 'localhost';
/** @var int $force_install_port Database server port */
$force_install_port = 3306;
@ -47,31 +51,31 @@ $force_install_port = 3306;
$force_install_prefix = 'llx_';
/** @var bool $force_install_createdatabase Force database creation */
$force_install_createdatabase = true;
$force_install_createdatabase = getenv('DOLI_DB_CREATE', true) ? true : false;
/** @var string $force_install_databaselogin Database username */
$force_install_databaselogin = 'root';
/** @var string $force_install_databasepass Database password */
$force_install_databasepass = '';
$force_install_databasepass = getenv('DOLI_DB_PASSWORD', true) ?: '';
/** @var bool $force_install_createuser Force database user creation */
$force_install_createuser = false;
/** @var string $force_install_dolibarrlogin Dolibarr administrator username */
$force_install_dolibarrlogin = 'admin';
/** @var string $force_install_dolibarrpassword Dolibarr administrator password */
$force_install_dolibarrpassword = '';
/** @var string $force_install_databaserootlogin Database root username */
$force_install_databaserootlogin = 'root';
/** @var string $force_install_databaserootpass Database root password */
$force_install_databaserootpass = '';
/** @var string $force_install_dolibarrlogin Dolibarr super-administrator username */
$force_install_dolibarrlogin = 'admin';
/** @var string $force_install_dolibarrpassword Dolibarr super-administrator password */
$force_install_dolibarrpassword = '';
$force_install_databaserootpass = getenv('DOLI_ROOT_PASSWORD', true) ?: '';
/** @var bool $force_install_lockinstall Force install locking */
$force_install_lockinstall = true;
/** @var string $force_install_module Enable module(s) (Comma separated class names list) */
$force_install_module = 'modSociete,modFournisseur,modFacture';
/** @var string $force_install_module Enable module(s) (Comma separated class names list, example: modSociete,modFournisseur,modFacture) */
$force_install_module = '';

View file

@ -612,7 +612,8 @@ $conf->file->instance_unique_id = (empty($dolibarr_main_instance_unique_id) ? (e
$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only.
$out = '<input type="checkbox" name="dolibarrpingno" id="dolibarrpingno"'.((getDolGlobalString('MAIN_FIRST_PING_OK_ID') == 'disabled') ? '' : ' value="checked" checked="true"').'> ';
$out = '<br>';
$out .= '<input type="checkbox" name="dolibarrpingno" id="dolibarrpingno"'.((getDolGlobalString('MAIN_FIRST_PING_OK_ID') == 'disabled') ? '' : ' value="checked" checked="true"').'> ';
$out .= '<label for="dolibarrpingno">'.$langs->trans("MakeAnonymousPing").'</label>';
$out .= '<!-- Add js script to manage the uncheck of option to not send the ping -->';

View file

@ -28,7 +28,6 @@
include_once 'inc.php';
/**
* @var string $conffile
* @var string $conffiletoshow
@ -37,6 +36,9 @@ include_once 'inc.php';
* @var Translate $langs
*
* @var string $dolibarr_main_document_root
* @var int $force_install_noedit
* @var string $force_install_dolibarrlogin
* @var string $force_install_dolibarrpassword
*/
require_once $dolibarr_main_document_root.'/core/class/conf.class.php';
@ -56,7 +58,7 @@ if ($conffile == "/etc/dolibarr/conf.php") {
$forcedfile = "/etc/dolibarr/install.forced.php";
}
if (@file_exists($forcedfile)) {
$useforcedwizard = true;
$useforcedwizard = true; // used into install.forced.php
include_once $forcedfile;
}
@ -90,13 +92,14 @@ print '<table cellspacing="0" cellpadding="2">';
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
if ($db->ok) {
print '<tr><td><label for="login">'.$langs->trans("Login").' :</label></td><td>';
print '<input id="login" name="login" type="text" value="'.(GETPOSTISSET("login") ? GETPOST("login", 'alpha') : (isset($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')).'"'.(@$force_install_noedit == 2 && $force_install_dolibarrlogin !== null ? ' disabled' : '').' spellcheck="false" autofocus></td></tr>';
print '<input id="login" name="login" type="text" value="'.(GETPOSTISSET("login") ? GETPOST("login", 'alpha') : (!empty($force_install_dolibarrlogin) ? $force_install_dolibarrlogin : '')).'"'.(@$force_install_noedit == 2 && !empty($force_install_dolibarrlogin) ? ' disabled' : '').' spellcheck="false" autofocus></td></tr>';
print '<tr><td><label for="pass">'.$langs->trans("Password").' :</label></td><td>';
print '<input type="password" id="pass" name="pass" autocomplete="new-password" minlength="8" value="'. (isset($force_install_dolibarrpassword) ? $force_install_dolibarrpassword : '').'"'.(@$force_install_noedit == 2 && $force_install_dolibarrpassword !== null ? ' disabled' : '').'></td></tr>';
print '<input type="password" id="pass" name="pass" autocomplete="new-password" minlength="8" value="'. (!empty($force_install_dolibarrpassword) ? '**********' : '').'"'.(@$force_install_noedit == 2 && !empty($force_install_dolibarrpassword) ? ' disabled' : '').'></td></tr>';
print '<tr><td><label for="pass_verif">'.$langs->trans("PasswordRetype").' :</label></td><td>';
print '<input type="password" id="pass_verif" name="pass_verif" autocomplete="new-password" minlength="8" value="'.(isset($force_install_dolibarrpassword) ? $force_install_dolibarrpassword : '').'"'.(@$force_install_noedit == 2 && $force_install_dolibarrpassword !== null ? ' disabled' : '').'></td></tr>';
print '<input type="password" id="pass_verif" name="pass_verif" autocomplete="new-password" minlength="8" value="'.(!empty($force_install_dolibarrpassword) ? '**********' : '').'"'.(@$force_install_noedit == 2 && !empty($force_install_dolibarrpassword) ? ' disabled' : '').'></td></tr>';
print '</table>';
if (GETPOSTINT("error") == 1) {

View file

@ -39,7 +39,6 @@
define('ALLOWED_IF_UPGRADE_UNLOCK_FOUND', 1);
include_once 'inc.php';
/**
* @var string $conffile
* @var string $conffiletoshow
@ -64,6 +63,8 @@ if (file_exists($conffile)) {
* @var string $dolibarr_main_db_cryptkey
* @var string $dolibarr_main_url_root
* @var string $modulesdir
* @var int $force_install_noedit
* @var string $force_install_dolibarrpassword
*/
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
require_once $dolibarr_main_document_root.'/core/lib/security.lib.php'; // for dol_hash
@ -144,6 +145,14 @@ if (@file_exists($forcedfile)) {
$force_install_lockinstall = (int) (!empty($force_install_lockinstall) ? $force_install_lockinstall : (GETPOST('installlock', 'aZ09') ? GETPOST('installlock', 'aZ09') : (empty($argv[8]) ? '' : $argv[8])));
// Case the password was in forced mode
if (@$force_install_noedit == 2 && isset($force_install_dolibarrpassword)) {
$pass = $force_install_dolibarrpassword;
$pass_verif = $force_install_dolibarrpassword;
}
dolibarr_install_syslog("--- step5: entering step5.php page ".$versionfrom." ".$versionto);
$error = 0;
@ -169,6 +178,10 @@ if ($action == "set") { // Test on permissions not required here
header("Location: step4.php?error=3&selectlang=$setuplang".(isset($login) ? '&login='.$login : ''));
exit;
}
if ($pass === '**********' || $pass_verif == '**********') {
header("Location: step4.php?error=2&selectlang=$setuplang".(isset($login) ? '&login='.$login : ''));
exit;
}
}

View file

@ -381,7 +381,7 @@ ErrorFailedToGetTokenFromClientIdAndSecret=Failed to get a %s token from client
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.
WarningMandatorySetupNotComplete=Click here to setup main parameters
WarningMandatorySetupNotComplete=Setup is not complete ! Click here to setup main parameters
WarningEnableYourModulesApplications=Click here to enable your modules and applications
WarningSafeModeOnCheckExecDir=Warning, PHP option <b>safe_mode</b> is on so command must be stored inside a directory declared by php parameter <b>safe_mode_exec_dir</b>.
WarningBookmarkAlreadyExists=A bookmark with this title or this target (URL) already exists.