Skip to content

Commit 3d26e30

Browse files
committed
NEW Make setup of volumes easier - Add option DOLI_INIT_DEMO
1 parent 5d6098c commit 3d26e30

File tree

9 files changed

+100
-48
lines changed

9 files changed

+100
-48
lines changed

README.md

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ services:
4848
MYSQL_ROOT_PASSWORD: root
4949
MYSQL_DATABASE: dolibarr
5050
volumes:
51-
- mariadb_data:/var/lib/mysql
51+
- /home/mariadb_data:/var/lib/mysql
5252

5353
web:
5454
image: dolibarr/dolibarr:latest
@@ -66,28 +66,8 @@ services:
6666
links:
6767
- mariadb
6868
volumes:
69-
- dolibarr_data:/var/www/documents
70-
- dolibarr_custom:/var/www/html/custom
71-
72-
volumes:
73-
mariadb_data:
74-
driver: local # Define the driver and options under the volume name
75-
driver_opts:
76-
type: none
77-
device: /home/mariadb_data
78-
o: bind
79-
dolibarr_data:
80-
driver: local # Define the driver and options under the volume name
81-
driver_opts:
82-
type: none
83-
device: /home/dolibarr_data
84-
o: bind
85-
dolibarr_custom:
86-
driver: local # Define the driver and options under the volume name
87-
driver_opts:
88-
type: none
89-
device: /home/dolibarr_custom
90-
o: bind
69+
- /home/dolibarr_data:/var/www/documents
70+
- /home/dolibarr_custom:/var/www/html/custom
9171
```
9272
9373
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
162142

163143
| Variable | Default value | Description |
164144
| ------------------------------- | ------------------------------ | ----------- |
165-
| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be executed on first boot
145+
| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be done during docker first boot
146+
| **DOLI_INIT_DEMO** | *0* | 1: The installation will also load demo data during docker first boot
166147
| **DOLI_PROD** | *1* | 1: Dolibarr will be run in production mode
167148
| **DOLI_DB_TYPE** | *mysqli* | Type of the DB server (**mysqli**, pgsql)
168149
| **DOLI_DB_HOST** | *mysql* | Host name of the MariaDB/MySQL server

README.template

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ services:
4242
MYSQL_ROOT_PASSWORD: root
4343
MYSQL_DATABASE: dolibarr
4444
volumes:
45-
- mariadb_data:/var/lib/mysql
45+
- /home/mariadb_data:/var/lib/mysql
4646

4747
web:
4848
image: dolibarr/dolibarr:latest
@@ -60,28 +60,8 @@ services:
6060
links:
6161
- mariadb
6262
volumes:
63-
- dolibarr_data:/var/www/documents
64-
- dolibarr_custom:/var/www/html/custom
65-
66-
volumes:
67-
mariadb_data:
68-
driver: local # Define the driver and options under the volume name
69-
driver_opts:
70-
type: none
71-
device: /home/mariadb_data
72-
o: bind
73-
dolibarr_data:
74-
driver: local # Define the driver and options under the volume name
75-
driver_opts:
76-
type: none
77-
device: /home/dolibarr_data
78-
o: bind
79-
dolibarr_custom:
80-
driver: local # Define the driver and options under the volume name
81-
driver_opts:
82-
type: none
83-
device: /home/dolibarr_custom
84-
o: bind
63+
- /home/dolibarr_data:/var/www/documents
64+
- /home/dolibarr_custom:/var/www/html/custom
8565
```
8666

8767
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
155135

156136
| Variable | Default value | Description |
157137
| ------------------------------- | ------------------------------ | ----------- |
158-
| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be executed on first boot
138+
| **DOLI_INSTALL_AUTO** | *1* | 1: The installation will be done during docker first boot
139+
| **DOLI_INIT_DEMO** | *0* | 1: The installation will also load demo data during docker first boot
159140
| **DOLI_PROD** | *1* | 1: Dolibarr will be run in production mode
160141
| **DOLI_DB_TYPE** | *mysqli* | Type of the DB server (**mysqli**, pgsql)
161142
| **DOLI_DB_HOST** | *mysql* | Host name of the MariaDB/MySQL server

docker-run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,17 @@ function initializeDatabase()
196196
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
197197
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
198198

199+
if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then
200+
for fileSQL in /var/www/dev/initdemo/*.sql; do
201+
# We exclude the old load file.
202+
if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then
203+
continue
204+
fi
205+
echo "Load demo data ${fileSQL} ..."
206+
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
207+
done
208+
fi
209+
199210
echo "Enable user module ..."
200211
php /var/www/scripts/docker-init.php
201212

@@ -245,6 +256,7 @@ function run()
245256
initDolibarr
246257
echo "Current Version is : ${DOLI_VERSION}"
247258

259+
# If install of mysql database (and not install of cron) is requested
248260
if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
249261
waitForDataBase
250262

images/15.0.3-php7.4/docker-run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ function initializeDatabase()
196196
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
197197
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
198198

199+
if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then
200+
for fileSQL in /var/www/dev/initdemo/*.sql; do
201+
# We exclude the old load file.
202+
if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then
203+
continue
204+
fi
205+
echo "Load demo data ${fileSQL} ..."
206+
sed -i 's/--.*//g;' ${fileSQL}
207+
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
208+
done
209+
fi
210+
199211
echo "Enable user module ..."
200212
php /var/www/scripts/docker-init.php
201213

