Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Add customs scripts via volume mount #150

Merged
merged 3 commits into from
Apr 29, 2024
Merged

Conversation

Vaadasch
Copy link
Contributor

@Vaadasch Vaadasch commented Apr 27, 2024

Hi,

As i need to configure some things after the deployment of this image, i suggest to add this functionality.

By adding mount volume inside the container at :

  • /var/www/scripts/docker-init.d/php
  • /var/www/scripts/docker-init.d/sql

We can use these folder to store scripts and sql files to be executed at the end of the deployment, at the end of the function "initializeDatabase" inside docker-run.sh, the same way as docker-init.php

I don't know what would be the best to the names of folders or other things, but the functionality will allow to automate and set up template on new deployments.

And will allow me to customize without creating lot of PR 😉

Copy link
Owner

@tuxgasy tuxgasy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* /var/www/scripts/docker-init.d/php

Just allow scripts in /var/www/scripts/docker-init.d/. Depending on the file extension, run the script with PHP or shell or import the SQL file.

* /var/www/scripts/docker-init.d/sql

We can use these folder to store scripts and sql files to be executed at the end of the deployment, at the end of the function "initializeDatabase" inside docker-run.sh, the same way as docker-init.php

Mariadb docker image already allows the database to be initialized via the volume mount /docker-entrypoint-initdb.d.
If need, you can update the database via your custom script.

@Vaadasch
Copy link
Contributor Author

Vaadasch commented Apr 28, 2024

Just allow scripts in /var/www/scripts/docker-init.d/. Depending on the file extension, run the script with PHP or shell or import the SQL file.

Yep, that would be better indeed. For those who want to categorize inside folders, shell scripts will allow it.

Mariadb docker image already allows the database to be initialized via the volume mount /docker-entrypoint-initdb.d.
If need, you can update the database via your custom script.

Will that not be erased by the importing of install/mysql/data/*.sql ?

@tuxgasy
Copy link
Owner

tuxgasy commented Apr 28, 2024

Will that not be erased by the importing of install/mysql/data/*.sql ?

No but if the database is already initialized with Dolibarr data, the initializeDatabase function will not be called.

@Vaadasch
Copy link
Contributor Author

Ok.
Thanks you for clarifying, it is indeed only to execution at the first initialisation of a new Dolibarr instance.
The rest should be done through the Dolibarr modules.

Copy link
Owner

@tuxgasy tuxgasy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test later.

@tuxgasy tuxgasy merged commit bf68e31 into tuxgasy:master Apr 29, 2024
2 checks passed
@Vaadasch Vaadasch deleted the add_customs branch May 16, 2024 09:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants