Phoenix21's picture
Update Dockerfile
f15f261 verified
raw
history blame
873 Bytes
# Use a lightweight Python 3.9 image
FROM python:3.9-slim
# Set environment variables for Python and Hugging Face cache
ENV PYTHONUNBUFFERED=1
ENV TRANSFORMERS_CACHE="/tmp/cache/huggingface/transformers"
ENV HF_HOME="/tmp/cache/huggingface"
# Create a non-root user and switch to it
RUN useradd -m -u 1000 user
USER user
# Set the working directory
WORKDIR /app
# Copy the requirements file and install dependencies
COPY --chown=user ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r /app/requirements.txt
# Copy the rest of the application code
COPY --chown=user . /app
# Expose port 7860 (required by Hugging Face Spaces)
EXPOSE 7860
# Start the FastAPI app using uvicorn via python -m to ensure it's found
CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]