From 4be89b244c88802eb1e055daaaf93d7de1ba6e44 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Wed, 9 Apr 2025 00:03:25 +0800 Subject: [PATCH] Remove redundant `apk update` in Dockerfiles (cc #5016) (#9055) The `apk` commands can utilize the `--no-cache` option, making the `update` step superfluous and ensuring the latest packages are used without maintaining a local cache. An additional `apk update` in the Dockerfile will just make the image larger with no benefits. --- Dockerfile | 6 ++---- docker/Dockerfile.alpine | 2 +- docker/Dockerfile.database | 6 ++---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index e0ae2ed091..3a74c46e68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,7 @@ WORKDIR /app USER root # Install build dependencies -RUN apk update && \ - apk add --no-cache gcc python3-dev openssl openssl-dev +RUN apk add --no-cache gcc python3-dev openssl openssl-dev RUN pip install --upgrade pip && \ @@ -52,8 +51,7 @@ FROM $LITELLM_RUNTIME_IMAGE AS runtime USER root # Install runtime dependencies -RUN apk update && \ - apk add --no-cache openssl +RUN apk add --no-cache openssl WORKDIR /app # Copy the current directory contents into the container at /app diff --git a/docker/Dockerfile.alpine b/docker/Dockerfile.alpine index cc0c434013..f036081549 100644 --- a/docker/Dockerfile.alpine +++ b/docker/Dockerfile.alpine @@ -35,7 +35,7 @@ RUN pip wheel --no-cache-dir --wheel-dir=/wheels/ -r requirements.txt FROM $LITELLM_RUNTIME_IMAGE AS runtime # Update dependencies and clean up -RUN apk update && apk upgrade && rm -rf /var/cache/apk/* +RUN apk upgrade --no-cache WORKDIR /app diff --git a/docker/Dockerfile.database b/docker/Dockerfile.database index f0b5eec8f9..da0326fd2c 100644 --- a/docker/Dockerfile.database +++ b/docker/Dockerfile.database @@ -12,8 +12,7 @@ WORKDIR /app USER root # Install build dependencies -RUN apk update && \ - apk add --no-cache gcc python3-dev openssl openssl-dev +RUN apk add --no-cache gcc python3-dev openssl openssl-dev RUN pip install --upgrade pip && \ @@ -44,8 +43,7 @@ FROM $LITELLM_RUNTIME_IMAGE AS runtime USER root # Install runtime dependencies -RUN apk update && \ - apk add --no-cache openssl +RUN apk add --no-cache openssl WORKDIR /app # Copy the current directory contents into the container at /app