From 8b4c84f82579e04f4041e887e7b3b7ffcc48a5c8 Mon Sep 17 00:00:00 2001 From: Christian Krakau-Louis Date: Sun, 9 Feb 2025 16:17:31 +0100 Subject: [PATCH] Create Dockerfile --- Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4c843024 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Stage 1: Build +FROM python:3.11 AS builder + +WORKDIR /app + +# Copy only dependency files first for better caching +COPY requirements.txt /app/ +RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt + +# Stage 2: Final image +FROM python:3.11-slim + +WORKDIR /app + +# Copy installed dependencies from builder stage +COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages +COPY --from=builder /usr/local/bin /usr/local/bin + +# Copy application files +COPY ./app /app + +# Set environment variables +ENV PYTHONUNBUFFERED=1 + +# Expose API port +EXPOSE 8000 + +# Default command +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]