LLM_Guard / Dockerfile
potato-pzy
Initial commit for Hugging Face Spaces deployment
1481062
Raw
History Blame Contribute Delete
980 Bytes
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 the model download script during build so the space starts up instantly
RUN python download_model.py
# Switch to the non-root user
USER user
# Expose the default Hugging Face Space port
EXPOSE 7860
# Run the Flask app
CMD ["python", "genai_app.py"]