Anjali04-15's picture
Update Dockerfile
58668d3 verified
raw
history blame contribute delete
993 Bytes
# Use official Python slim image
FROM python:3.9-slim
# Set working directory inside the container
WORKDIR /app
# Copy all files from current directory to /app in the container
COPY . /app
# Install system dependencies for PIL and PyTorch
RUN apt-get update && apt-get install -y \
gcc \
libgl1-mesa-glx \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip and install python dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# create cache folder with write permissions
RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache/huggingface
# set environment variables for huggingface cache
ENV HF_HOME=/app/.cache/huggingface
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
ENV HF_DATASETS_CACHE=/app/.cache/huggingface/datasets
# Expose the port your FastAPI app will run on (7860 is standard on Hugging Face Spaces)
EXPOSE 7860
# Run the FastAPI app with uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]