working on dockerization

This commit is contained in:
bvn13 2024-10-16 02:16:10 +03:00
parent 0be2fcbbe5
commit 2ed51cbf44
7 changed files with 57 additions and 4 deletions

48
Dockerfile Normal file
View File

@ -0,0 +1,48 @@
FROM python:3.11.5-slim-bookworm
ARG YOUR_ENV
ARG APP_SETTINGS
ARG APP_DIRECTORY
ARG APP_CHECK_INTERVAL
ARG APP_PORT
ENV YOUR_ENV=${YOUR_ENV} \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# Poetry's configuration:
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
POETRY_HOME='/usr' \
POETRY_VERSION=1.8.3 \
# ^^^
# Make sure to update it!
SETTINGS=${APP_SETTINGS} \
DIRECTORY=${APP_DIRECTORY} \
CHECK_INTERVAL=${APP_CHECK_INTERVAL} \
PORT=${APP_PORT}
# System deps:
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN ls -la /usr/bin
RUN alias poetry=/usr/bin/poetry
RUN poetry lock
# Copy only requirements to cache them in docker layer
WORKDIR /app
COPY poetry.lock pyproject.toml /app/
# Project initialization:
RUN poetry install $(test "$YOUR_ENV" == production && echo "--only=main") --no-interaction --no-ansi
# Creating folders, and files for a project:
COPY src /app
CMD ["poetry", "run", "rss-feedler"]

0
README.md Normal file
View File

View File

@ -4,6 +4,9 @@ version = "0.1.0"
description = "" description = ""
authors = ["bvn13 <from.github@bvn13.me>"] authors = ["bvn13 <from.github@bvn13.me>"]
readme = "README.md" readme = "README.md"
packages = [
{ include = "src" }
]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.12" python = "^3.12"
@ -13,6 +16,8 @@ tornado = "^6.4.1"
asyncio = "^3.4.3" asyncio = "^3.4.3"
scheduler = "^0.8.7" scheduler = "^0.8.7"
[tool.poetry.scripts]
rss-feedler = "src.app:start"
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]

0
src/__init__.py Normal file
View File

View File

@ -6,8 +6,8 @@ import time
import threading import threading
from scheduler import Scheduler from scheduler import Scheduler
from fetcher import fetch from src.fetcher import fetch
from server import start_server from src.server import start_server
from src.logger import logger as l from src.logger import logger as l

View File

@ -6,7 +6,7 @@ from requests import Session
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
from urllib3.util import Retry from urllib3.util import Retry
from src.logger import logger as l from src.logger import logger as l
import stats import src.stats as stats
def fetch(settings: list, args: Namespace) -> None: def fetch(settings: list, args: Namespace) -> None:

View File

@ -3,7 +3,7 @@ import os
from argparse import Namespace from argparse import Namespace
import tornado import tornado
from src.logger import logger as l from src.logger import logger as l
import stats import src.stats as stats
def start_server(settings: list, args: Namespace) -> None: def start_server(settings: list, args: Namespace) -> None: