Spaces:
Runtime error
Runtime error
Enhance Dockerfile: add permissions setup for cache directory and improve prompt construction in chat_hf.py
f13a869
FROM python:3.13-slim | |
# Disable buffering for easier logging | |
ENV PYTHONUNBUFFERED=1 | |
# Set PYTHONPATH environment variable | |
ENV PYTHONPATH=/app | |
# Set working directory | |
WORKDIR /app | |
# Create cache and logs directories early + set permissions | |
RUN mkdir -p /app/logs /app/.cache/huggingface && \ | |
chmod -R 777 /app/logs /app/.cache | |
# Ensure correct permissions for cache directory | |
RUN mkdir -p /app/hf_cache && \ | |
chmod -R 777 /app/hf_cache | |
# Copy only requirements first to leverage Docker cache | |
COPY ./app/requirements.txt /app/requirements.txt | |
# Install OS dependencies | |
RUN apt-get update && apt-get install -y \ | |
gcc \ | |
libffi-dev \ | |
libssl-dev \ | |
ca-certificates \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& apt-get clean | |
# Install Python dependencies | |
RUN pip install --upgrade pip && \ | |
pip install -r requirements.txt | |
# Copy the entire app directory into the container | |
COPY ./app /app | |
# Set environment variables for Hugging Face token and cache | |
ARG HF_TOKEN | |
ENV HF_TOKEN=${HF_TOKEN} | |
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface | |
ENV HF_HOME=/app/.cache/huggingface | |
# Expose port | |
EXPOSE 7860 | |
# Healthcheck | |
HEALTHCHECK --interval=15s --timeout=5s --start-period=90s --retries=5 \ | |
CMD curl --fail http://https://adsurkasur-arina-hf-spaces-api.hf.space/healthz || exit 1 | |
# Run FastAPI app | |
CMD ["uvicorn", "main_hf:app", "--host", "0.0.0.0", "--port", "7860"] | |