-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add crontab to Docker template #339
Comments
We should add this to |
I'd add it to each template instead. |
crontab itself:
docker-compose: services:
app:
image: php-image
cron:
image: php-image
healthcheck:
test: ["CMD", "pgrep", "cron"]
interval: 5s
timeout: 10s
retries: 10
entrypoint: ["/entrypoint_cron.sh"]
command: ["crond", "-f"]
queue:
image: php-image
restart: always # the worker auto exits
healthcheck:
test: ["CMD", "pgrep", "php"]
interval: 5s
timeout: 10s
retries: 10
entrypoint: ["/entrypoint_cron.sh"]
command: ["php", "/app/yii", "queue:listen"] entrypoint_cron.sh: #!/bin/sh
echo "Initializing cron container"
if [ -f /app/crontab ]
then
export > /root/env.sh
chmod 0744 /root/env.sh
cat /app/crontab > /root/crontab
chmod 0644 /root/crontab
crontab /root/crontab
fi
#start cron
exec "$@" Additional packages in Dockerfile: COPY ./wolfi/packages/x86_64/tini-0.19.0-r5.apk /tini.apk
RUN apk add --no-cache \
...
cronie \
/tini.apk
RUN mkdir /root/.cache/crontab -p
COPY ./entrypoint_cron.sh /entrypoint_cron.sh
RUN chmod +x /entrypoint_cron.sh |
Overall a bit complicated. Might worth using https://github.com/aptible/supercronic instead, which doesn't require magic to deal with environment variables. |
An example crontab could be added.
The text was updated successfully, but these errors were encountered: