Skip to content

Commit

Permalink
Add deployment part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
thevops committed Aug 22, 2023
1 parent 603af54 commit 942c052
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.venv
__pycache__
.idea
venv
db/*.db.json
config.yaml
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ RUN pip install --disable-pip-version-check -r /requirements.txt
#
# Stage 2
#
# FROM gcr.io/distroless/python3-debian11:debug AS production
FROM gcr.io/distroless/python3-debian11 AS production

COPY --from=build /venv /venv
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

WORKDIR /app
COPY ./src/ /app

ENV TZ=Europe/Warsaw
ENV PYTHONUNBUFFERED=1
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY --from=build /venv /venv

WORKDIR /app
COPY ./ /app

ENTRYPOINT ["python", "main.py"]
27 changes: 24 additions & 3 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@ tasks:
docker-build:
desc: Build Docker image
cmds:
- docker build -t rss .
- docker build -t ghcr.io/thevops/rss-assistant:{{.VERSION}} .
vars:
VERSION:
sh: cat VERSION

docker-push:
desc: Push Docker image
cmds:
- docker push ghcr.io/thevops/rss-assistant:{{.VERSION}}
vars:
VERSION:
sh: cat VERSION

compose-up:
desc: Run Docker Compose
desc: Run Docker Compose Up
cmds:
- docker compose up --build -d

compose-down:
desc: Run Docker Compose Down
cmds:
- docker compose down

compose-logs:
desc: Stream logs from Docker Compose
cmds:
- docker-compose up -d
- docker compose logs -f
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.0
11 changes: 11 additions & 0 deletions deployment/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
rss-assistant:
image: ghcr.io/thevops/rss-assistant:v1.0.0
container_name: rss-assistant
platform: linux/amd64
environment:
- CONFIG_FILE=/config.yaml
- LOG_LEVEL=DEBUG
volumes:
- ./config.yaml:/config.yaml:ro
- ./db:/app/db
9 changes: 9 additions & 0 deletions deployment/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# Prepare database directory
mkdir db/

# Create configuration file
touch config.yaml

# Download docker-compose.yaml
5 changes: 3 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
services:
rss:
rss-assistant:
build: ./
container_name: rss
container_name: rss-assistant
platform: linux/amd64
environment:
- CONFIG_FILE=/config.yaml
- LOG_LEVEL=DEBUG
volumes:
- ./config.yaml:/config.yaml:ro
- ./db:/app/db
2 changes: 2 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def main():
send_latest_feeds,
trigger=CronTrigger.from_crontab(job["schedule"]),
kwargs=job,
max_instances=1,
misfire_grace_time=60, # 1 minute
)
logger.info("Added RSSFeed job: %s" % job["name"])

Expand Down
2 changes: 1 addition & 1 deletion src/RSSFeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class RSSFeed:
def __init__(self, link, database_dir="db/", history_limit=10):
def __init__(self, link, database_dir="db/", history_limit=100):
self.link = link
self.history_limit = history_limit
# File name for storing the database is separate for each link
Expand Down

0 comments on commit 942c052

Please sign in to comment.