Spaces:
Sleeping
Sleeping
| FROM python:3.11.5 | |
| # Expose the application port | |
| EXPOSE 7860 | |
| # Environment settings | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set the working directory inside the container | |
| WORKDIR /app | |
| # Copy the backend code into the container | |
| COPY backend /app | |
| # Install dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Create a non-root user | |
| RUN useradd -m -u 1000 user | |
| # Create a writable directory for attachments and assign ownership to the non-root user | |
| USER root | |
| RUN mkdir -p /data/attachments && chown -R user:user /data/attachments | |
| # Ensure correct permissions (optional but recommended) | |
| RUN chown -R root:root /app | |
| # Switch to the non-root user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Start the FastAPI application | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |