Initial scaffold: FastAPI micro-service with Docker, SQLite, tests

This commit is contained in:
founder
2026-06-05 02:45:49 +02:00
commit 350143ceb4
16 changed files with 460 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
# ---- Build stage ----
FROM python:3.12-slim AS builder
WORKDIR /app
# Install dependencies in a venv
COPY requirements.txt .
RUN python -m venv /opt/venv && \
/opt/venv/bin/pip install --no-cache-dir -r requirements.txt
# ---- Runtime stage ----
FROM python:3.12-slim AS runtime
WORKDIR /app
# Copy virtualenv from builder
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy application code
COPY app/ ./app/
# Create data dir for SQLite
RUN mkdir -p /app/data && chmod 777 /app/data
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')" || exit 1
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]