brainfuncall / Dockerfile
triflix's picture
Create Dockerfile
221c179 verified
raw
history blame contribute delete
746 Bytes
# Use Python 3.10 slim image for small footprint
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Create a non-root user (Required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Copy requirements first to leverage Docker cache
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the application code
COPY --chown=user . .
# Create a cache directory for the model so it's writable
RUN mkdir -p /home/user/.cache/huggingface && chmod -R 777 /home/user/.cache
# Expose the Hugging Face default port
EXPOSE 7860
# Start the FastAPI server
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]