️(docker) Optimize Dockerfile to use apk with --no-cache

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.
This commit is contained in:
Peter Dave Hello
2025-03-17 21:55:14 +08:00
committed by Anthony LC
parent ca09f9a158
commit ac0c16a44a
2 changed files with 8 additions and 5 deletions

View File

@@ -8,6 +8,10 @@ and this project adheres to
## [Unreleased] ## [Unreleased]
### Changed
- ⚡️(docker) Optimize Dockerfile to use apk with --no-cache #743
## [3.4.1] - 2025-07-15 ## [3.4.1] - 2025-07-15
### Fixed ### Fixed

View File

@@ -7,8 +7,7 @@ FROM python:3.13.3-alpine AS base
RUN python -m pip install --upgrade pip setuptools RUN python -m pip install --upgrade pip setuptools
# Upgrade system packages to install security updates # Upgrade system packages to install security updates
RUN apk update && \ RUN apk update && apk upgrade --no-cache
apk upgrade
# ---- Back-end builder image ---- # ---- Back-end builder image ----
FROM base AS back-builder FROM base AS back-builder
@@ -45,7 +44,7 @@ FROM base AS link-collector
ARG IMPRESS_STATIC_ROOT=/data/static ARG IMPRESS_STATIC_ROOT=/data/static
# Install pango & rdfind # Install pango & rdfind
RUN apk add \ RUN apk add --no-cache \
pango \ pango \
rdfind rdfind
@@ -71,7 +70,7 @@ FROM base AS core
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
# Install required system libs # Install required system libs
RUN apk add \ RUN apk add --no-cache \
cairo \ cairo \
file \ file \
font-noto \ font-noto \
@@ -117,7 +116,7 @@ FROM core AS backend-development
USER root:root USER root:root
# Install psql # 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 # Uninstall impress and re-install it in editable mode along with development
# dependencies # dependencies