Skip to content

Commit

Permalink
SONARIAC-1701 Update RSPEC description for S6587 (#4562)
Browse files Browse the repository at this point in the history
* SONARIAC-1701 Update RSPEC description for S6587

* Address review comments
  • Loading branch information
rudy-regazzoni-sonarsource authored Dec 9, 2024
1 parent d1ee5fd commit 2bd1df5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rules/S6587/docker/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ 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 (i.e., the same `RUN` instruction) as the installation.

The following code incorrectly cleans the cache:
[source,docker]
----
RUN apt-get install nginx
RUN apt-get clean
----
It should be written as:
[source,docker]
----
RUN apt-get install nginx && apt-get clean
----

== Resources
=== Documentation

Expand Down

0 comments on commit 2bd1df5

Please sign in to comment.