Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile to run Shreddit as an hourly cron job #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kusold
Copy link

@kusold kusold commented Aug 18, 2017

I was wondering if you would be interested in having a docker image for this repo. DockerHub provides automated docker builds if you setup an integration with Github, so once it is setup things should be pretty hands off unless the installation steps change.

If you are not interested in having the dockerfile be part of your project, I can manage the dockerfile in a separate repo. If this happens, would you be interested in adding a push_event so that I can have the image rebuild each time you commit?

@ghost
Copy link

ghost commented Oct 19, 2017

I personally would be absolutely happy to have a docker file to do exactly this. Hourly is a little often but weekly would be absolutely fantastic.


COPY . /shreddit
WORKDIR /shreddit
RUN pip install -r requirements.txt && python setup.py install
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider seperating the copy of requirements.txt and everything else so Docker caches the install. Something like:

WORKDIR /shreddit
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . ./
RUN python setup.py install

Changes to anything but requirements.txt will not require a reinstall when the container is rebuilt -- it'll just start at the python setup.py install

@KopfKrieg
Copy link

Hourly is a little often but weekly would be absolutely fantastic.

I'd go with daily. Seems like a nice compromise.

@ghost
Copy link

ghost commented Aug 18, 2018

This absolutely needs to happen, is it? Running Shreddit manually is a pain.

Someone?

@KopfKrieg
Copy link

KopfKrieg commented Aug 18, 2018

For now you could use a timer, or a cron job :)

@ghost
Copy link

ghost commented Aug 23, 2018

Would you mind quickly telling me how to do this? I'd like to have it setup on a server that is always running so it actually does do this properly. I guess I'd need to install python or something too of course. I'm not using any VMs on my server, just Docker. Is it possible to do it with that or?

@KopfKrieg
Copy link

I'm not using any VMs on my server, just Docker. Is it possible to do it with that or?

Well, on your host system you should add an entry to the crontab, which executes the script (doesn't matter if within a docker container or not) in a specific interval.

The entry in the crontab for running the script, for example, every 15 minutes within a docker container could look like this:

echo "*/15 *   * * *   root    /usr/bin/docker exec docker-shreddit -s /bin/bash -c '/path/to/the/script.sh'"
@MitchTalmadge
Copy link

I made an image this week which has support for any CRON schedule:

https://github.com/MitchTalmadge/shreddit-dockerized

Enjoy

@kusold
Copy link
Author

kusold commented May 11, 2022

https://github.com/kusold/Shreddit

I setup automatic publishing of docker images on my repo. It does not include cron inside the image, you can manage that with k8s, or just a host level cron job.

My fork also makes this compatible with Python 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants