Spaces:
Sleeping
Sleeping
Update Dockerfile and docker-compose.yml to expose port 7860 and run Gunicorn with updated parameters
a5247bb
| FROM python:3.12-slim | |
| WORKDIR /app | |
| # Combining update and install to ensure proper cache handling | |
| RUN apt-get update -y && \ | |
| apt-get install -y --no-install-recommends \ | |
| curl \ | |
| poppler-utils \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender1 \ | |
| libgomp1 \ | |
| wget && \ | |
| apt-get clean -y && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Install poetry | |
| RUN pip install poetry | |
| # Configure poetry | |
| RUN poetry config virtualenvs.create false | |
| # Copy dependency files | |
| COPY pyproject.toml poetry.lock* /app/ | |
| # Install dependencies | |
| RUN poetry install --only main --no-root | |
| # Download spacy model | |
| RUN python -m spacy download en_core_web_trf | |
| # Create user | |
| RUN useradd -m -u 1000 appuser | |
| # Copy source code | |
| COPY --chown=appuser src /app/src | |
| COPY --chown=appuser main.py /app/ | |
| # Change ownership | |
| RUN chown -R appuser /app | |
| USER appuser | |
| EXPOSE 7860 | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PYTHONPATH=/app | |
| ENV SPACY_MODEL_NAME=en_core_web_trf | |
| CMD ["gunicorn", "src.app:app", "-k", "uvicorn.workers.UvicornWorker", "-w", "2", "--preload", "-b", "0.0.0.0:7860", "--timeout", "600", "--graceful-timeout", "180", "--keep-alive", "180"] | |