Spaces:
Sleeping
Sleeping
# Use a lightweight base image | |
FROM python:3.10-slim | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
libglib2.0-0 \ | |
libgl1-mesa-glx \ | |
libsm6 \ | |
libxext6 \ | |
libxrender-dev \ | |
git \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set working directory | |
WORKDIR /app | |
# Create a non-root user to run the application | |
RUN useradd -m appuser | |
RUN chown -R appuser:appuser /app | |
# Create cache directories with proper permissions | |
RUN mkdir -p /tmp/matplotlib /tmp/torchxrayvision | |
RUN chown -R appuser:appuser /tmp/matplotlib /tmp/torchxrayvision | |
# Copy project files | |
COPY --chown=appuser:appuser . . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Switch to non-root user | |
USER appuser | |
# Expose the port used by FastAPI | |
EXPOSE 7860 | |
# Start the API | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |