File size: 868 Bytes
e1581e4 c7b1ae2 e1581e4 c7b1ae2 381d345 e1581e4 00a7e34 933a887 e1581e4 849a7bc 3721a6d e1581e4 00a7e34 e1581e4 3721a6d 381d345 |
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 |
# Use the official Python 3.10 slim image
FROM python:3.10-slim
# Set environment variables to prevent Python from writing pyc files and to buffer stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set the working directory to /app
WORKDIR /app
# Install system dependencies to get `nproc` (for number of CPU cores)
RUN apt-get update && apt-get install -y procps
# Copy only the requirements.txt first to leverage Docker cache
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# Expose port 8001 to the outside world
EXPOSE 8001
# Command to run Uvicorn with a dynamic number of workers based on the CPU cores
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 8001 --workers $(nproc)"] |