feat: Docker image

This commit is contained in:
Piotr Dec 2025-11-28 23:19:23 +01:00
parent 6455087893
commit 4fcd7bc49d
Signed by: stawros
GPG key ID: 74B18A3F0F1E99C0
3 changed files with 96 additions and 0 deletions

62
.dockerignore Normal file
View file

@ -0,0 +1,62 @@
# JB Toolkit
.idea
# Git
.git
.gitignore
.gitattributes
# CI
.woodpecker/
# Virtual env
.venv/
# Docker
docker-compose.yml
Dockerfile
.docker
.dockerignore
# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
target/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# Logs
**/*.log
# Documentation
docs/_build/
# Python mode for VIM
.ropeproject
**/.ropeproject
# Vim swap files
**/*.swp
# Project specific
.compose_repository/
config/
tests/

30
Dockerfile Normal file
View file

@ -0,0 +1,30 @@
FROM ghcr.io/astral-sh/uv:0.9-python3.12-alpine AS builder
WORKDIR /app
RUN apk update \
&& apk add gcc python3-dev musl-dev linux-headers
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-workspace
ADD . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked
FROM python:3.12-alpine3.22
RUN apk update --no-cache \
&& apk add --no-cache git
COPY --from=builder --chown=app:app /app/.venv /app/.venv
COPY --from=builder --chown=app:app /app/app /app/app
ENV PYTHONPATH="/app"
ENTRYPOINT ["app/.venv/bin/python"]
CMD ["/app/app/main.py"]

View file

@ -67,6 +67,10 @@ class HandlerFactory:
return handler
def file_handler(prefix: str = ''):
if not file_path:
raise ValueError("File path must be set.")
file_path.parent.mkdir(parents=True, exist_ok=True)
file_path.touch(exist_ok=True)
handler = TimedRotatingFileHandler(file_path, when='midnight', backupCount=30)
handler.setFormatter(ApplicationFormatter(prefix))
handler.setLevel('TRACE')