Skip to content

Commit 990e31a

Browse files
Feat: Add Docker Compose, security tools, and improve logging (#8)
Introduces docker-compose.yml and .dockerignore for container orchestration and build optimization. Switches Dockerfile to use the official Python image and installs uv via pip. Adds pip-audit and detect-secrets to pre-commit and dev dependencies, and updates Taskfile.yml with new security and Docker tasks. Improves logging in FastAPI app and main entrypoint, refines global exception handling, and updates tests for logger usage. Removes SECURITY.md and unused test fixture. Dependabot schedule changed to weekly. ## Description Please include a summary of the change and which issue is fixed. ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update ## Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with `make test`
1 parent 4e376c8 commit 990e31a

File tree

15 files changed

+401
-80
lines changed

15 files changed

+401
-80
lines changed

.coverage

0 Bytes
Binary file not shown.

.dockerignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
*.pyd
5+
.Python
6+
env/
7+
venv/
8+
.venv/
9+
pip-log.txt
10+
pip-delete-this-directory.txt
11+
.tox/
12+
.coverage
13+
.coverage.*
14+
.cache
15+
nosetests.xml
16+
coverage.xml
17+
*.cover
18+
*.log
19+
.git
20+
.mypy_cache
21+
.pytest_cache
22+
.hypothesis

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ updates:
44
- package-ecosystem: "pip"
55
directory: "/"
66
schedule:
7-
interval: "daily"
7+
interval: "weekly"
88
time: "09:00"
99
timezone: "America/New_York"
1010
labels:

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,14 @@ repos:
2020
- id: bandit
2121
args: ["-r", "src"]
2222
exclude: ^tests/
23+
24+
- repo: https://github.com/pypa/pip-audit
25+
rev: v2.7.3
26+
hooks:
27+
- id: pip-audit
28+
args: ["--progress-spinner", "off"]
29+
30+
- repo: https://github.com/Yelp/detect-secrets
31+
rev: v1.5.0
32+
hooks:
33+
- id: detect-secrets

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
],
1717
"mypy-type-checker.args": [
1818
"--config-file=pyproject.toml"
19-
]
19+
],
20+
"makefile.configureOnOpen": false
2021
}

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# Use a Python image with uv pre-installed
2-
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
1+
# Use standard Python image to avoid ghcr.io auth issues
2+
FROM python:3.13-slim
3+
4+
# Install uv
5+
RUN pip install uv
36

47
# Set the working directory to /app
58
WORKDIR /app

SECURITY.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

Taskfile.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ tasks:
6767
- uv run python -m mypy src tests
6868

6969
security:
70-
desc: Run bandit security checks
70+
desc: Run all security checks (bandit, pip-audit)
7171
cmds:
7272
- uv run bandit -r src
73+
- task: security-audit
7374

7475
check:
7576
desc: Run all checks (lint, format, type-check, security, test)
@@ -103,6 +104,21 @@ tasks:
103104
cmds:
104105
- docker run --rm defaultpython
105106

107+
docker-up:
108+
desc: Start services with docker compose
109+
cmds:
110+
- docker compose up --build
111+
112+
docker-down:
113+
desc: Stop services
114+
cmds:
115+
- docker compose down
116+
117+
security-audit:
118+
desc: Check for known security vulnerabilities in dependencies
119+
cmds:
120+
- uv run pip-audit
121+
106122
pre-commit:
107123
desc: Run pre-commit hooks on all files
108124
cmds:

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
services:
2+
app:
3+
build: .
4+
image: defaultpython-app
5+
environment:
6+
- APP_ENV=production
7+
volumes:
8+
- .:/app
9+
- /app/.venv
10+
# If/when you switch to a web server, uncomment ports:
11+
# ports:
12+
# - "8000:8000"
13+
# command: uvicorn defaultpython.main:app --host 0.0.0.0 --port 8000 --reload

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ requires-python = ">=3.13"
1111
dependencies = [
1212
"fastapi>=0.128.0",
1313
"pydantic-settings>=2.12.0",
14+
"python-dotenv>=1.2.1",
1415
"uvicorn>=0.40.0",
1516
]
1617

@@ -58,6 +59,9 @@ disallow_untyped_defs = true
5859
[dependency-groups]
5960
dev = [
6061
"bandit>=1.9.2",
62+
"detect-secrets>=1.5.0",
63+
"pip-audit>=2.7.3",
64+
"vulture>=2.11",
6165
"commitizen>=4.11.3",
6266
"httpx>=0.28.1",
6367
"mypy>=1.19.1",

0 commit comments

Comments
 (0)