Skip to content

Commit

Permalink
feat: add env variables to config cron container
Browse files Browse the repository at this point in the history
  • Loading branch information
Scarbous committed Oct 29, 2024
1 parent 51da475 commit 7d7ef38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 12 additions & 2 deletions php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ CMD ["php", "-a"]

FROM php-cli AS php-cron

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

ENV VHOST_PATH="/var/www"
ENV CRONTAB_PATH="/var/www/Configuration/crontab"
ENV CRON_USER=www-data

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 +221,11 @@ FROM php-cli-dev AS php-cron-dev

WORKDIR /var/www

COPY cron/docker-cron-entrypoint /usr/local/bin/
ENV VHOST_PATH="/var/www"
ENV CRONTAB_PATH="/var/www/Configuration/crontab"
ENV CRON_USER=www-data

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
9 changes: 3 additions & 6 deletions php/cron/docker-cron-entrypoint
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/sh
set -e

env >> /etc/environment
env > /etc/environment

# 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 7d7ef38

Please sign in to comment.