Add Docker support for backend

- Add Dockerfile for Python 3.12-slim based backend image
- Add docker-compose.yml for service orchestration
- Add .dockerignore to optimize build context
- Include health check and reference docs in container

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
michael 2025-12-15 14:34:18 -06:00
parent 808326ea36
commit 1e2082b642
3 changed files with 65 additions and 0 deletions

17
.dockerignore Normal file
View file

@ -0,0 +1,17 @@
__pycache__/
*.py[cod]
venv/
.venv/
.env
.env.local
backend/.env
backend/.env.local
.idea/
.vscode/
.DS_Store
.git/
frontend/
specs/
test_files/
*.md
!reference_docs/**/*.md

29
backend/Dockerfile Normal file
View file

@ -0,0 +1,29 @@
FROM python:3.12-slim
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install curl for healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for layer caching
COPY backend/requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY backend/app/ ./app/
# Copy reference docs into the image
COPY reference_docs/ ./reference_docs/
# Set reference docs path for container
ENV REFERENCE_DOCS_PATH=/app/reference_docs
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

19
docker-compose.yml Normal file
View file

@ -0,0 +1,19 @@
services:
backend:
build:
context: .
dockerfile: backend/Dockerfile
ports:
- "8000:8000"
env_file:
- backend/.env
environment:
- HOST=0.0.0.0
- PORT=8000
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
restart: unless-stopped