From 9cef9b929be0b38d6f9be6a6288fdafc2369ea23 Mon Sep 17 00:00:00 2001 From: ulises-jeremias Date: Mon, 4 Dec 2023 03:22:10 -0300 Subject: [PATCH] Updated code --- .../apps/python-fastapi-app/Dockerfile | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/examples/kubernetes-tilt-dev/apps/python-fastapi-app/Dockerfile b/examples/kubernetes-tilt-dev/apps/python-fastapi-app/Dockerfile index 763c2cd..0414bbf 100644 --- a/examples/kubernetes-tilt-dev/apps/python-fastapi-app/Dockerfile +++ b/examples/kubernetes-tilt-dev/apps/python-fastapi-app/Dockerfile @@ -9,22 +9,9 @@ COPY requirements*.txt ./ # Install development dependencies RUN pip install --no-cache-dir -r requirements.dev.txt -# Stage 2: Build production dependencies -FROM python:3.12.0-alpine AS builder-prod - -WORKDIR /code - -# Copy production requirements file -COPY requirements.txt ./ - -# Install production dependencies -RUN pip install --no-cache-dir -r requirements.txt - +# Stage 2: Build development dependencies and run the application in development mode FROM builder-dev AS development -# Copy development dependencies from builder-dev stage -COPY --from=builder-dev /usr/local /usr/local - # Copy the application code COPY ./app ./app @@ -37,7 +24,18 @@ USER nonroot # Command to run the application CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80", "--reload"] -# Stage 3: Final image +# Stage 3: Build production dependencies +FROM python:3.12.0-alpine AS builder-prod + +WORKDIR /code + +# Copy production requirements file +COPY requirements.txt ./ + +# Install production dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Stage 4: Final image FROM python:3.12.0-alpine as production WORKDIR /code