diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..daf4f93 --- /dev/null +++ b/.dockerignore @@ -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/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a3f2cd1 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/app/util/logging.py b/app/util/logging.py index 3e9e77a..15e52c9 100644 --- a/app/util/logging.py +++ b/app/util/logging.py @@ -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')