Spaces:
Runtime error
Runtime error
File size: 1,008 Bytes
0d599d9 8ad04f6 0d599d9 f295d99 0d599d9 | 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 | FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
GENAI_PORT=7860 \
HOME=/home/user
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user (required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
WORKDIR /app
# Install CPU-only PyTorch first to reduce container size and build time
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
# Copy and install requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application files
COPY --chown=user:user . .
RUN chown -R user:user /app
# Switch to the non-root user
USER user
# Run the model download script during build so the space starts up instantly
RUN python download_model.py
# Expose the default Hugging Face Space port
EXPOSE 7860
# Run the Flask app
CMD ["python", "genai_app.py"]
|