Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLATTA-5751: Add cron and deploy entrypoints to Drupal image #39

Merged
merged 6 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions local/drupal/files/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
# This file will be overridden by project's Dockerfile.
2 changes: 1 addition & 1 deletion openshift/drupal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ COPY files/ /
COPY files/etc/profile.d/ /etc/bash

RUN chmod +x /entrypoints/* && \
chmod +x /usr/local/bin/entrypoint
chmod +x /usr/local/bin/*

ENV PATH=${PATH}:/app/vendor/bin:/var/www/html/vendor/bin
ENV COMPOSER_HOME=/.composer
Expand Down
42 changes: 42 additions & 0 deletions openshift/drupal/files/usr/local/bin/cron-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

source /init.sh

echo "Starting cron: $(date)"

# You can add any additional cron "daemons" to project's docker/openshift/crons/ folder.
#
# Example:
# @code
# #!/bin/bash
# while true
# do
# drush some-command
# sleep 600
# done
# @endcode

for cron in /crons/*.sh; do
# Skip legacy base.sh script if it exists.
# Skip Kubernetes hooks that are stored in crons directory.
if [[ "${cron##*/}" == "base.sh" ]] || [[ "${cron##*/}" == *-hook.sh ]]; then
continue
elif [[ -r "$cron" ]]; then
echo "Starting $cron"
exec "$cron" &
fi
done

while true
do
# Rudimentary process supervisor:
# Waits for the next process to terminate. The parent
# process is killed if any subprocess exists with failure.
# OpenShift should then restart the cron pod.
wait -n
exit_code=$?
if [[ "$exit_code" -ne 0 ]]; then
output_error_message "Cron subprocess failed with exit code $exit_code"
exit 1
fi
done
21 changes: 21 additions & 0 deletions openshift/drupal/files/usr/local/bin/drush-deploy-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

source /init.sh

# This script will be the default ENTRYPOINT for deployment job pod.
# It just sources all files within /deploy/* in an alphabetical order and then runs `exec` on the given parameter.
# You can add additional deploy scripts to project's docker/openshift/deploy folder.
if [ -d /deploy ]; then
for i in /deploy/*; do
if [ -r $i ]; then
echo "# Source $i"
. $i
else
echo "! $i not sourced"
fi
done
unset i
fi

echo "Exec: $@"
exec "$@"
Loading