Spaces:
Paused
Paused
File size: 1,041 Bytes
4efde5d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
FROM ghcr.io/astral-sh/uv:python3.11-alpine
ENV ENV_MODE production
WORKDIR /app
RUN apk add --no-cache curl git
# Install Python dependencies
COPY pyproject.toml uv.lock ./
ENV UV_LINK_MODE=copy
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --quiet
# Copy application code
COPY . .
# Calculate optimal worker count based on 16 vCPUs
# Using (2*CPU)+1 formula for CPU-bound applications
ENV WORKERS=7
ENV THREADS=2
ENV WORKER_CONNECTIONS=2000
ENV PYTHONPATH=/app
EXPOSE 8000
# Gunicorn configuration
CMD ["sh", "-c", "uv run gunicorn api:app \
--workers $WORKERS \
--worker-class uvicorn.workers.UvicornWorker \
--bind 0.0.0.0:8000 \
--timeout 1800 \
--graceful-timeout 600 \
--keep-alive 1800 \
--max-requests 0 \
--max-requests-jitter 0 \
--forwarded-allow-ips '*' \
--worker-connections $WORKER_CONNECTIONS \
--worker-tmp-dir /dev/shm \
--preload \
--log-level info \
--access-logfile - \
--error-logfile - \
--capture-output \
--enable-stdio-inheritance \
--threads $THREADS"]
|