Skip to content

Commit 56b337b

Browse files
authored
Use ghcr.io images by default + podman option on mega-linter-runner (#5874)
* init * Migrates to ghcr.io container registry Updates the docker image registry from docker://oxsecurity to ghcr.io/oxsecurity. This ensures better discoverability and management of the MegaLinter images. A new documentation file listing all the standalone linters and their docker images is added. * Updates Docker image badge links Updates the Docker image badge and pull count links in the generated documentation to remove the redundant host prefix from the image name. This change ensures the badge links point to the correct Docker Hub repository, improving the accuracy and usability of the documentation. * Updates linters and documentation Updates linter versions for groovy-lint, java-pmd, repository-trufflehog, and snakemake. Corrects broken links in documentation for disabled linters and updates powershell CLI executable. Adds Docker Hub image links to flavor documentation and provides documentation on custom flavors. * Updates default Docker image location Updates the default Docker image location to the GitHub Container Registry (ghcr.io). This change ensures that the correct image is pulled, especially for the default `oxsecurity/megalinter` image, improving image availability and reliability. * Adds podman support Enables the use of podman as a container engine, providing an alternative to docker. Updates the runner to use ghcr.io docker images by default. Adds a new parameter `--container-engine` to specify either docker or podman as the container runner. * Adds option to specify container engine Adds a new `--container-engine` option to allow users to specify the Docker engine (`docker` or `podman`) to be used. This provides more flexibility and control over the container runtime environment. * Adds ML_DOCKER_NAME to constants Adds the ML_DOCKER_NAME constant to the megalinter constants file. This constant is likely needed for referencing the Docker image name within the automation scripts or other parts of the codebase. * Fix syntax error by adding missing semicolon for containerEngine declaration * Update options * Initializes containerEngine in constructor The `containerEngine` property was previously being initialized outside of the constructor, which is not best practice. This commit updates the code to initialize `containerEngine` within the constructor for better code organization and clarity. * [MegaLinter] Apply linters fixes * Validates container engine selection Removes the class constructor and validates the container engine value directly within the `run` method. This ensures that the container engine is validated before proceeding with the MegaLinter execution. --------- Co-authored-by: nvuillam <[email protected]>
1 parent c92b823 commit 56b337b

Some content is hidden

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

53 files changed

+367
-218
lines changed

.automation/build.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@
4242
DEFAULT_DOCKERFILE_RUST_ARGS,
4343
DEFAULT_RELEASE,
4444
DEFAULT_REPORT_FOLDER_NAME,
45+
DOCKER_PACKAGES_ROOT_URL,
46+
GHCR_PACKAGES_ROOT_URL,
4547
ML_DOC_URL_BASE,
4648
ML_DOCKER_IMAGE,
4749
ML_DOCKER_IMAGE_LEGACY,
4850
ML_DOCKER_IMAGE_LEGACY_V5,
51+
ML_DOCKER_IMAGE_WITH_HOST,
52+
ML_DOCKER_NAME,
4953
ML_REPO,
5054
ML_REPO_URL,
5155
)
@@ -229,7 +233,7 @@ def generate_flavor(flavor, flavor_info):
229233
description: "0 if no source file has been updated, 1 if source files has been updated"
230234
runs:
231235
using: "docker"
232-
image: "docker://{ML_DOCKER_IMAGE}:{image_release}"
236+
image: "docker://{ML_DOCKER_IMAGE_WITH_HOST}:{image_release}"
233237
args:
234238
- "-v"
235239
- "/var/run/docker.sock:/var/run/docker.sock:rw"
@@ -293,7 +297,7 @@ def generate_flavor(flavor, flavor_info):
293297
description: "0 if no source file has been updated, 1 if source files has been updated"
294298
runs:
295299
using: "docker"
296-
image: "docker://{ML_DOCKER_IMAGE}-{flavor}:{image_release}"
300+
image: "docker://{ML_DOCKER_IMAGE_WITH_HOST}-{flavor}:{image_release}"
297301
args:
298302
- "-v"
299303
- "/var/run/docker.sock:/var/run/docker.sock:rw"
@@ -808,7 +812,9 @@ def generate_linter_dockerfiles():
808812
dockerfile, descriptor_and_linter, requires_docker, "none", extra_lines
809813
)
810814
gha_workflow_yml += [f' "{linter_lower_name}",']
811-
docker_image = f"{ML_DOCKER_IMAGE}-only-{linter_lower_name}:{VERSION_V}"
815+
docker_image = (
816+
f"{ML_DOCKER_IMAGE_WITH_HOST}-only-{linter_lower_name}:{VERSION_V}"
817+
)
812818
docker_image_badge = (
813819
f"![Docker Image Size (tag)]({BASE_SHIELD_IMAGE_LINK}/"
814820
f"{ML_DOCKER_IMAGE}-only-{linter_lower_name}/{VERSION_V})"
@@ -1161,13 +1167,16 @@ def generate_descriptor_documentation(descriptor):
11611167

11621168
def generate_flavor_documentation(flavor_id, flavor, linters_tables_md):
11631169
flavor_github_action = f"{ML_REPO}/flavors/{flavor_id}@{VERSION_V}"
1164-
flavor_docker_image = f"{ML_DOCKER_IMAGE}-{flavor_id}:{VERSION_V}"
1170+
flavor_docker_image = f"{ML_DOCKER_IMAGE_WITH_HOST}-{flavor_id}:{VERSION_V}"
1171+
flavor_docker_image_dockerhub = (
1172+
f"docker.io/{ML_DOCKER_IMAGE}-{flavor_id}:{VERSION_V}"
1173+
)
11651174
docker_image_badge = (
11661175
f"![Docker Image Size (tag)]({BASE_SHIELD_IMAGE_LINK}/"
11671176
f"{ML_DOCKER_IMAGE}-{flavor_id}/{VERSION_V})"
11681177
)
11691178
docker_pulls_badge = (
1170-
f"![Docker Pulls]({BASE_SHIELD_COUNT_LINK}/" f"{ML_DOCKER_IMAGE}-{flavor_id})"
1179+
f"![Docker Pulls]({BASE_SHIELD_COUNT_LINK}/{ML_DOCKER_IMAGE}-{flavor_id})"
11711180
)
11721181
flavor_doc_md = [
11731182
"---",
@@ -1187,7 +1196,12 @@ def generate_flavor_documentation(flavor_id, flavor, linters_tables_md):
11871196
"## Usage",
11881197
"",
11891198
f"- [GitHub Action]({MKDOCS_URL_ROOT}/installation/#github-action): **{flavor_github_action}**",
1190-
f"- Docker image: **{flavor_docker_image}**",
1199+
"",
1200+
"- Docker images:",
1201+
"",
1202+
f" - GitHub Packages: **{flavor_docker_image}**",
1203+
f" - Docker Hub: **{flavor_docker_image_dockerhub}**",
1204+
"",
11911205
f"- [mega-linter-runner]({MKDOCS_URL_ROOT}/mega-linter-runner/): `mega-linter-runner --flavor {flavor_id}`",
11921206
"",
11931207
"## Embedded linters",
@@ -2003,9 +2017,7 @@ def build_flavors_md_table(filter_linter_name=None, replace_link=False):
20032017
+ +len(linters_by_type["other"])
20042018
)
20052019
docker_image_badge = f"![Docker Image Size (tag)]({BASE_SHIELD_IMAGE_LINK}/{ML_DOCKER_IMAGE}/{VERSION_V})"
2006-
docker_pulls_badge = (
2007-
f"![Docker Pulls]({BASE_SHIELD_COUNT_LINK}/" f"{ML_DOCKER_IMAGE})"
2008-
)
2020+
docker_pulls_badge = f"![Docker Pulls]({BASE_SHIELD_COUNT_LINK}/{ML_DOCKER_IMAGE})"
20092021
md_line_all = (
20102022
f"| {icon_html} | [all]({MKDOCS_URL_ROOT}/supported-linters/) | "
20112023
f"Default MegaLinter Flavor | {str(linters_number)} | {docker_image_badge} {docker_pulls_badge} |"
@@ -2106,29 +2118,32 @@ def update_docker_pulls_counter():
21062118
now_str = datetime.now().replace(microsecond=0).isoformat()
21072119
for flavor_id in all_flavors_ids:
21082120
if flavor_id == "all":
2109-
docker_image_url = (
2110-
f"https://hub.docker.com/v2/repositories/{ML_DOCKER_IMAGE}"
2111-
)
2121+
ghcr_image_url = f"{GHCR_PACKAGES_ROOT_URL}/{ML_DOCKER_NAME}"
2122+
docker_image_url = f"{DOCKER_PACKAGES_ROOT_URL}/{ML_DOCKER_IMAGE}"
21122123
legacy_docker_image_url = (
2113-
f"https://hub.docker.com/v2/repositories/{ML_DOCKER_IMAGE_LEGACY}"
2124+
f"{DOCKER_PACKAGES_ROOT_URL}/{ML_DOCKER_IMAGE_LEGACY}"
21142125
)
21152126
legacy_v5_docker_image_url = (
2116-
f"https://hub.docker.com/v2/repositories/{ML_DOCKER_IMAGE_LEGACY_V5}"
2127+
f"{DOCKER_PACKAGES_ROOT_URL}/{ML_DOCKER_IMAGE_LEGACY_V5}"
21172128
)
21182129
else:
2130+
ghcr_image_url = f"{GHCR_PACKAGES_ROOT_URL}/{ML_DOCKER_NAME}-{flavor_id}"
21192131
docker_image_url = (
2120-
f"https://hub.docker.com/v2/repositories/{ML_DOCKER_IMAGE}-{flavor_id}"
2132+
f"{DOCKER_PACKAGES_ROOT_URL}/{ML_DOCKER_IMAGE}-{flavor_id}"
2133+
)
2134+
legacy_docker_image_url = (
2135+
f"{DOCKER_PACKAGES_ROOT_URL}/{ML_DOCKER_IMAGE_LEGACY}-{flavor_id}"
21212136
)
2122-
legacy_docker_image_url = f"https://hub.docker.com/v2/repositories/{ML_DOCKER_IMAGE_LEGACY}-{flavor_id}"
21232137
legacy_v5_docker_image_url = (
2124-
"https://hub.docker.com/v2/repositories/"
2138+
f"{DOCKER_PACKAGES_ROOT_URL}/"
21252139
+ f"{ML_DOCKER_IMAGE_LEGACY_V5}-{flavor_id}"
21262140
)
21272141

2142+
flavor_count_0 = perform_count_request(ghcr_image_url)
21282143
flavor_count_1 = perform_count_request(docker_image_url)
21292144
flavor_count_2 = perform_count_request(legacy_docker_image_url)
21302145
flavor_count_3 = perform_count_request(legacy_v5_docker_image_url)
2131-
flavor_count = flavor_count_1 + flavor_count_2 + flavor_count_3
2146+
flavor_count = flavor_count_0 + flavor_count_1 + flavor_count_2 + flavor_count_3
21322147
logging.info(f"- docker pulls for {flavor_id}: {flavor_count}")
21332148
total_count = total_count + flavor_count
21342149
flavor_stats = list(docker_stats.get(flavor_id, []))

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
1717
- Console Reporter
1818
- Text Reporter
1919
- Git platforms PR/MR comments Reporter
20+
- Use ghcr.io docker images by default because of rate limits on docker.io
2021
- Use uv to create the venv folder for pip-installed linters
2122
- Add copilot instructions for GitHub Copilot
2223

@@ -57,6 +58,8 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
5758

5859
- mega-linter-runner
5960
- Add all CI/CD providers in the --install command
61+
- Use ghcr.io docker images by default
62+
- New parameter **--container-engine** allowing to use **podman** as runner.
6063

6164
- Linter versions upgrades (N)
6265
- [mypy](https://mypy.readthedocs.io/en/stable/) from 1.16.0 to **1.16.1** on 2025-06-16

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ outputs:
77
description: "0 if no source file has been updated, 1 if source files has been updated"
88
runs:
99
using: "docker"
10-
image: "docker://oxsecurity/megalinter:v8.8.0"
10+
image: "docker://ghcr.io/oxsecurity/megalinter:v8.8.0"
1111
args:
1212
- "-v"
1313
- "/var/run/docker.sock:/var/run/docker.sock:rw"

docs/descriptors/groovy_npm_groovy_lint.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ Note: command-line arguments have priority on config file properties - default:
165165
```dockerfile
166166
ENV JAVA_HOME_17=/usr/lib/jvm/java-17-openjdk
167167
# renovate: datasource=npm depName=npm-groovy-lint
168-
ARG NPM_GROOVY_LINT_VERSION=15.2.0
168+
ARG NPM_GROOVY_LINT_VERSION=15.2.1
169169
```
170170
171171
- APK packages (Linux):
172172
- [openjdk17](https://pkgs.alpinelinux.org/packages?branch=v3.21&arch=x86_64&name=openjdk17)
173173
- NPM packages (node.js):
174-
- [[email protected].0](https://www.npmjs.com/package/npm-groovy-lint/v/15.2.0)
174+
- [[email protected].1](https://www.npmjs.com/package/npm-groovy-lint/v/15.2.1)

docs/descriptors/java_pmd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk
120120
ENV PATH="$JAVA_HOME/bin:${PATH}"
121121
# Linter install
122122
# renovate: datasource=github-tags depName=pmd/pmd extractVersion=^pmd_releases/(?<version>.*)$
123-
ARG PMD_VERSION=7.15.0
123+
ARG PMD_VERSION=7.16.0
124124

125125
RUN wget --quiet https://github.com/pmd/pmd/releases/download/pmd_releases%2F${PMD_VERSION}/pmd-dist-${PMD_VERSION}-bin.zip && \
126126
unzip pmd-dist-${PMD_VERSION}-bin.zip || echo "Error unzipping" && \

docs/descriptors/powershell_powershell.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ description: How to use powershell (configure, ignore files, ignore errors, help
5353
| POWERSHELL_POWERSHELL_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
5454
| POWERSHELL_POWERSHELL_DISABLE_ERRORS | Run linter but consider errors as warnings | `false` |
5555
| POWERSHELL_POWERSHELL_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
56-
| POWERSHELL_POWERSHELL_CLI_EXECUTABLE | Override CLI executable | `['pwsh']` |
56+
| POWERSHELL_POWERSHELL_CLI_EXECUTABLE | Override CLI executable | `['powershell']` |
5757

5858
## IDE Integration
5959

docs/descriptors/powershell_powershell_formatter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ description: How to use powershell_formatter (configure, ignore files, ignore er
5252
| POWERSHELL_POWERSHELL_FORMATTER_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
5353
| POWERSHELL_POWERSHELL_FORMATTER_DISABLE_ERRORS | Run linter but consider errors as warnings | `true` |
5454
| POWERSHELL_POWERSHELL_FORMATTER_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | `0` |
55-
| POWERSHELL_POWERSHELL_FORMATTER_CLI_EXECUTABLE | Override CLI executable | `['pwsh']` |
55+
| POWERSHELL_POWERSHELL_FORMATTER_CLI_EXECUTABLE | Override CLI executable | `['powershell']` |
5656

5757
## IDE Integration
5858

docs/descriptors/repository_trufflehog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ analyze
241241
- Dockerfile commands :
242242
```dockerfile
243243
# renovate: datasource=docker depName=trufflesecurity/trufflehog
244-
ARG REPOSITORY_TRUFFLEHOG_VERSION=3.90.1
244+
ARG REPOSITORY_TRUFFLEHOG_VERSION=3.90.2
245245
FROM trufflesecurity/trufflehog:${REPOSITORY_TRUFFLEHOG_VERSION} AS trufflehog
246246
COPY --link --from=trufflehog /usr/bin/trufflehog /usr/bin/
247247
```

docs/descriptors/snakemake_snakemake.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,8 @@ defaults.
10581058
- Dockerfile commands :
10591059
```dockerfile
10601060
# renovate: datasource=pypi depName=snakemake
1061-
ARG PIP_SNAKEMAKE_VERSION=9.8.1
1061+
ARG PIP_SNAKEMAKE_VERSION=9.8.2
10621062
```
10631063
10641064
- PIP packages (Python):
1065-
- [snakemake==9.8.1](https://pypi.org/project/snakemake/9.8.1)
1065+
- [snakemake==9.8.2](https://pypi.org/project/snakemake/9.8.2)

docs/flavors.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ _The following table doesn't display docker pulls from [MegaLinter v4 & v5 image
4141

4242
If you need a new flavor, [post an issue](https://github.com/oxsecurity/megalinter/issues) :wink:
4343

44+
You can also generate your own [Custom Flavors](https://megalinter.io/beta/custom-flavors/) to have exactly the linters you need in your MegaLinter Docker image
45+
4446

4547
<!-- flavors-section-end -->

0 commit comments

Comments
 (0)