The docker image is re-built on every deployment using project's /docker/openshift/Dockerfile.
The codebase is built into image's /var/www/html
folder using composer: composer install --no-progress --profile --prefer-dist --no-interaction --no-dev --optimize-autoloader
as root
user.
The container is run as random UID (non-root) user (like uid 10009900
) that has no write permissions to any files (except inside /tmp
folder), meaning that files inside the container cannot be modified after the image is built.
See City-of-Helsinki/drupal-docker-images for more documentation about the underlying Docker image.
Crons are run inside a separate cron container and use docker/openshift/crons/base.sh as an entrypoint.
The cron container is run using the same image as the Drupal container and should contain everything your normal container does.
The entrypoint is run only once and the container will die as soon as the "main" loop is finished, meaning that all scripts must be run inside an infinite loop. You can use sleep XX
to define how often a certain task should be run.
Any scripts placed in repository's docker/openshift/crons
folder will be copied automatically
to /crons
folder inside the cron container, but won't be run automatically.
The cron script must contain something like:
#!/bin/bash
echo "Starting my custom cron script: $(date)"
while true
do
echo "Running my custom cron script: $(date)"
drush my_custom_command
# Sleep for 60 seconds.
sleep 60
done
then add exec "/crons/your-custom-cron-script.sh" &
to docker/openshift/crons/base.sh
to run it.