Spaces:
Sleeping
Sleeping
# Use an official Python runtime as the base image | |
FROM python:3.9-slim | |
# Set working directory | |
WORKDIR /app | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
curl \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy the requirements first to leverage Docker cache | |
COPY requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the application files | |
COPY . . | |
# Create necessary directories and ensure proper permissions | |
RUN mkdir -p data/ scripts/training/models \ | |
&& chmod -R 755 static \ | |
&& chmod -R 755 templates \ | |
&& chown -R nobody:nogroup static templates | |
# Make port 8000 available (FastAPI default port) | |
EXPOSE 8000 | |
# Set environment variable for FastAPI to listen on 0.0.0.0 | |
ENV HOST=0.0.0.0 | |
ENV PORT=8000 | |
# Switch to non-root user | |
USER nobody | |
# Command to run the application using uvicorn | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"] |