@@ -245,6 +257,7 @@ function run()
245257
initDolibarr
246258
echo "Current Version is : ${DOLI_VERSION}"
247259

260+
# If install of mysql database (and not install of cron) is requested
248261
if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
249262
waitForDataBase
250263

images/16.0.5-php8.1/docker-run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ function initializeDatabase()
196196
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
197197
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
198198

199+
if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then
200+
for fileSQL in /var/www/dev/initdemo/*.sql; do
201+
# We exclude the old load file.
202+
if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then
203+
continue
204+
fi
205+
echo "Load demo data ${fileSQL} ..."
206+
sed -i 's/--.*//g;' ${fileSQL}
207+
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
208+
done
209+
fi
210+
199211
echo "Enable user module ..."
200212
php /var/www/scripts/docker-init.php
201213

@@ -245,6 +257,7 @@ function run()
245257
initDolibarr
246258
echo "Current Version is : ${DOLI_VERSION}"
247259

260+
# If install of mysql database (and not install of cron) is requested
248261
if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
249262
waitForDataBase
250263

images/17.0.4-php8.1/docker-run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ function initializeDatabase()
196196
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
197197
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
198198

199+
if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then
200+
for fileSQL in /var/www/dev/initdemo/*.sql; do
201+
# We exclude the old load file.
202+
if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then
203+
continue
204+
fi
205+
echo "Load demo data ${fileSQL} ..."
206+
sed -i 's/--.*//g;' ${fileSQL}
207+
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
208+
done
209+
fi
210+
199211
echo "Enable user module ..."
200212
php /var/www/scripts/docker-init.php
201213

@@ -245,6 +257,7 @@ function run()
245257
initDolibarr
246258
echo "Current Version is : ${DOLI_VERSION}"
247259

260+
# If install of mysql database (and not install of cron) is requested
248261
if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
249262
waitForDataBase
250263

images/18.0.5-php8.1/docker-run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ function initializeDatabase()
196196
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
197197
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
198198

199+
if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then
200+
for fileSQL in /var/www/dev/initdemo/*.sql; do
201+
# We exclude the old load file.
202+
if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then
203+
continue
204+
fi
205+
echo "Load demo data ${fileSQL} ..."
206+
sed -i 's/--.*//g;' ${fileSQL}
207+
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
208+
done
209+
fi
210+
199211
echo "Enable user module ..."
200212
php /var/www/scripts/docker-init.php
201213

@@ -245,6 +257,7 @@ function run()
245257
initDolibarr
246258
echo "Current Version is : ${DOLI_VERSION}"
247259

260+
# If install of mysql database (and not install of cron) is requested
248261
if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
249262
waitForDataBase
250263

images/19.0.2-php8.2/docker-run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ function initializeDatabase()
196196
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
197197
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
198198

199+
if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then
200+
for fileSQL in /var/www/dev/initdemo/*.sql; do
201+
# We exclude the old load file.
202+
if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then
203+
continue
204+
fi
205+
echo "Load demo data ${fileSQL} ..."
206+
sed -i 's/--.*//g;' ${fileSQL}
207+
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
208+
done
209+
fi
210+
199211
echo "Enable user module ..."
200212
php /var/www/scripts/docker-init.php
201213

@@ -245,6 +257,7 @@ function run()
245257
initDolibarr
246258
echo "Current Version is : ${DOLI_VERSION}"
247259

260+
# If install of mysql database (and not install of cron) is requested
248261
if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
249262
waitForDataBase
250263

images/develop/docker-run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ function initializeDatabase()
196196
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
197197
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
198198

199+
if [[ ${DOLI_INIT_DEMO} -eq 1 ]]; then
200+
for fileSQL in /var/www/dev/initdemo/*.sql; do
201+
# We exclude the old load file.
202+
if [[ $fileSQL =~ mysqldump_dolibarr_3.5 ]]; then
203+
continue
204+
fi
205+
echo "Load demo data ${fileSQL} ..."
206+
sed -i 's/--.*//g;' ${fileSQL}
207+
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
208+
done
209+
fi
210+
199211
echo "Enable user module ..."
200212
php /var/www/scripts/docker-init.php
201213

@@ -245,6 +257,7 @@ function run()
245257
initDolibarr
246258
echo "Current Version is : ${DOLI_VERSION}"
247259

260+
# If install of mysql database (and not install of cron) is requested
248261
if [[ ${DOLI_INSTALL_AUTO} -eq 1 && ${DOLI_CRON} -ne 1 && ! -f /var/www/documents/install.lock && ${DOLI_DB_TYPE} != "pgsql" ]]; then
249262
waitForDataBase
250263

0 commit comments

Comments
 (0)