File size: 1,583 Bytes
26e1c2e a326431 26e1c2e a326431 26e1c2e a326431 26e1c2e a326431 26e1c2e | 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 58 59 60 | FROM python:3.11-slim
# System deps
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential libxml2-dev libxslt1-dev \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user (HF Spaces requirement)
RUN useradd -m -u 1000 appuser
WORKDIR /app
# Install PyTorch with CUDA 12.1 support
RUN pip install --no-cache-dir \
torch==2.3.1 --index-url https://download.pytorch.org/whl/cu121
# Install ML dependencies
RUN pip install --no-cache-dir \
transformers>=4.44.0 \
accelerate>=0.34.0 \
"bitsandbytes>=0.46.1" \
sentencepiece>=0.2.0 \
huggingface_hub>=0.25.0
# Install backend dependencies
COPY murshid_backend/requirements_light.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir openpyxl aiofiles scikit-learn
# Copy backend code
COPY murshid_backend/ ./murshid_backend/
# Copy model files
COPY Needed/ ./Needed/
# Copy frontend
COPY murshid_frontend/ ./murshid_frontend/
# Create writable directory for SQLite DB + HF cache
RUN mkdir -p /app/data /home/appuser/.cache && chown -R appuser:appuser /app /home/appuser
# Setup environment
ENV MURSHID_DB_URL=sqlite:////app/data/murshid.db
ENV MURSHID_MODELS_DIR=/app/Needed
ENV MURSHID_SKIP_LLM=false
ENV SECRET_KEY=murshid_hf_space_2026
ENV PORT=7860
ENV HF_HOME=/home/appuser/.cache/huggingface
ENV TRANSFORMERS_CACHE=/home/appuser/.cache/huggingface/hub
# Run DB migrations + import templates + start server
COPY start.sh ./start.sh
RUN chmod +x start.sh
USER appuser
EXPOSE 7860
CMD ["./start.sh"]
|