- Add Alembic migration setup with async configuration - Create 16 user data models (users, decks, cards, replays, etc.) - Implement comprehensive API endpoints with JWT auth - Add replay, card collection, group, network, preferences, and activity log routers - Include API documentation and migration test plan - Update Dockerfile to run migrations on startup
61 lines
1.6 KiB
Docker
61 lines
1.6 KiB
Docker
# Build stage
|
|
FROM python:3.12-slim as builder
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN groupadd -r appuser && useradd -r -g appuser -d /app -s /sbin/nologin appuser
|
|
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir --user -r requirements.txt
|
|
|
|
# Application stage
|
|
FROM python:3.12-slim
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libpq5 \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=builder /root/.local /app/.local
|
|
|
|
ENV PATH=/app/.local/bin:$PATH
|
|
|
|
RUN groupadd -r appuser && useradd -r -g appuser -d /app -s /sbin/nologin appuser
|
|
|
|
RUN mkdir -p /app/data /app/uploads /app/logs /app/scripts /app/alembic/versions && chown -R appuser:appuser /app
|
|
|
|
# Copy application code
|
|
COPY --chown=appuser:appuser app/ ./app/
|
|
|
|
# Copy Alembic configuration
|
|
COPY --chown=appuser:appuser alembic.ini ./
|
|
COPY --chown=appuser:appuser alembic/ ./alembic/
|
|
|
|
# Copy interaction pipeline scripts
|
|
COPY --chown=appuser:appuser scripts/ ./scripts/
|
|
RUN chmod +x /app/scripts/*.py
|
|
|
|
COPY --chown=appuser:appuser .env.example ./.env.example
|
|
COPY --chown=appuser:appuser pyproject.toml ./
|
|
|
|
ENV PYTHONPATH=/app
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
HEALTHCHECK --interval=30s --timeout=20s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/health || exit 1
|
|
|
|
USER appuser
|
|
|
|
EXPOSE 8000
|
|
|
|
# Run migrations before starting the app
|
|
CMD ["sh", "-c", "python -m alembic upgrade head && python -m uvicorn app.main:app --host 0.0.0.0 --port 8000"]
|