Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit fd891d4

Browse files
committed
Configure CRON inside container
1 parent 343b8ab commit fd891d4

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

.docker/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM phpdaily/php:8.1.0-dev-fpm-alpine3.12
22

33
# System dependencies
4-
RUN apk add --update bash sqlite
4+
RUN apk add --update bash sqlite supervisor
55

66
# Install Composer
77
RUN wget https://getcomposer.org/composer.phar \
@@ -11,3 +11,8 @@ RUN wget https://getcomposer.org/composer.phar \
1111
# Install Symfony CLI
1212
RUN wget https://get.symfony.com/cli/installer -O - | bash \
1313
&& mv /root/.symfony/bin/symfony /usr/local/bin/symfony
14+
15+
RUN echo '0 0 * * * cd /var/www/phpversions && bin/console synchronize >> /var/www/phpversions/var/log/cron.log' >> /etc/crontabs/root
16+
17+
COPY conf/supervisor.conf /etc/supervisor/phpversions.conf
18+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/phpversions.conf"]

.docker/conf/supervisor.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:cron]
5+
command=/usr/sbin/crond -f -l 8
6+
stdout_logfile=/dev/stdout
7+
stderr_logfile=/dev/stderr
8+
stdout_logfile_maxbytes=0
9+
stderr_logfile_maxbytes=0
10+
autorestart=true
11+
12+
[program:php-fpm]
13+
command=docker-php-entrypoint php-fpm

.docker/entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#/bin/sh
2+
3+
set -e
4+
5+
echo "* * * * * cd /var/www/phpversions && bin/console synchronize >> var/log/cron.log" >> /etc/crontabs/root
6+
7+
/usr/sbin/crond
8+
9+
/usr/local/bin/docker-php-entrypoint "$@"

docker-compose.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
version: '3.7'
22
services:
33
nginx:
4-
image: nginx:1.19-alpine
4+
image: nginx:stable-alpine
5+
depends_on:
6+
- fpm
57
ports:
68
- 80:80
79
volumes:

0 commit comments

Comments
 (0)