shl-api / Dockerfile
devjhawar's picture
Upload 7 files
8ad2128 verified
raw
history blame contribute delete
719 Bytes
FROM python:3.11-slim
# Create a user to run the app (Hugging Face Spaces requirement)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Copy all files into the container
COPY --chown=user . $HOME/app
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Create a cache directory with proper permissions for Hugging Face transformers
ENV TRANSFORMERS_CACHE=$HOME/app/.cache
RUN mkdir -p $HOME/app/.cache
# Hugging Face Spaces require the app to run on port 7860
EXPOSE 7860
# Start the FastAPI application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]