Skip to content

Commit

Permalink
Merge pull request #358 from netlogix/feature/variable-crontab-path
Browse files Browse the repository at this point in the history
feat: add env variables to config cron container
  • Loading branch information
Scarbous authored Oct 30, 2024
2 parents 51da475 + 6670feb commit 8f0423a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
6 changes: 4 additions & 2 deletions php/8.2.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ CMD ["php", "-a"]

FROM php-cli AS php-cron

COPY cron/docker-cron-entrypoint /usr/local/bin/
WORKDIR /var/www

COPY --chmod=0755 cron/docker-cron-entrypoint /usr/local/bin/

ENTRYPOINT ["docker-cron-entrypoint"]
CMD ["cron", "-f", "-l", "2"]
Expand Down Expand Up @@ -219,7 +221,7 @@ FROM php-cli-dev AS php-cron-dev

WORKDIR /var/www

COPY cron/docker-cron-entrypoint /usr/local/bin/
COPY --chmod=0755 cron/docker-cron-entrypoint /usr/local/bin/

# Disabling the health check of the descendant php-fpm-dev image, since the production php-cron image does neither have a healthcheck.
HEALTHCHECK NONE
Expand Down
6 changes: 4 additions & 2 deletions php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ CMD ["php", "-a"]

FROM php-cli AS php-cron

COPY cron/docker-cron-entrypoint /usr/local/bin/
WORKDIR /var/www

COPY --chmod=0755 cron/docker-cron-entrypoint /usr/local/bin/

ENTRYPOINT ["docker-cron-entrypoint"]
CMD ["cron", "-f", "-l", "2"]
Expand Down Expand Up @@ -215,7 +217,7 @@ FROM php-cli-dev AS php-cron-dev

WORKDIR /var/www

COPY cron/docker-cron-entrypoint /usr/local/bin/
COPY --chmod=0755 cron/docker-cron-entrypoint /usr/local/bin/

# Disabling the health check of the descendant php-fpm-dev image, since the production php-cron image does neither have a healthcheck.
HEALTHCHECK NONE
Expand Down
13 changes: 7 additions & 6 deletions php/cron/docker-cron-entrypoint
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/sh
set -e

env >> /etc/environment
export VHOST_PATH="/var/www"
env > /etc/environment

CRONTAB_PATH="${CRONTAB_PATH:-/var/www/Configuration/crontab}"
CRON_USER="${CRON_USER:-www-data}"

# init crontab file
if [ -f "/var/www/Configuration/crontab" ]; then
echo "$(
echo "VHOST_PATH=/var/www"
cat /var/www/Configuration/crontab
)" | crontab -u www-data -
if [ -f $CRONTAB_PATH ]; then
crontab -u $CRON_USER - < $CRONTAB_PATH
fi

exec "$@"

0 comments on commit 8f0423a

Please sign in to comment.