Skip to content

Commit 7502786

Browse files
authored
Merge pull request #1736 from maths/api-cron
Set up API demo server cron job
2 parents 9717627 + 204b39a commit 7502786

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

api/docker/DockerfileDemo

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#This Docker file is for building the University of Edinburgh specific STACK API Demo server.
22
#Please use the other Dockerfile in this folder.
33
#Intermediate step installing dependencies
4-
FROM composer:lts as composer
4+
FROM composer:lts AS composer
55

66
COPY / /work/
77

@@ -43,18 +43,18 @@ COPY / /srv/stack
4343
#Copy dependencies
4444
COPY --from=composer /work/api/vendor /srv/stack/api/vendor
4545

46-
FROM base as development
46+
FROM base AS development
4747

4848
#Enable xdebug extension in develop
4949
COPY /api/docker/files/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
5050
RUN pecl install xdebug && \
5151
docker-php-ext-enable xdebug
5252

53-
FROM development as profiling
53+
FROM development AS profiling
5454

5555
COPY /api/docker/files/xdebug-profile.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
5656

57-
FROM base as production
57+
FROM base AS production
5858

5959
#Enable opcache extension in production
6060
COPY /api/docker/files/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
@@ -66,8 +66,11 @@ RUN docker-php-ext-install opcache && \
6666
# Required for building the Edinburgh demo server
6767
RUN a2enmod ssl && \
6868
apt-get update && \
69-
apt install -y python3 python3-dev python3-venv libaugeas-dev gcc && \
69+
apt-get install -y python3 python3-dev python3-venv libaugeas-dev gcc && \
7070
python3 -m venv /opt/certbot/ && \
7171
/opt/certbot/bin/pip install --upgrade pip && \
7272
/opt/certbot/bin/pip install certbot certbot-apache && \
73-
echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew -q" | tee -a /etc/crontab > /dev/null
73+
apt-get install -y cron
74+
75+
COPY /api/docker/files/startcron /usr/sbin
76+
ENTRYPOINT ["startcron"]

api/docker/files/startcron

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew -q" | tee -a /etc/cron.d/crontab > /dev/null
3+
service cron start
4+
/usr/sbin/apache2ctl -D FOREGROUND

0 commit comments

Comments
 (0)