MusAI / Dockerfile
Eng-Musa's picture
dockerfile modification"
a4a1ec8
raw
history blame contribute delete
922 Bytes
# 1. Use Hugging Face recommended Python image
FROM python:3.9
# 2. Create non-root user (required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# 3. Set working directory
WORKDIR /app
# 4. Install essential system dependencies
# - switched to root temporarily
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc libpq-dev && \
rm -rf /var/lib/apt/lists/*
USER user
# 5. Copy requirements first for caching
COPY --chown=user requirements.txt .
# 6. Upgrade pip & install Python dependencies
RUN python -m pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# 7. Copy the rest of the app code
COPY --chown=user . .
# 8. Expose Hugging Face default port
EXPOSE 7860
# 9. Run Uvicorn server for FastAPI app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]