From bf832c60ae1960aae7d4b4c0bda05474a26527b4 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Mon, 15 Jan 2024 21:02:51 +0100 Subject: [PATCH] build: cache more standard image layers (#5133) Run the steps to copy super-linter configs and executables in both the standard and the slim images so that we can cache the steps to install additional linters for the standard image even if we modify super-linter configs and executables. --- Dockerfile | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec4c8e4a..7412e3e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -358,9 +358,6 @@ COPY --chmod=555 scripts/bash-exec.sh /usr/bin/bash-exec ######################### # Configure Environment # ######################### -# Set image variant -ENV IMAGE="slim" - ENV PATH="${PATH}:/venvs/ansible-lint/bin" ENV PATH="${PATH}:/venvs/black/bin" ENV PATH="${PATH}:/venvs/checkov/bin" @@ -384,6 +381,10 @@ ENV PATH="${PATH}:${DART_SDK}/bin:/root/.pub-cache/bin" RUN terrascan init \ && touch ~/.chktexrc +ENTRYPOINT ["/action/lib/linter.sh"] + +FROM base_image as slim + ################################### # Copy linter configuration files # ################################### @@ -394,9 +395,7 @@ COPY TEMPLATES /action/lib/.automation ################################# COPY lib /action/lib -ENTRYPOINT ["/action/lib/linter.sh"] - -FROM base_image as slim +ENV IMAGE="slim" # Run to build version file and validate image RUN ACTIONS_RUNNER_DEBUG=true WRITE_LINTER_VERSIONS_FILE=true IMAGE="${IMAGE}" /action/lib/linter.sh @@ -427,7 +426,6 @@ ARG PWSH_DIRECTORY='/usr/lib/microsoft/powershell' ARG PSSA_VERSION='1.21.0' ENV ARM_TTK_PSD1="/usr/lib/microsoft/arm-ttk/arm-ttk.psd1" -ENV IMAGE="standard" ENV PATH="${PATH}:/var/cache/dotnet/tools:/usr/share/dotnet" # Install super-linter runtime dependencies @@ -461,6 +459,18 @@ RUN --mount=type=secret,id=GITHUB_TOKEN /install-pwsh.sh && rm -rf /install-pwsh COPY scripts/install-arm-ttk.sh / RUN --mount=type=secret,id=GITHUB_TOKEN /install-arm-ttk.sh && rm -rf /install-arm-ttk.sh +################################### +# Copy linter configuration files # +################################### +COPY TEMPLATES /action/lib/.automation + +################################# +# Copy super-linter executables # +################################# +COPY lib /action/lib + +ENV IMAGE="standard" + # Run to build version file and validate image again because we installed more linters RUN ACTIONS_RUNNER_DEBUG=true WRITE_LINTER_VERSIONS_FILE=true IMAGE="${IMAGE}" /action/lib/linter.sh