pryscraper/Dockerfile
cryptorugmunch 0fc69d2650 feat(db): add Alembic migrations for versioned schema changes
- Add alembic to dev deps and requirements.txt.
- Initialize alembic/ config with SQLite + Postgres support.
- Create 0001_initial_schema migration covering all 26 models.
- Add db.run_migrations() helper and  CLI command.
- Add docker-entrypoint.sh to run migrations before app start.
- Keep Base.metadata.create_all() for backward compatibility.
- Add tests verifying alembic current and upgrade head work.
2026-07-03 02:04:21 +02:00

52 lines
1.9 KiB
Docker

# Pry — Multi-stage Docker build
# Stage 1: Build deps + Playwright + Tesseract
FROM python:3.12-slim AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
wget curl gnupg ca-certificates \
libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 \
libcups2 libdrm2 libdbus-1-3 libxcb1 libxkbcommon0 \
libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
libpango-1.0-0 libcairo2 libasound2 \
tesseract-ocr tesseract-ocr-eng \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN python3 -m playwright install chromium 2>&1 | tail -1
# Stage 2: Runtime
FROM python:3.12-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 \
libcups2 libdrm2 libdbus-1-3 libxcb1 libxkbcommon0 \
libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
libpango-1.0-0 libcairo2 libasound2 \
tesseract-ocr tesseract-ocr-eng \
curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /root/.cache/ms-playwright /root/.cache/ms-playwright
WORKDIR /app
COPY *.py ./
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
COPY alembic.ini ./alembic.ini
COPY alembic/ ./alembic/
COPY routers/ ./routers/
COPY llm_providers/ ./llm_providers/
COPY stealth_scripts/ ./stealth_scripts/
COPY templates/ ./templates/
RUN mkdir -p /app/sessions
EXPOSE 8002
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \
CMD curl -sf http://localhost:8002/health || exit 1
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "8002", \
"--workers", "2", "--timeout-keep-alive", "120", "--limit-concurrency", "20"]