Skip to content

Commit bc04f5a

Browse files
committed
Added supervisor which runs crontab.
1 parent bfd7aac commit bc04f5a

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

.docker/Dockerfile

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ RUN apt-get update \
1010
libpq-dev \
1111
libzip-dev \
1212
unzip \
13-
git
13+
git \
14+
cron \
15+
nano \
16+
supervisor
1417

1518
# Install PHP extensions
1619
RUN docker-php-ext-install \
@@ -22,22 +25,20 @@ RUN docker-php-ext-install \
2225
pdo_mysql \
2326
opcache
2427

25-
# Install XDEBUG
28+
# Install XDEBUG, APCU
2629
RUN pecl install xdebug apcu
27-
# Enable XDEBUG
2830
RUN docker-php-ext-enable xdebug apcu
2931

32+
# Install symfony CLI
3033
RUN curl -sS https://get.symfony.com/cli/installer | bash
3134
RUN mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
3235

33-
# Enable Apache modules
34-
RUN a2enmod rewrite
35-
36-
# Install Composer and dependencies
36+
# Install Composer CLI
3737
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
3838

39-
# Enable Apache mod_rewrite and mod_headers
40-
RUN a2enmod rewrite headers
39+
# Setup crontab
40+
COPY ./crontab /var/www/html/.docker/crontab
41+
RUN crontab /var/www/html/.docker/crontab
4142

4243
# You can add your own aliases here
4344
RUN echo 'alias console="php /var/www/html/bin/console"' >> ~/.bashrc
@@ -46,8 +47,5 @@ RUN echo 'alias dsu="/var/www/html/bin/console d:s:u --force --complete"' >> ~/.
4647

4748
RUN echo "umask 0000" >> /root/.bashrc
4849

49-
# Expose port 80 for Apache
50-
EXPOSE 80
51-
52-
# Start Apache server
53-
CMD ["apache2-foreground"]
50+
# Start Supervisor, which will run cron -f by default.
51+
CMD ["/usr/bin/supervisord"]

.docker/crontab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* * * * * touch /var/www/html/.idea/file_from_crontab

.docker/supervisord.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:cron]
5+
command=cron -f
6+
autostart=true
7+
autorestart=true
8+
stdout_logfile=/var/log/cron.log
9+
stderr_logfile=/var/log/cron_error.log

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ services:
3535
volumes:
3636
- ./:/var/www/html
3737
- ./.docker/virtualhost.conf:/etc/apache2/sites-available/000-default.conf
38+
- ./.docker/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf
3839
ports:
3940
- "80:80"
4041
depends_on:

0 commit comments

Comments
 (0)