| FROM python:3.9 | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| libsndfile1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /app | |
| # Copy requirements first to leverage Docker cache | |
| COPY --chown=user requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy the rest of the application | |
| COPY --chown=user . /app | |
| # Set environment variables | |
| ENV FLASK_APP=app.py | |
| ENV FLASK_ENV=production | |
| ENV PORT=7860 | |
| # Expose the port the app runs on | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--worker-class", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "app:app"] |