Skip to content

Commit

Permalink
build: cache more standard image layers (#5133)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ferrarimarco committed Jan 15, 2024
1 parent 5219fee commit bf832c6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 #
###################################
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bf832c6

Please sign in to comment.