Skip to content

Commit

Permalink
NEW Make setup of volumes easier - Add option DOLI_INIT_DEMO
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 17, 2024
1 parent 5d6098c commit 3d26e30
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 48 deletions.
29 changes: 5 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
29 changes: 5 additions & 24 deletions README.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions images/15.0.3-php7.4/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions images/16.0.5-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions images/17.0.4-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions images/18.0.5-php8.1/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions images/19.0.2-php8.2/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions images/develop/docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 3d26e30

Please sign in to comment.