File size: 669 Bytes
fbd5a42 | 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 | # Use the official Python image
FROM python:3.9-slim
# Set the working directory inside the container
WORKDIR /app
# Copy the requirements file
COPY requirements.txt .
# Install dependencies
# --no-cache-dir keeps the image small
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the app code (main.py and .pkl files)
COPY . .
# Create a generic user (Hugging Face requirement for security)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Expose the port (Hugging Face uses 7860 by default)
EXPOSE 7860
# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |