Created
September 5, 2016 09:45
-
-
Save yetanotherchris/e5185530eee16495a1432d3acf7f3e32 to your computer and use it in GitHub Desktop.
Run cron inside a docker container.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env - `cat /root/env.sh` /bin/bash -c $1 >> /var/log/cron.log 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run every 30 minutes on Wednesday | |
*/30 * * * 3 /root/cron_task.sh /root/run_app.sh | |
# cron needs an empty line at the end, leave this here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM microsoft/dotnet | |
MAINTAINER Chris | |
# Fix from: | |
# https://github.com/bringnow/docker-letsencrypt-manager/commit/7a157dcd05ea8e745ec604734f6e7aa2e9e7b7cc | |
# Put cron logfiles into a volume. This also works around bug | |
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810669 | |
# caused by base image using old version of coreutils | |
# which causes "tail: unrecognized file system type 0x794c7630 for '/var/log/cron.log'" | |
# when using docker with overlay storage driver. | |
VOLUME /var/log/ | |
RUN mkdir /app | |
COPY ./src/MyApp/bin/Debug/netcoreapp1.0/publish /app | |
WORKDIR /app | |
RUN apt-get update | |
RUN apt-get install -y cron | |
ADD *.sh /root/ | |
RUN chmod 750 /root/cron_task.sh | |
RUN chmod 750 /root/run_redditbot.sh | |
RUN chmod 750 /app/ | |
ADD crontab /var/spool/cron/crontabs/root | |
RUN chmod 0600 /var/spool/cron/crontabs/root | |
CMD touch /var/log/cron.log && cron && env > /root/env.sh && tail -f /var/log/cron.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet /app/MyApp.dll |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment