daily_paper_reader / Dockerfile
anik-jha's picture
updated port
cee0f63
Raw History Blame Contribute Delete
1.3 kB
# Dockerfile for PUBLIC Space
# This loads and runs code from a private HF Space
FROM python:3.12-slim
# Set working directory
WORKDIR /app
# Set Python to run in unbuffered mode (see logs immediately)
ENV PYTHONUNBUFFERED=1
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
build-essential \
gcc \
libffi-dev \
libxml2-dev \
libxslt1-dev \
poppler-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Python packages needed for loading from private space
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir \
huggingface-hub \
Flask
# Copy requirements and install additional dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Create a non-root user
RUN useradd -m -u 1000 appuser && \
chown -R appuser:appuser /app
# Copy only the loader script
COPY app.py .
# Switch to non-root user
USER appuser
# Set environment variables
ENV PORT=7860
# Expose port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# Run the loader which will download and execute the private space code
CMD ["python", "app.py"]