Skip to content

Commit ea5c767

Browse files
committed
Add COPY --link --from by using dockerfile frontend syntax
1 parent 722ee45 commit ea5c767

File tree

55 files changed

+419
-371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+419
-371
lines changed

.automation/build.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,13 @@ def generate_flavor(flavor, flavor_info):
209209
os.makedirs(os.path.dirname(dockerfile), exist_ok=True)
210210
copyfile(f"{REPO_HOME}/Dockerfile", dockerfile)
211211
flavor_label = flavor_info["label"]
212-
comment = f"# MEGA-LINTER FLAVOR [{flavor}]: {flavor_label}"
212+
comment = f"# MEGALINTER FLAVOR [{flavor}]: {flavor_label}"
213213
with open(dockerfile, "r+", encoding="utf-8") as f:
214+
first_line = f.readline().rstrip()
215+
if first_line.startswith("# syntax="):
216+
comment = f"{first_line}\n{comment}"
217+
else:
218+
f.seek(0)
214219
content = f.read()
215220
f.seek(0)
216221
f.truncate()

Dockerfile

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# syntax=docker/dockerfile:1
12
###########################################
23
###########################################
34
## Dockerfile to run MegaLinter ##
@@ -292,26 +293,26 @@ ENV PATH="/root/.cargo/bin:${PATH}"
292293
#############################################################################################
293294

294295
#COPY__START
295-
COPY --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
296+
COPY --link --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
296297
# shellcheck is a dependency for actionlint
297-
COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
298-
299-
COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
300-
COPY --from=shfmt /bin/shfmt /usr/bin/
301-
COPY --from=clj-kondo /bin/clj-kondo /usr/bin/
302-
COPY --from=hadolint /bin/hadolint /usr/bin/hadolint
303-
COPY --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
304-
COPY --from=revive /usr/bin/revive /usr/bin/revive
305-
COPY --from=chktex /usr/bin/chktex /usr/bin/
306-
COPY --from=checkmake /checkmake /usr/bin/checkmake
307-
COPY --from=protolint /usr/local/bin/protolint /usr/bin/
308-
COPY --from=dustilock /usr/bin/dustilock /usr/bin/dustilock
309-
COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
310-
COPY --from=tflint /usr/local/bin/tflint /usr/bin/
311-
COPY --from=terrascan /go/bin/terrascan /usr/bin/
312-
COPY --from=terragrunt /usr/local/bin/terragrunt /usr/bin/
313-
COPY --from=terragrunt /bin/terraform /usr/bin/
314-
COPY --from=kics /app/bin/kics /usr/bin/
298+
COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
299+
300+
COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
301+
COPY --link --from=shfmt /bin/shfmt /usr/bin/
302+
COPY --link --from=clj-kondo /bin/clj-kondo /usr/bin/
303+
COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint
304+
COPY --link --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
305+
COPY --link --from=revive /usr/bin/revive /usr/bin/revive
306+
COPY --link --from=chktex /usr/bin/chktex /usr/bin/
307+
COPY --link --from=checkmake /checkmake /usr/bin/checkmake
308+
COPY --link --from=protolint /usr/local/bin/protolint /usr/bin/
309+
COPY --link --from=dustilock /usr/bin/dustilock /usr/bin/dustilock
310+
COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/
311+
COPY --link --from=tflint /usr/local/bin/tflint /usr/bin/
312+
COPY --link --from=terrascan /go/bin/terrascan /usr/bin/
313+
COPY --link --from=terragrunt /usr/local/bin/terragrunt /usr/bin/
314+
COPY --link --from=terragrunt /bin/terraform /usr/bin/
315+
COPY --link --from=kics /app/bin/kics /usr/bin/
315316
COPY --from=kics /app/bin/assets /opt/kics/assets/
316317
#COPY__END
317318

@@ -401,9 +402,9 @@ RUN echo y|sfdx plugins:install sfdx-hardis \
401402
# ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
402403

403404
# actionlint installation
404-
# Managed with COPY --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
405+
# Managed with COPY --link --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
405406
# shellcheck is a dependency for actionlint
406-
COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
407+
COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
407408

408409

409410
# arm-ttk installation
@@ -419,18 +420,18 @@ RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \
419420
&& chmod +x /usr/bin/bash-exec \
420421

421422
# shellcheck installation
422-
# Managed with COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
423+
# Managed with COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
423424

424425
# shfmt installation
425-
# Managed with COPY --from=shfmt /bin/shfmt /usr/bin/
426+
# Managed with COPY --link --from=shfmt /bin/shfmt /usr/bin/
426427

427428
# bicep_linter installation
428429
&& curl --retry 5 --retry-delay 5 -sLo ${BICEP_EXE} "${BICEP_URI}" \
429430
&& chmod +x "${BICEP_EXE}" \
430431
&& mv "${BICEP_EXE}" "${BICEP_DIR}" \
431432

