crawler / Dockerfile
cruelface's picture
Deploy web crawler
0dd9d3c
Raw History Blame Contribute Delete
971 Bytes
# Use a lightweight official Python runtime
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
# Install minimal system packages for lxml compile fallbacks
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user (Hugging Face Spaces runs as UID 1000)
RUN useradd -m -u 1000 user
WORKDIR /home/user/app
# Set permissions for home directory
RUN chown user:user /home/user/app
USER user
# Set user local path
ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:$PATH
# Copy requirements and install dependencies
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Copy the rest of the application files
COPY --chown=user:user . .
# Expose port 7860
EXPOSE 7860
# Run FastAPI via Uvicorn
CMD ["uvicorn", "web_app:app", "--host", "0.0.0.0", "--port", "7860"]