Skip to content

Commit 1bada56

Browse files
authored
Merge pull request #4 from SmileyJoe/add-docker-cron
Adding docker with daily cron
2 parents 2e9b786 + 7136710 commit 1bada56

11 files changed

Lines changed: 45 additions & 3 deletions

File tree

Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM python:3.10
2+
3+
RUN apt-get update && apt-get -y install cron vim
4+
5+
WORKDIR /github/app
6+
COPY ./app /github/app
7+
COPY ./repos /github/repos
8+
9+
RUN pip install -r requirements.txt
10+
COPY crontab /etc/cron.d/crontab
11+
12+
RUN chmod 0644 /etc/cron.d/crontab
13+
RUN /usr/bin/crontab /etc/cron.d/crontab
14+
15+
# run crond as main process of container
16+
CMD ["cron", "-f"]

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@ This is meant as a backup, the repos it clones should not be updated as there is
66

77
## Setup
88

9-
- Duplicate `example_config.yaml` and rename it to `config.yaml`
9+
- Copy `example_config.yaml` into `app/` and rename it to `config.yaml`
1010
- Update `config.yaml` with your keys/settings
11-
- Install the requirements with `pip install -r requirements.txt`
1211
- See [here](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) for generating a github token
1312
- For the pushover api token, a new app will need to be registered [here](https://pushover.net/apps/build)
1413

14+
## Docker
15+
16+
- Update `Dockerfile` and `docker-compose.yml` to reference the local directory the repos will be cloned to
17+
- Run the container with `docker-compose up -d`
18+
19+
## Without docker
20+
21+
- Install the requirements with `pip install -r requirements.txt`
22+
- Run with `python app/main.py`
23+
1524
## Translations
1625

1726
- Copy a language file, rename the 2 letter code and translate it, the file can them be specified in `config.yaml`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

main.py renamed to app/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727

2828
# if the path is not set, we need to clone the repo
2929
if not os.path.isdir(repo_dir):
30-
Repo.clone_from(repo.ssh_url, repo_dir)
30+
# clone using the token, this means ssh doesn't need to be setup
31+
repo_url = "https://{username}:{password}@github.com/{repo_name}.git".format(
32+
username=config.github.username,
33+
password=config.github.token,
34+
repo_name=repo.full_name)
35+
Repo.clone_from(repo_url, repo_dir)
3136
log.cloned(repo.name)
3237
# else we need to pull the new contents
3338
else:
File renamed without changes.

crontab

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#run python script every day at midnight
2+
0 0 * * * /usr/local/bin/python /github/app/main.py > /proc/1/fd/1 2>/proc/1/fd/2

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '1'
2+
services:
3+
github:
4+
build: .
5+
volumes:
6+
- ./app:/github/app
7+
- ./repos:/github/repos

0 commit comments

Comments
 (0)