# environment variables necessary to run:
# REPO_URL  the url of this repo
# BRANCH    the branch to work at

FROM nginx:alpine

RUN apk add --no-cache git bash
COPY nginx.conf /etc/nginx/nginx.conf

COPY update.sh /update.sh
RUN chmod +x /update.sh

# Add the cron job to run every 30 minutes
# Redirecting to /proc/1/fd/1 ensures the script's echo statements show up in `docker logs`
RUN echo "*/30 * * * * bash /update.sh > /proc/1/fd/1 2>&1" > /etc/crontabs/root

# Start the cron daemon in the background (-b) and nginx in the foreground
CMD crond -b && nginx -g 'daemon off;'