432433
# clj-kondo installation
433-
# Managed with COPY --from=clj-kondo /bin/clj-kondo /usr/bin/
434+
# Managed with COPY --link --from=clj-kondo /bin/clj-kondo /usr/bin/
434435

435436
# csharpier installation
436437
&& /usr/share/dotnet/dotnet tool install -g csharpier \
@@ -445,10 +446,10 @@ RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \
445446
&& rm -r dart-sdk/ \
446447

447448
# hadolint installation
448-
# Managed with COPY --from=hadolint /bin/hadolint /usr/bin/hadolint
449+
# Managed with COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint
449450

450451
# editorconfig-checker installation
451-
# Managed with COPY --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
452+
# Managed with COPY --link --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
452453

453454
# dotenv-linter installation
454455
&& wget -q -O - https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh | sh -s \
@@ -459,7 +460,7 @@ RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \
459460

460461

461462
# revive installation
462-
# Managed with COPY --from=revive /usr/bin/revive /usr/bin/revive
463+
# Managed with COPY --link --from=revive /usr/bin/revive /usr/bin/revive
463464

464465
# checkstyle installation
465466
RUN --mount=type=secret,id=GITHUB_TOKEN CHECKSTYLE_LATEST=$(curl -s \
@@ -505,7 +506,7 @@ RUN wget --quiet https://github.com/pmd/pmd/releases/download/pmd_releases%2F${P
505506
&& find ${ML_THIRD_PARTY_DIR} -type f -not -name 'LICENSE*' -delete -o -type d -empty -delete \
506507

507508
# chktex installation
508-
# Managed with COPY --from=chktex /usr/bin/chktex /usr/bin/
509+
# Managed with COPY --link --from=chktex /usr/bin/chktex /usr/bin/
509510
&& cd ~ && touch .chktexrc && cd / \
510511

511512
# luacheck installation
@@ -524,7 +525,7 @@ RUN wget --quiet https://github.com/pmd/pmd/releases/download/pmd_releases%2F${P
524525
&& cd / \
525526

526527
# checkmake installation
527-
# Managed with COPY --from=checkmake /checkmake /usr/bin/checkmake
528+
# Managed with COPY --link --from=checkmake /checkmake /usr/bin/checkmake
528529

529530
# perlcritic installation
530531
&& curl --retry 5 --retry-delay 5 -sL https://cpanmin.us/ | perl - -nq --no-wget Perl::Critic
@@ -553,7 +554,7 @@ RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
553554
# RUN pwsh -c 'Install-Module -Name PSScriptAnalyzer -RequiredVersion ${PSSA_VERSION} -Scope AllUsers -Force'
554555

555556
# protolint installation
556-
# Managed with COPY --from=protolint /usr/local/bin/protolint /usr/bin/
557+
# Managed with COPY --link --from=protolint /usr/local/bin/protolint /usr/bin/
557558

558559
# lintr installation
559560
&& mkdir -p /home/r-library \
@@ -581,10 +582,10 @@ ENV PATH="~/.raku/bin:/opt/rakudo-pkg/bin:/opt/rakudo-pkg/share/perl6/site/bin:$
581582
RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI \
582583

583584
# dustilock installation
584-
# Managed with COPY --from=dustilock /usr/bin/dustilock /usr/bin/dustilock
585+
# Managed with COPY --link --from=dustilock /usr/bin/dustilock /usr/bin/dustilock
585586

586587
# gitleaks installation
587-
# Managed with COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
588+
# Managed with COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/
588589

589590
# syft installation
590591
&& curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin \
@@ -630,19 +631,19 @@ RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI \
630631
&& dotnet tool install --global TSQLLint \
631632

632633
# tflint installation
633-
# Managed with COPY --from=tflint /usr/local/bin/tflint /usr/bin/
634+
# Managed with COPY --link --from=tflint /usr/local/bin/tflint /usr/bin/
634635

635636
# terrascan installation
636-
# Managed with COPY --from=terrascan /go/bin/terrascan /usr/bin/
637+
# Managed with COPY --link --from=terrascan /go/bin/terrascan /usr/bin/
637638

638639
# terragrunt installation
639-
# Managed with COPY --from=terragrunt /usr/local/bin/terragrunt /usr/bin/
640+
# Managed with COPY --link --from=terragrunt /usr/local/bin/terragrunt /usr/bin/
640641

641642
# terraform-fmt installation
642-
# Managed with COPY --from=terragrunt /bin/terraform /usr/bin/
643+
# Managed with COPY --link --from=terragrunt /bin/terraform /usr/bin/
643644

644645
# kics installation
645-
# Managed with COPY --from=kics /app/bin/kics /usr/bin/
646+
# Managed with COPY --link --from=kics /app/bin/kics /usr/bin/
646647
&& mkdir -p /opt/kics/assets
647648
ENV KICS_QUERIES_PATH=/opt/kics/assets/queries KICS_LIBRARIES_PATH=/opt/kics/assets/libraries
648649
# Managed with COPY --from=kics /app/bin/assets /opt/kics/assets/

flavors/ci_light/Dockerfile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# MEGA-LINTER FLAVOR [ci_light]: Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML
1+
# syntax=docker/dockerfile:1
2+
# MEGALINTER FLAVOR [ci_light]: Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML
23
###########################################
34
###########################################
45
## Dockerfile to run MegaLinter ##
@@ -164,34 +165,34 @@ ENV PATH="/root/.cargo/bin:${PATH}"
164165
#############################################################################################
165166

166167
#COPY__START
167-
COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
168-
COPY --from=shfmt /bin/shfmt /usr/bin/
169-
COPY --from=hadolint /bin/hadolint /usr/bin/hadolint
170-
COPY --from=checkmake /checkmake /usr/bin/checkmake
171-
COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
168+
COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
169+
COPY --link --from=shfmt /bin/shfmt /usr/bin/
170+
COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint
171+
COPY --link --from=checkmake /checkmake /usr/bin/checkmake
172+
COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/
172173
#COPY__END
173174

174175
#############################################################################################
175176
## @generated by .automation/build.py using descriptor files, please do not update manually ##
176177
#############################################################################################
177178
#OTHER__START
178179
# shellcheck installation
179-
# Managed with COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
180+
# Managed with COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
180181

181182
# shfmt installation
182-
# Managed with COPY --from=shfmt /bin/shfmt /usr/bin/
183+
# Managed with COPY --link --from=shfmt /bin/shfmt /usr/bin/
183184

184185
# hadolint installation
185-
# Managed with COPY --from=hadolint /bin/hadolint /usr/bin/hadolint
186+
# Managed with COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint
186187

187188
# dotenv-linter installation
188189
RUN wget -q -O - https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh | sh -s \
189190

190191
# checkmake installation
191-
# Managed with COPY --from=checkmake /checkmake /usr/bin/checkmake
192+
# Managed with COPY --link --from=checkmake /checkmake /usr/bin/checkmake
192193

193194
# gitleaks installation
194-
# Managed with COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
195+
# Managed with COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/
195196

196197
# trivy installation
197198
&& wget --tries=5 -q -O - https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin

flavors/cupcake/Dockerfile

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# MEGA-LINTER FLAVOR [cupcake]: MegaLinter for the most commonly used languages
1+
# syntax=docker/dockerfile:1
2+
# MEGALINTER FLAVOR [cupcake]: MegaLinter for the most commonly used languages
23
###########################################
34
###########################################
45
## Dockerfile to run MegaLinter ##
@@ -251,23 +252,23 @@ ENV PATH="/root/.cargo/bin:${PATH}"
251252
#############################################################################################
252253

253254
#COPY__START
254-
COPY --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
255+
COPY --link --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
255256
# shellcheck is a dependency for actionlint
256-
COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
257-
258-
COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
259-
COPY --from=shfmt /bin/shfmt /usr/bin/
260-
COPY --from=clj-kondo /bin/clj-kondo /usr/bin/
261-
COPY --from=hadolint /bin/hadolint /usr/bin/hadolint
262-
COPY --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
263-
COPY --from=revive /usr/bin/revive /usr/bin/revive
264-
COPY --from=checkmake /checkmake /usr/bin/checkmake
265-
COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
266-
COPY --from=tflint /usr/local/bin/tflint /usr/bin/
267-
COPY --from=terrascan /go/bin/terrascan /usr/bin/
268-
COPY --from=terragrunt /usr/local/bin/terragrunt /usr/bin/
269-
COPY --from=terragrunt /bin/terraform /usr/bin/
270-
COPY --from=kics /app/bin/kics /usr/bin/
257+
COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
258+
259+
COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
260+
COPY --link --from=shfmt /bin/shfmt /usr/bin/
261+
COPY --link --from=clj-kondo /bin/clj-kondo /usr/bin/
262+
COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint
263+
COPY --link --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
264+
COPY --link --from=revive /usr/bin/revive /usr/bin/revive
265+
COPY --link --from=checkmake /checkmake /usr/bin/checkmake
266+
COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/
267+
COPY --link --from=tflint /usr/local/bin/tflint /usr/bin/
268+
COPY --link --from=terrascan /go/bin/terrascan /usr/bin/
269+
COPY --link --from=terragrunt /usr/local/bin/terragrunt /usr/bin/
270+
COPY --link --from=terragrunt /bin/terraform /usr/bin/
271+
COPY --link --from=kics /app/bin/kics /usr/bin/
271272
COPY --from=kics /app/bin/assets /opt/kics/assets/
272273
#COPY__END
273274

@@ -299,29 +300,29 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI
299300
ENV PATH="/root/.composer/vendor/bin:$PATH"
300301

301302
# actionlint installation
302-
# Managed with COPY --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
303+
# Managed with COPY --link --from=actionlint /usr/local/bin/actionlint /usr/bin/actionlint
303304
# shellcheck is a dependency for actionlint
304-
COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
305+
COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
305306

306307

307308
# bash-exec installation
308309
RUN printf '#!/bin/bash \n\nif [[ -x "$1" ]]; then exit 0; else echo "Error: File:[$1] is not executable"; exit 1; fi' > /usr/bin/bash-exec \
309310
&& chmod +x /usr/bin/bash-exec \
310311

311312
# shellcheck installation
312-
# Managed with COPY --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
313+
# Managed with COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck
313314

314315
# shfmt installation
315-
# Managed with COPY --from=shfmt /bin/shfmt /usr/bin/
316+
# Managed with COPY --link --from=shfmt /bin/shfmt /usr/bin/
316317

317318
# clj-kondo installation
318-
# Managed with COPY --from=clj-kondo /bin/clj-kondo /usr/bin/
319+
# Managed with COPY --link --from=clj-kondo /bin/clj-kondo /usr/bin/
319320

320321
# hadolint installation
321-
# Managed with COPY --from=hadolint /bin/hadolint /usr/bin/hadolint
322+
# Managed with COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint
322323

323324
# editorconfig-checker installation
324-
# Managed with COPY --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
325+
# Managed with COPY --link --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checker
325326

326327
# dotenv-linter installation
327328
&& wget -q -O - https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh | sh -s \
@@ -332,7 +333,7 @@ RUN printf '#!/bin/bash \n\nif [[ -x "$1" ]]; then exit 0; else echo "Error: Fil
332333

333334

334335
# revive installation
335-
# Managed with COPY --from=revive /usr/bin/revive /usr/bin/revive
336+
# Managed with COPY --link --from=revive /usr/bin/revive /usr/bin/revive
336337

337338
# checkstyle installation
338339
RUN --mount=type=secret,id=GITHUB_TOKEN CHECKSTYLE_LATEST=$(curl -s \
@@ -379,7 +380,7 @@ RUN wget --quiet https://github.com/pmd/pmd/releases/download/pmd_releases%2F${P
379380

380381

381382
# checkmake installation
382-
# Managed with COPY --from=checkmake /checkmake /usr/bin/checkmake
383+
# Managed with COPY --link --from=checkmake /checkmake /usr/bin/checkmake
383384

384385
# phpcs installation
385386
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192
@@ -398,7 +399,7 @@ RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
398399
&& composer global config bin-dir --absolute \
399400

400401
# gitleaks installation
401-
# Managed with COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
402+
# Managed with COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/
402403

403404
# trivy installation
404405
&& wget --tries=5 -q -O - https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin \
@@ -412,19 +413,19 @@ RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
412413
&& find /tmp -path '/tmp/tmp.*' -type f -name 'misspell*' -delete -o -type d -empty -delete \
413414

414415
# tflint installation
415-
# Managed with COPY --from=tflint /usr/local/bin/tflint /usr/bin/
416+
# Managed with COPY --link --from=tflint /usr/local/bin/tflint /usr/bin/
416417

417418
# terrascan installation
418-
# Managed with COPY --from=terrascan /go/bin/terrascan /usr/bin/
419+
# Managed with COPY --link --from=terrascan /go/bin/terrascan /usr/bin/
419420

420421
# terragrunt installation
421-
# Managed with COPY --from=terragrunt /usr/local/bin/terragrunt /usr/bin/
422+
# Managed with COPY --link --from=terragrunt /usr/local/bin/terragrunt /usr/bin/
422423

423424
# terraform-fmt installation
424-
# Managed with COPY --from=terragrunt /bin/terraform /usr/bin/
425+
# Managed with COPY --link --from=terragrunt /bin/terraform /usr/bin/
425426

426427
# kics installation
427-
# Managed with COPY --from=kics /app/bin/kics /usr/bin/
428+
# Managed with COPY --link --from=kics /app/bin/kics /usr/bin/
428429
&& mkdir -p /opt/kics/assets
429430
ENV KICS_QUERIES_PATH=/opt/kics/assets/queries KICS_LIBRARIES_PATH=/opt/kics/assets/libraries
430431
# Managed with COPY --from=kics /app/bin/assets /opt/kics/assets/

0 commit comments

Comments
 (0)