Issue
We are building Docker images so we run the task "gradle buildDockerImage" to build our image.
We would like to know the following:
Where do we have to place in our workspace "pre-startup" scripts?
We have tried to create the folder in common or specific environment folder but then the scripts are not appearing in /usr/local/liferay/pre-startup
Environment
- Liferay 7.3 with Liferay Workspace
Resolution
You have to place the scripts inside below route:
${LR_WORKSPACE_HOME}/configs/docker/scripts
Sample script
Is executed when docker image is run
However, scripts placed in you workspace:
${LR_WORKSPACE_HOME}/configs/docker/scripts
before building the image are just copied to:
/home/liferay/configs/local/scripts
during the image creation, and then during the startup of the container they are copied to
/mnt/liferay/scripts
as seen in the logs:
[LIFERAY] Copying /home/liferay/configs/local/scripts scripts files:
/home/liferay/configs/local/scripts
└── my_custom_script.sh
[LIFERAY] ... into /mnt/liferay/scripts
These scripts, however, are only executed before Liferay DXP starts as stated in the official doc:
[LIFERAY] Executing scripts in /mnt/liferay/scripts:
[LIFERAY] Executing my_custom_script.sh.
[CUSTOM SCRIPT] Hello, I'm a custom script copied during the creation of the image!
So they play the role of pre-startup scripts but are not copied to /usr/local/liferay/pre-startup folder actually. To achieve this, you have to bind mount a local folder, place there the required scripts of each phase there and start the container as documented here.
Additional Information