Spaces:
Sleeping
Sleeping
| # Use an official Python runtime as a parent image | |
| FROM python:3.11-slim | |
| # Set environment variables | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV ALLOWED_HOSTS=nitinbot001-mistrybox.hf.space,localhost,127.0.0.1 | |
| # Create a non-root user | |
| RUN useradd -m -u 1000 appuser && \ | |
| mkdir -p /app && \ | |
| chown -R appuser:appuser /app | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Copy requirements first (for better caching) | |
| COPY --chown=appuser:appuser requirements.txt /app/ | |
| # Install any needed packages specified in requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the entire project | |
| COPY --chown=appuser:appuser . /app/ | |
| # Switch to non-root user | |
| USER appuser | |
| # Expose port 7860 | |
| EXPOSE 7860 | |
| # Run the application | |
| CMD ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:7860"] |