Spaces:
Sleeping
Sleeping
| # Use an official Python runtime as a parent image | |
| FROM python:3.9-slim | |
| # Set environment variables | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 | |
| # Create a non-root user | |
| RUN useradd --create-home user | |
| # Set the working directory to the user's home directory | |
| WORKDIR /home/user | |
| # Copy and install dependencies | |
| COPY --chown=user:user requirements.txt ./ | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy the application code | |
| COPY --chown=user:user app.py ./ | |
| COPY --chown=user:user model.pkl ./ | |
| # Switch to the non-root user | |
| USER user | |
| # Set environment variables for the application | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Expose the port uvicorn will run on | |
| EXPOSE 7860 | |
| # Define the default command to run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |