Combine apt statements in Dockerfile

Quoting the Docker documentation [1]:

> Always combine RUN apt-get update with apt-get install in the same RUN
> statement.
> (...)
> Using apt-get update alone in a RUN statement causes caching issues
> and subsequent apt-get install instructions fail.
> (...)
> Docker sees the initial and modified instructions as identical and
> reuses the cache from previous steps. As a result the apt-get update
> is not executed because the build uses the cached version. Because the
> apt-get update is not run, your build can potentially get an outdated
> version of the curl and nginx packages.
>
> Using RUN apt-get update && apt-get install -y ensures your Dockerfile
> installs the latest package versions with no further coding or manual
> intervention.

[1] https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
This commit is contained in:
Javi Martín
2021-12-09 18:22:38 +01:00
parent 54eb65b81d
commit 8c5e7121ef

View File

@@ -3,8 +3,7 @@ FROM ruby:2.7.4-buster
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
# Install essential Linux packages # Install essential Linux packages
RUN apt-get update -qq RUN apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql-client nodejs imagemagick sudo libxss1 libappindicator1 libindicator7 unzip memcached cmake pkg-config shared-mime-info
RUN apt-get install -y build-essential libpq-dev postgresql-client nodejs imagemagick sudo libxss1 libappindicator1 libindicator7 unzip memcached cmake pkg-config shared-mime-info
# Install Chromium for E2E integration tests # Install Chromium for E2E integration tests
RUN apt-get update -qq && apt-get install -y chromium RUN apt-get update -qq && apt-get install -y chromium