- #12: Remove duplicate logging.basicConfig() from 10 modules - #15: Remove redundant import re in rebuild_database.py - #17: rglob('*') → rglob('*.html/json/txt/xml/md') for speed - #18: Dockerfile individual COPY → glob COPY *.py/*.json + .dockerignore - #19: Remove deprecated docker-compose version field - #20: Pin requirements.txt versions (flask, requests, etc.) - #22: SIGALRM → threading.Timer for multi-threaded safety - #23: AP regex parsing → BeautifulSoup selectors
46 lines
1.0 KiB
Docker
46 lines
1.0 KiB
Docker
FROM python:3.11-slim
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install system dependencies for Playwright
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy requirements first for better caching
|
|
COPY requirements.txt .
|
|
|
|
# Install Python dependencies
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Install Playwright browsers
|
|
RUN playwright install chromium --with-deps || true
|
|
|
|
# Create app directory structure
|
|
RUN mkdir -p /app/archival_data
|
|
|
|
# Set environment variable for archive directory (can be overridden)
|
|
ENV ARCHIVE_DIR=/app/archival_data
|
|
|
|
# Copy application code
|
|
COPY *.py ./
|
|
COPY *.json ./
|
|
|
|
# Copy templates and static directories if they exist
|
|
COPY templates/ ./templates/
|
|
COPY static/ ./static/
|
|
|
|
# Copy entrypoint script
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
# Expose Flask port
|
|
EXPOSE 5000
|
|
|
|
# Use entrypoint script
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
|
|
# Default command
|
|
CMD ["python", "run_archiver.py", "--serve", "--host", "0.0.0.0", "--port", "5000"]
|