Update state.json and development plan to reflect actual progress (~15%)

- state.json: Phase 5 status changed to pending, next steps updated
- DEVELOPMENT_PLAN.md v1.1: Added actual progress, verified current state,
  renumbered phases 5-9, marked all remaining work as PENDING
- Deleted outdated plans (BACKEND_TEST_PLAN, DATA_LOADING_VERIFICATION,
  DOCKER_MIGRATION_PLAN, ENDPOINT_AUDIT, ROADMAP, SIMPLIFICATION_PLAN,
  STATEMENT_OF_INTENT, backend/TEST_PLAN)
- Added new files: DEVELOPMENT_PLAN.md, backend/ARCHITECTURAL_REPORT.md,
  backend/SIMPLIFICATION_SUMMARY.md, backend/run.py, backend/.dockerignore
This commit is contained in:
2026-08-27 04:41:30 +00:00
parent 900f51af3a
commit 0e6506d97f
17 changed files with 2938 additions and 2218 deletions
+22 -58
View File
@@ -1,84 +1,48 @@
# Build stage
FROM python:3.12-slim as builder
# Multi-stage build for MTG Online Backend
# Stage 1: Install dependencies
FROM python:3.12-slim AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
build-essential \
libpq-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Application stage
# Stage 2: Production image
FROM python:3.12-slim
LABEL org.label-schema.name="mtgonline-backend" \
org.label-schema.description="MTG Online Backend API" \
org.label-schema.version="0.2.0" \
org.label-schema.build-date="${BUILD_DATE}" \
org.label-schema.vcs-url="https://gitea.wallomation.com/wall-o/mtgonline"
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder
COPY --from=builder /root/.local /app/.local
ENV PATH=/app/.local/bin:$PATH
# Create non-root user
RUN groupadd -r appuser && useradd -r -g appuser -d /app -s /sbin/nologin appuser
# Create necessary directories
RUN mkdir -p /app/data /app/uploads /app/logs /app/scripts /app/alembic/versions && \
chown -R appuser:appuser /app
# Copy dependencies from builder
COPY --from=builder /root/.local /root/.local
# Add local bin to PATH
ENV PATH=/root/.local/bin:$PATH
# Copy application code
COPY --chown=appuser:appuser app/ ./app/
COPY . .
# Copy Alembic configuration
COPY --chown=appuser:appuser alembic.ini ./
COPY --chown=appuser:appuser alembic/ ./alembic/
# Copy scripts (including entrypoint)
COPY --chown=appuser:appuser scripts/ ./scripts/
RUN chmod +x /app/scripts/*.py /app/scripts/docker-entrypoint.sh
# Copy environment files
COPY --chown=appuser:appuser .env ./.env
COPY --chown=appuser:appuser .env.example ./.env.example
COPY --chown=appuser:appuser pyproject.toml ./
# Python environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONPATH=/app
# Logging configuration
ENV MTG_LOG_LEVEL=INFO
ENV MTG_LOG_FORMAT=text
# Create logging directory with proper permissions
RUN mkdir -p /app/logs && chown appuser:appuser /app/logs
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Set ownership
RUN chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Expose port
EXPOSE 8000
# Use entrypoint script for dependency checking and migrations
ENTRYPOINT ["/app/scripts/docker-entrypoint.sh"]
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--forwarded-allow-ips", "*"]
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
# Run the application
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]