From ac0c16a44a744d28cd242e218f8d8c607bcee7cb Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Mon, 17 Mar 2025 21:55:14 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(docker)=20Optimize=20Dockerf?= =?UTF-8?q?ile=20to=20use=20`apk`=20with=20`--no-cache`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the `apk` commands with the `--no-cache` parameter for package installation and upgrade will prevent the package index from being cached and reduce the built image size. --- CHANGELOG.md | 4 ++++ Dockerfile | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9325c9c7..af080561 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to ## [Unreleased] +### Changed + +- ⚡️(docker) Optimize Dockerfile to use apk with --no-cache #743 + ## [3.4.1] - 2025-07-15 ### Fixed diff --git a/Dockerfile b/Dockerfile index 37c76034..90b68476 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,7 @@ FROM python:3.13.3-alpine AS base RUN python -m pip install --upgrade pip setuptools # Upgrade system packages to install security updates -RUN apk update && \ - apk upgrade +RUN apk update && apk upgrade --no-cache # ---- Back-end builder image ---- FROM base AS back-builder @@ -45,7 +44,7 @@ FROM base AS link-collector ARG IMPRESS_STATIC_ROOT=/data/static # Install pango & rdfind -RUN apk add \ +RUN apk add --no-cache \ pango \ rdfind @@ -71,7 +70,7 @@ FROM base AS core ENV PYTHONUNBUFFERED=1 # Install required system libs -RUN apk add \ +RUN apk add --no-cache \ cairo \ file \ font-noto \ @@ -117,7 +116,7 @@ FROM core AS backend-development USER root:root # Install psql -RUN apk add postgresql-client +RUN apk add --no-cache postgresql-client # Uninstall impress and re-install it in editable mode along with development # dependencies