Spaces:
Running
Running
File size: 1,787 Bytes
e159fb9 3ad6f3d b4a2bb2 3ad6f3d b4a2bb2 e159fb9 3ad6f3d e159fb9 4ea19e8 e159fb9 4ea19e8 e159fb9 3ad6f3d 5505d86 3ad6f3d 5505d86 2e21632 d96f0e7 96f9e36 5505d86 d96f0e7 3ad6f3d e159fb9 3ad6f3d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
FROM python:3.9-slim
WORKDIR /code
# Set environment variables for Hugging Face cache (use /code directory)
ENV HF_HOME=/code/.cache/huggingface
ENV TRANSFORMERS_CACHE=/code/.cache/huggingface
ENV HF_HUB_CACHE=/code/.cache/huggingface
ENV HF_DATASETS_CACHE=/code/.cache/huggingface
# Create cache directories with proper permissions
RUN mkdir -p /code/.cache/huggingface && \
chmod -R 777 /code/.cache && \
chown -R nobody:nogroup /code/.cache
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
python3-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Ensure cache directories exist and have proper permissions
RUN mkdir -p /code/.cache/huggingface && \
chmod -R 777 /code/.cache && \
chown -R nobody:nogroup /code/.cache
# Pre-download the sentence-transformers model during build
RUN python download_model.py || echo "Warning: Model download failed, will retry at runtime"
# Create a startup script for Hugging Face Spaces
RUN echo '#!/bin/bash\n\
echo "Starting HackRx 6.0 on Hugging Face Spaces..."\n\
echo "Cache directory: $HF_HOME"\n\
echo "Using app.py as entry point..."\n\
echo "Starting uvicorn server on port 7860..."\n\
echo "App will be available at: https://huggingface.co/spaces/Manjesh501/hackrx"\n\
exec uvicorn app:app --host 0.0.0.0 --port 7860 --workers 1 --log-level info\n\
' > /code/start.sh && chmod +x /code/start.sh
# Hugging Face Spaces uses port 7860
EXPOSE 7860
# Set environment variables
ENV HOST=0.0.0.0
ENV PORT=7860
# Command to run the application
CMD ["/code/start.sh"] |