Spaces:
Runtime error
Runtime error
File size: 1,493 Bytes
d419755 2c9e18c d419755 fb0682f d419755 2c9e18c e847b4c 2d37303 d419755 2d37303 d419755 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # Dockerfile for PUBLIC Space
# This loads and runs code from a private HF Space
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Install basic dependencies
RUN apt-get update && apt-get install -y \
curl \
libpango-1.0-0 \
libpangoft2-1.0-0 \
libharfbuzz0b \
libffi-dev \
libjpeg-dev \
libopenjp2-7 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Python packages needed for loading from private space
RUN pip install --no-cache-dir \
huggingface-hub \
Flask \
dotenv
# Install common dependencies that the loaded app might need
# These will be available when the private space code runs
RUN pip install --no-cache-dir \
google-generativeai \
pypdf2 \
weasyprint \
markdown \
requests \
Pillow
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
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 PYTHONUNBUFFERED=1
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/ping || exit 1
# Run the loader which will download and execute the private space code
CMD ["python", "app.py"]
|