Files
Nat20-Notes/backend/Dockerfile.deps
KansaiGaijin 5081ba00f6
Some checks failed
Build and Push / build (push) Failing after 17s
add auth system and split backend into two-image CI/CD build
Backend:
- password hashing via hashlib.scrypt
- stateless HMAC-SHA256 tokens (7-day expiry)
- POST /api/auth/login, /api/auth/register (admin), /api/auth/reset-password
- admin user created from NAT20_ADMIN_USERNAME/PASSWORD on first startup
- users table, campaign_shares table, created_by on campaigns
- require_user dependency on all routes except auth
- campaign sharing: GET/POST/DELETE /api/campaigns/{id}/shares

Frontend:
- AuthContext: user/token state, login/logout, global fetch Auth header
- Login page, Users page (admin user management)
- route protection, sidebar user info/sign out

Docker/CI:
- split backend/Dockerfile into thin app-only image
- backend/Dockerfile.deps builds the heavy WhisperX/PyTorch base
- CI builds deps only when requirements.txt changes
- docker compose pull now fetches ~100KB app layer instead of 3.5GB
2026-07-30 12:05:56 +12:00

44 lines
1.6 KiB
Docker

# ==========================================
# Build the heavy WhisperX dependency layer.
# Build once (or when requirements.txt changes):
# docker build -f Dockerfile.deps -t nat20-whisperx-base .
# ==========================================
# Stage 1 — builder: compile Python deps
FROM python:3.11-slim AS builder
WORKDIR /build
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
patchelf \
&& rm -rf /var/lib/apt/lists/*
ENV PIP_NO_CACHE_DIR=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
COPY requirements.txt .
RUN pip install --user --extra-index-url https://download.pytorch.org/whl/cu121 -r requirements.txt
RUN python -c "import sys, subprocess, whisperx, pathlib; ckpt = pathlib.Path(whisperx.__file__).parent/'assets'/'pytorch_model.bin'; ckpt.exists() and subprocess.run([sys.executable, '-m', 'pytorch_lightning.utilities.upgrade_checkpoint', str(ckpt)])" 2>/dev/null || true
RUN patchelf --clear-execstack /root/.local/lib/python3.11/site-packages/ctranslate2.libs/libctranslate2-*.so*
RUN find /root/.local -type d -name "__pycache__" -exec rm -rf {} + \
&& find /root/.local -type d \( -name "test" -o -name "tests" \) -exec rm -rf {} + \
&& find /root/.local -name "*.dist-info" -exec sh -c 'rm -f "$1"/RECORD "$1"/INSTALLER' _ {} \;
# Stage 2 — runtime base: system deps + Python packages, no app code
FROM python:3.11-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
ENV PYTHONUNBUFFERED=1