Skip to content

Commit

Permalink
Merge pull request #27 from mhubig/feature/GH-21-adds-a-container-to-…
Browse files Browse the repository at this point in the history
…run-cronjobs

[GH-21] Adds a cronjob service to docker-compose.
  • Loading branch information
mhubig authored Apr 12, 2020
2 parents 1bda70b + aaf5ff3 commit 4011811
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN set -ex \
libxml2-dev \
libpng-dev \
libldap2-dev \
cron \
--no-install-recommends && rm -r /var/lib/apt/lists/* \
\
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
Expand All @@ -30,6 +31,7 @@ RUN set -ex \
\
&& a2enmod rewrite

COPY crontab /etc/cron.d/partkeepr
COPY info.php /var/www/html/web/info.php
COPY php.ini /usr/local/etc/php/php.ini
COPY apache.conf /etc/apache2/sites-available/000-default.conf
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ docker-compose exec partkeepr cat app/authkey.php

The default database parameters are:

![Database Parameters](https://raw.githubusercontent.com/mhubig/docker-partkeepr/master/setupdb.png "Database Parameters")
<img src="https://raw.githubusercontent.com/mhubig/docker-partkeepr/master/setupdb.png" width="500">

## Howto manually build & run the docker image

Expand Down
2 changes: 2 additions & 0 deletions crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/10 * * * * /usr/local/bin/php /var/www/html/app/console partkeepr:cron:run 2>&1 > /proc/1/fd/1
# Don't remove the empty line at the end of this file. It is required to run the cron job
32 changes: 24 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
version: "3"
services:

database:
image: mariadb:10.0
restart: on-failure
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_DATABASE=partkeepr
- MYSQL_USER=partkeepr
- MYSQL_PASSWORD=partkeepr
volumes:
- mysql-data:/var/lib/mysql

partkeepr:
image: mhubig/partkeepr:latest
restart: on-failure
environment:
- PARTKEEPR_DATABASE_HOST
- PARTKEEPR_DATABASE_NAME
Expand Down Expand Up @@ -51,22 +63,26 @@ services:
ports:
- "8080:80"
volumes:
- partkeepr-conf:/var/www/html/app/config
- partkeepr-data:/var/www/html/data
- partkeepr-web:/var/www/html/web
depends_on:
- database

database:
image: mariadb:10.0
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_DATABASE=partkeepr
- MYSQL_USER=partkeepr
- MYSQL_PASSWORD=partkeepr
cronjob:
image: mhubig/partkeepr:latest
restart: on-failure
entrypoint: []
command: bash -c "crontab /etc/cron.d/partkeepr && cron -f"
volumes:
- mysql-data:/var/lib/mysql
- partkeepr-conf:/var/www/html/app/config:ro
- partkeepr-data:/var/www/html/data
- partkeepr-web:/var/www/html/web
depends_on:
- partkeepr

volumes:
partkeepr-conf:
partkeepr-data:
partkeepr-web:
mysql-data:

0 comments on commit 4011811

Please sign in to comment.