Skip to content

Commit

Permalink
SONARIAC-1701 Update RSPEC description for S6587
Browse files Browse the repository at this point in the history
  • Loading branch information
rudy-regazzoni-sonarsource committed Dec 9, 2024
1 parent d1ee5fd commit 32c7203
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rules/S6587/docker/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ They are not removed by the `clean` command, so they need to be removed manually
Alternatively, store the cache in a dedicated cache mount. A cache mount can be created by adding a flag `--mount type=cache` to the `RUN` command. +
This will store the cache in a Docker volume, which will be persisted between builds making the build faster.

Also, each `RUN` instruction creates a new layer, and any changes made in one layer are not visible in the next. Thus, the cache should be removed in the same layer as the installation in the same `RUN` instruction.

The following code incorrectly cleans the cache:
[source,docker]
----
RUN apt-get install -y git
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
----
It should be written as:
[source,docker]
----
RUN apt-get install -y git \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
----

== Resources
=== Documentation

Expand Down

0 comments on commit 32c7203

Please sign in to comment.