From d124d52c88caa222af60cc4105701e010e52361d Mon Sep 17 00:00:00 2001 From: Eric Vincent Bermudez Date: Sun, 25 Oct 2026 11:39:39 +0800 Subject: [PATCH 1/3] shrink image --- challenges/shrink-the-image/Dockerfile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/challenges/shrink-the-image/Dockerfile b/challenges/shrink-the-image/Dockerfile index 1ac445d..85ed37a 100644 --- a/challenges/shrink-the-image/Dockerfile +++ b/challenges/shrink-the-image/Dockerfile @@ -1,15 +1,9 @@ -FROM python:3.13 - -RUN apt-get update && apt-get install -y \ - build-essential \ - curl \ - git \ - vim +FROM python:3.13-slim WORKDIR /app COPY . . -RUN pip install -r requirements.txt -r requirements-dev.txt +RUN pip install -r requirements.txt EXPOSE 8000 CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "app:app"] From c3e5c7a42616934d10b4f9efbbbbb53f92546ca5 Mon Sep 17 00:00:00 2001 From: Eric Vincent Bermudez Date: Sun, 25 Oct 2026 11:59:58 +0800 Subject: [PATCH 2/3] Shrink the image: slim base, runtime deps only, non-root user --- challenges/shrink-the-image/Dockerfile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/challenges/shrink-the-image/Dockerfile b/challenges/shrink-the-image/Dockerfile index 85ed37a..9868e54 100644 --- a/challenges/shrink-the-image/Dockerfile +++ b/challenges/shrink-the-image/Dockerfile @@ -1,9 +1,12 @@ FROM python:3.13-slim WORKDIR /app -COPY . . +COPY requirements.txt app.py . -RUN pip install -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt && \ +useradd --uid 1001 app + +USER 1001 EXPOSE 8000 CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "app:app"] From 8e6a0784cb31073a477dc49fc92e6abe1e0d8bae Mon Sep 17 00:00:00 2001 From: Eric Vincent Bermudez Date: Sun, 25 Oct 2026 12:04:22 +0800 Subject: [PATCH 3/3] perf(docker): copy app.py after pip install --- challenges/shrink-the-image/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/challenges/shrink-the-image/Dockerfile b/challenges/shrink-the-image/Dockerfile index 9868e54..9518f11 100644 --- a/challenges/shrink-the-image/Dockerfile +++ b/challenges/shrink-the-image/Dockerfile @@ -1,11 +1,13 @@ FROM python:3.13-slim WORKDIR /app -COPY requirements.txt app.py . +COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt && \ useradd --uid 1001 app +COPY app.py . + USER 1001 EXPOSE 8000