Spaces:
Running
Running
# Use Python as base image | |
FROM python:3.10-slim | |
# Install system dependencies | |
USER root | |
RUN apt-get update && apt-get install -y \ | |
libgl1-mesa-glx \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Set environment variables | |
ENV PYTHONUNBUFFERED=1 \ | |
PYTHONDONTWRITEBYTECODE=1 | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Set the working directory inside the container | |
WORKDIR /app | |
# Copy the project files into the container | |
# COPY . /app | |
COPY --chown=user ./requirements.txt requirements.txt | |
# Install Python dependencies | |
RUN pip install --upgrade pip && pip install -r requirements.txt | |
COPY --chown=user . /app | |
# Expose the application's port | |
EXPOSE 8000 | |
# Start the FastAPI application | |
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:8000", "--workers", "4"] |