ai / Dockerfile
Ahmed Tarek
changes
80f913d
raw
history blame contribute delete
956 Bytes
FROM python:3.10-slim
WORKDIR /app
# Install system dependencies + filelock for TinyDB
RUN apt-get update && \
apt-get install -y --no-install-recommends g++ && \
rm -rf /var/lib/apt/lists/*
# Create directory structure with fail-safes
RUN mkdir -p /.cache/huggingface/hub && \
mkdir -p /tmp/hf_cache && \
chmod -R 777 /tmp/hf_cache && \
chmod -R 777 /.cache # Full permissions
# Install Python dependencies (add filelock)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt filelock
# Copy app code (ensure proper permissions)
COPY --chmod=777 . .
# Environment configuration
ENV HF_HOME=/tmp/hf_cache \
PYTHONUNBUFFERED=1
ENV ONNX_MODELS_DIR=/tmp
ENV HF_HOME=/.cache/huggingface/hub
# Health check (optional but recommended)
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:7860/ || exit 1
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]