diff --git a/README.md b/README.md index 7d87945..468099a 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ services: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: dolibarr volumes: - - mariadb_data:/var/lib/mysql + - /home/mariadb_data:/var/lib/mysql web: image: dolibarr/dolibarr:latest @@ -66,28 +66,8 @@ services: links: - mariadb volumes: - - dolibarr_data:/var/www/documents - - dolibarr_custom:/var/www/html/custom - -volumes: - mariadb_data: - driver: local # Define the driver and options under the volume name - driver_opts: - type: none - device: /home/mariadb_data - o: bind - dolibarr_data: - driver: local # Define the driver and options under the volume name - driver_opts: - type: none - device: /home/dolibarr_data - o: bind - dolibarr_custom: - driver: local # Define the driver and options under the volume name - driver_opts: - type: none - device: /home/dolibarr_custom - o: bind + - /home/dolibarr_data:/var/www/documents + - /home/dolibarr_custom:/var/www/html/custom ``` Then build and run all services (-d is to run in background) @@ -162,7 +142,8 @@ You can use the following variables for a better customization of your docker-co | Variable | Default value | Description | | ------------------------------- | ------------------------------ | ----------- | -| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be executed on first boot +| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be done during docker first boot +| **DOLI_INIT_DEMO** | *0* | 1: The installation will also load demo data during docker first boot | **DOLI_PROD** | *1* | 1: Dolibarr will be run in production mode | **DOLI_DB_TYPE** | *mysqli* | Type of the DB server (**mysqli**, pgsql) | **DOLI_DB_HOST** | *mysql* | Host name of the MariaDB/MySQL server diff --git a/README.template b/README.template index d58a66a..1241966 100644 --- a/README.template +++ b/README.template @@ -42,7 +42,7 @@ services: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: dolibarr volumes: - - mariadb_data:/var/lib/mysql + - /home/mariadb_data:/var/lib/mysql web: image: dolibarr/dolibarr:latest @@ -60,28 +60,8 @@ services: links: - mariadb volumes: - - dolibarr_data:/var/www/documents - - dolibarr_custom:/var/www/html/custom - -volumes: - mariadb_data: - driver: local # Define the driver and options under the volume name - driver_opts: - type: none - device: /home/mariadb_data - o: bind - dolibarr_data: - driver: local # Define the driver and options under the volume name - driver_opts: - type: none - device: /home/dolibarr_data - o: bind - dolibarr_custom: - driver: local # Define the driver and options under the volume name - driver_opts: - type: none - device: /home/dolibarr_custom - o: bind + - /home/dolibarr_data:/var/www/documents + - /home/dolibarr_custom:/var/www/html/custom ``` Then build and run all services (-d is to run in background) @@ -155,7 +135,8 @@ You can use the following variables for a better customization of your docker-co | Variable | Default value | Description | | ------------------------------- | ------------------------------ | ----------- | -| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be executed on first boot +| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be done during docker first boot +| **DOLI_INIT_DEMO** | *0* | 1: The installation will also load demo data during docker first boot | **DOLI_PROD** | *1* | 1: Dolibarr will be run in production mode | **DOLI_DB_TYPE** | *mysqli* | Type of the DB server (**mysqli**, pgsql) | **DOLI_DB_HOST** | *mysql* | Host name of the MariaDB/MySQL server diff --git a/docker-run.sh b/docker-run.sh index ec09ac0..0a60ff6 100755 --- a/docker-run.sh +++ b/docker-run.sh @@ -196,6 +196,17 @@ function initializeDatabase() mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('MAIN_LANG_DEFAULT', 'auto', 'chaine', 0, 'Default language', 1);" > /dev/null 2>&1 mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('SYSTEMTOOLS_MYSQLDUMP', '/usr/bin/mysqldump', 'chaine', 0, '', 0);" > /dev/null 2>&1 + if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then + for fileSQL in /var/www/dev/initdemo/*.sql; do + # We exclude the old load file. + if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then + continue + fi + echo "Load demo data ${fileSQL} ..." + mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${fileSQL} > /dev/null 2>&1 + done + fi + echo "Enable user module ..." php /var/www/scripts/docker-init.php @@ -245,6 +256,7 @@ function run() initDolibarr echo "Current Version is : ${DOLI_VERSION}" + # If install of mysql database (and not install of cron) is requested if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then waitForDataBase diff --git a/images/15.0.3-php7.4/docker-run.sh b/images/15.0.3-php7.4/docker-run.sh index ec09ac0..cc8977a 100755 --- a/images/15.0.3-php7.4/docker-run.sh +++ b/images/15.0.3-php7.4/docker-run.sh @@ -196,6 +196,18 @@ function initializeDatabase() mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('MAIN_LANG_DEFAULT', 'auto', 'chaine', 0, 'Default language', 1);" > /dev/null 2>&1 mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('SYSTEMTOOLS_MYSQLDUMP', '/usr/bin/mysqldump', 'chaine', 0, '', 0);" > /dev/null 2>&1 + if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then + for fileSQL in /var/www/dev/initdemo/*.sql; do + # We exclude the old load file. + if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then + continue + fi + echo "Load demo data ${fileSQL} ..." + sed -i 's/--.*//g;' ${fileSQL} + mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${fileSQL} > /dev/null 2>&1 + done + fi + echo "Enable user module ..." php /var/www/scripts/docker-init.php @@ -245,6 +257,7 @@ function run() initDolibarr echo "Current Version is : ${DOLI_VERSION}" + # If install of mysql database (and not install of cron) is requested if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then waitForDataBase diff --git a/images/16.0.5-php8.1/docker-run.sh b/images/16.0.5-php8.1/docker-run.sh index ec09ac0..cc8977a 100755 --- a/images/16.0.5-php8.1/docker-run.sh +++ b/images/16.0.5-php8.1/docker-run.sh @@ -196,6 +196,18 @@ function initializeDatabase() mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('MAIN_LANG_DEFAULT', 'auto', 'chaine', 0, 'Default language', 1);" > /dev/null 2>&1 mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('SYSTEMTOOLS_MYSQLDUMP', '/usr/bin/mysqldump', 'chaine', 0, '', 0);" > /dev/null 2>&1 + if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then + for fileSQL in /var/www/dev/initdemo/*.sql; do + # We exclude the old load file. + if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then + continue + fi + echo "Load demo data ${fileSQL} ..." + sed -i 's/--.*//g;' ${fileSQL} + mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${fileSQL} > /dev/null 2>&1 + done + fi + echo "Enable user module ..." php /var/www/scripts/docker-init.php @@ -245,6 +257,7 @@ function run() initDolibarr echo "Current Version is : ${DOLI_VERSION}" + # If install of mysql database (and not install of cron) is requested if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then waitForDataBase diff --git a/images/17.0.4-php8.1/docker-run.sh b/images/17.0.4-php8.1/docker-run.sh index ec09ac0..cc8977a 100755 --- a/images/17.0.4-php8.1/docker-run.sh +++ b/images/17.0.4-php8.1/docker-run.sh @@ -196,6 +196,18 @@ function initializeDatabase() mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('MAIN_LANG_DEFAULT', 'auto', 'chaine', 0, 'Default language', 1);" > /dev/null 2>&1 mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('SYSTEMTOOLS_MYSQLDUMP', '/usr/bin/mysqldump', 'chaine', 0, '', 0);" > /dev/null 2>&1 + if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then + for fileSQL in /var/www/dev/initdemo/*.sql; do + # We exclude the old load file. + if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then + continue + fi + echo "Load demo data ${fileSQL} ..." + sed -i 's/--.*//g;' ${fileSQL} + mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${fileSQL} > /dev/null 2>&1 + done + fi + echo "Enable user module ..." php /var/www/scripts/docker-init.php @@ -245,6 +257,7 @@ function run() initDolibarr echo "Current Version is : ${DOLI_VERSION}" + # If install of mysql database (and not install of cron) is requested if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then waitForDataBase diff --git a/images/18.0.5-php8.1/docker-run.sh b/images/18.0.5-php8.1/docker-run.sh index ec09ac0..cc8977a 100755 --- a/images/18.0.5-php8.1/docker-run.sh +++ b/images/18.0.5-php8.1/docker-run.sh @@ -196,6 +196,18 @@ function initializeDatabase() mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('MAIN_LANG_DEFAULT', 'auto', 'chaine', 0, 'Default language', 1);" > /dev/null 2>&1 mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('SYSTEMTOOLS_MYSQLDUMP', '/usr/bin/mysqldump', 'chaine', 0, '', 0);" > /dev/null 2>&1 + if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then + for fileSQL in /var/www/dev/initdemo/*.sql; do + # We exclude the old load file. + if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then + continue + fi + echo "Load demo data ${fileSQL} ..." + sed -i 's/--.*//g;' ${fileSQL} + mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${fileSQL} > /dev/null 2>&1 + done + fi + echo "Enable user module ..." php /var/www/scripts/docker-init.php @@ -245,6 +257,7 @@ function run() initDolibarr echo "Current Version is : ${DOLI_VERSION}" + # If install of mysql database (and not install of cron) is requested if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then waitForDataBase diff --git a/images/19.0.2-php8.2/docker-run.sh b/images/19.0.2-php8.2/docker-run.sh index ec09ac0..cc8977a 100755 --- a/images/19.0.2-php8.2/docker-run.sh +++ b/images/19.0.2-php8.2/docker-run.sh @@ -196,6 +196,18 @@ function initializeDatabase() mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('MAIN_LANG_DEFAULT', 'auto', 'chaine', 0, 'Default language', 1);" > /dev/null 2>&1 mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('SYSTEMTOOLS_MYSQLDUMP', '/usr/bin/mysqldump', 'chaine', 0, '', 0);" > /dev/null 2>&1 + if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then + for fileSQL in /var/www/dev/initdemo/*.sql; do + # We exclude the old load file. + if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then + continue + fi + echo "Load demo data ${fileSQL} ..." + sed -i 's/--.*//g;' ${fileSQL} + mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${fileSQL} > /dev/null 2>&1 + done + fi + echo "Enable user module ..." php /var/www/scripts/docker-init.php @@ -245,6 +257,7 @@ function run() initDolibarr echo "Current Version is : ${DOLI_VERSION}" + # If install of mysql database (and not install of cron) is requested if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then waitForDataBase diff --git a/images/develop/docker-run.sh b/images/develop/docker-run.sh index ec09ac0..cc8977a 100755 --- a/images/develop/docker-run.sh +++ b/images/develop/docker-run.sh @@ -196,6 +196,18 @@ function initializeDatabase() mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('MAIN_LANG_DEFAULT', 'auto', 'chaine', 0, 'Default language', 1);" > /dev/null 2>&1 mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} -e "INSERT INTO llx_const(name,value,type,visible,note,entity) VALUES ('SYSTEMTOOLS_MYSQLDUMP', '/usr/bin/mysqldump', 'chaine', 0, '', 0);" > /dev/null 2>&1 + if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then + for fileSQL in /var/www/dev/initdemo/*.sql; do + # We exclude the old load file. + if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then + continue + fi + echo "Load demo data ${fileSQL} ..." + sed -i 's/--.*//g;' ${fileSQL} + mysql -u ${DOLI_DB_USER} -p${DOLI_DB_PASSWORD} -h ${DOLI_DB_HOST} -P ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME} < ${fileSQL} > /dev/null 2>&1 + done + fi + echo "Enable user module ..." php /var/www/scripts/docker-init.php @@ -245,6 +257,7 @@ function run() initDolibarr echo "Current Version is : ${DOLI_VERSION}" + # If install of mysql database (and not install of cron) is requested if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then waitForDataBase