Spaces:
mxrkai
/
Runtime error

test24 / Dockerfile
Niansuh's picture
Update Dockerfile
562b93f verified
raw
history blame
1.02 kB
# Stage 1: Build
FROM python:3.10-slim AS builder
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Set the working directory in the container
WORKDIR /app
# Copy the requirements file first for caching
COPY requirements.txt /app/
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# Stage 2: Production
FROM python:3.10-slim
# Set environment variables for user installation
ENV PATH=/root/.local/bin:$PATH
ENV PYTHONUNBUFFERED=1
# Set the working directory in the container
WORKDIR /app
# Copy only the necessary files from the builder stage
COPY --from=builder /root/.local /root/.local
COPY . /app
# Expose the port that the FastAPI app runs on
EXPOSE 8001
# Command to run the app with Gunicorn and Uvicorn workers
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "--workers", "4", "--bind", "0.0.0.0:8001", "main:app"]