diff --git a/.automation/build.py b/.automation/build.py index 313970dd437..6f41a0bed6c 100644 --- a/.automation/build.py +++ b/.automation/build.py @@ -3286,6 +3286,14 @@ def generate_version(): ) print(process.stdout) print(process.stderr) + # Update python project version: + process = subprocess.run( + ["hatch", "version", RELEASE_TAG], + stdout=subprocess.PIPE, + text=True, + shell=True, + check=False, + ) # Update changelog if UPDATE_CHANGELOG is True: changelog_file = f"{REPO_HOME}/CHANGELOG.md" diff --git a/.automation/test/python_mypy/pyproject.toml b/.automation/test/python_mypy/pyproject.toml new file mode 100644 index 00000000000..4910886128a --- /dev/null +++ b/.automation/test/python_mypy/pyproject.toml @@ -0,0 +1 @@ +[tool.pyright] diff --git a/.config/make/python.mak b/.config/make/python.mak index 548bb51a873..cb3b9c8453e 100644 --- a/.config/make/python.mak +++ b/.config/make/python.mak @@ -1,6 +1,5 @@ # Python default launcher python_launcher ?= python3.11 -python_requirements_file ?= .config/python/dev/requirements.txt python_requirements_dev_file ?= .config/python/dev/requirements.txt UV = $(shell command -v uv 2> /dev/null) @@ -10,7 +9,7 @@ UV = $(shell command -v uv 2> /dev/null) python-bootstrap: ## Bootstrap python $(MAKE) python-venv-init $(MAKE) python-venv-upgrade - $(MAKE) python-venv-requirements + $(MAKE) python-venv-editable-install .PHONY: python-bootstrap-dev python-bootstrap-dev: ## Bootstrap python for dev env @@ -33,22 +32,22 @@ else endif .PHONY: python-venv-upgrade -python-venv-upgrade: ## Upgrade venv with pip, setuptools and wheel +python-venv-upgrade: ## Upgrade venv with pip ifeq ($(strip $(UV)),) source .venv/bin/activate - pip install --upgrade pip setuptools wheel + pip install --upgrade pip else - $(UV) pip install --upgrade pip setuptools wheel + $(UV) pip install --upgrade pip endif -.PHONY: python-venv-requirements -python-venv-requirements: ## Install or upgrade from $(python_requirements_file) +.PHONY: python-venv-editable-install +python-venv-editable-install: ## Install or upgrade from local project's pyproject.toml ifeq ($(strip $(UV)),) source .venv/bin/activate - pip install --upgrade --requirement $(python_requirements_file) + pip install --upgrade -e . else - $(UV) pip install --upgrade --requirement $(python_requirements_file) + $(UV) pip install --upgrade -e . endif .PHONY: python-venv-requirements-dev diff --git a/.cspell.json b/.cspell.json index 8df55a537d0..30716e1d968 100644 --- a/.cspell.json +++ b/.cspell.json @@ -715,6 +715,7 @@ "displaymath", "distutils", "djlint", + "dmypy", "dockerfilelint", "dockerfilelintrc", "dockerignore", @@ -881,6 +882,7 @@ "holdy", "hprof", "hsts", + "htmlcov", "htmlhint", "htmlhintrc", "htmlout", @@ -1104,6 +1106,7 @@ "norionomura", "normalsize", "noserver", + "nosetests", "nostic", "nosw", "notemp", @@ -1318,6 +1321,7 @@ "scolladon", "scriptsize", "scshape", + "sdist", "seaneagan", "secretlint", "secretlintrc", @@ -1540,4 +1544,4 @@ "zaach", "zricethezav" ] -} \ No newline at end of file +} diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ea3e3653d58..a8188d03f1f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -119,17 +119,15 @@ In order to be able to run locally a server that serves all the documentation an Commands to execute (only one time): ```bash -mkdir venv -python -m venv venv/ -source venv/bin/activate -pip install --upgrade -r .config/python/dev/requirements.txt +pip install pipx +pipx install hatch +hatch shell ``` -Commands to run every time you want to enter the environment and run the server: +Commands to run every time you want to build the docs and run the server: ```bash -source venv/bin/activate -mkdocs serve +hatch run build:serve ``` By default it listens on `http://127.0.0.1:8000/`. diff --git a/.gitignore b/.gitignore index f59f7e67f1f..db57e79e746 100644 --- a/.gitignore +++ b/.gitignore @@ -99,6 +99,7 @@ coverage.xml !**/salesforce/good/report/* !**/salesforce/bad/report/* +# mkdocs documentation site/ .sfdx/ @@ -126,4 +127,73 @@ server/server-files/ .venv *megalinter_file_names_cspell.txt -.DS_Store \ No newline at end of file +.DS_Store + +################################ +# Python: +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 49d592f5934..81d1d677af0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image - Core + - Replace usage of setup.py with a pyproject.toml package install, by @echoix in [#3893](https://github.com/oxsecurity/megalinter/pull/3893) - Media diff --git a/Dockerfile b/Dockerfile index 26bd7c66ad7..6d3c8642c40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -75,6 +75,20 @@ FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt # FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -792,11 +806,11 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/Dockerfile-quick b/Dockerfile-quick index 0fc871d22a2..88fbc754fd4 100644 --- a/Dockerfile-quick +++ b/Dockerfile-quick @@ -9,7 +9,26 @@ ################## ARG GITHUB_TOKEN ARG MEGALINTER_BASE_IMAGE=oxsecurity/megalinter:beta -FROM $MEGALINTER_BASE_IMAGE +FROM $MEGALINTER_BASE_IMAGE as base + +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + +####################### +# Continue base image # +####################### +FROM base ###################### # Set the entrypoint # @@ -21,10 +40,12 @@ ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN python /megalinter/setup.py install \ - && python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . + ####################################### # Copy scripts and rules to container # ####################################### diff --git a/flavors/c_cpp/Dockerfile b/flavors/c_cpp/Dockerfile index 6e2013370b3..4318be9936b 100644 --- a/flavors/c_cpp/Dockerfile +++ b/flavors/c_cpp/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -321,11 +335,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/ci_light/Dockerfile b/flavors/ci_light/Dockerfile index a260abc8f06..45c94ef9b68 100644 --- a/flavors/ci_light/Dockerfile +++ b/flavors/ci_light/Dockerfile @@ -33,6 +33,20 @@ FROM zricethezav/gitleaks:${REPOSITORY_GITLEAKS_VERSION} AS gitleaks FROM trufflesecurity/trufflehog:${REPOSITORY_TRUFFLEHOG_VERSION} AS trufflehog #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -215,11 +229,11 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/cupcake/Dockerfile b/flavors/cupcake/Dockerfile index 108c6339d79..62698291d6f 100644 --- a/flavors/cupcake/Dockerfile +++ b/flavors/cupcake/Dockerfile @@ -67,6 +67,20 @@ FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt # FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -535,11 +549,11 @@ RUN wget --tries=5 -q -O - https://raw.githubusercontent.com/aquasecurity/trivy/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/documentation/Dockerfile b/flavors/documentation/Dockerfile index d6a6b0ca446..399514e906b 100644 --- a/flavors/documentation/Dockerfile +++ b/flavors/documentation/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -318,11 +332,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/dotnet/Dockerfile b/flavors/dotnet/Dockerfile index f9733c13e2b..3ed7710d23f 100644 --- a/flavors/dotnet/Dockerfile +++ b/flavors/dotnet/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -383,11 +397,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/dotnetweb/Dockerfile b/flavors/dotnetweb/Dockerfile index 9cac8871130..6bea7c13f28 100644 --- a/flavors/dotnetweb/Dockerfile +++ b/flavors/dotnetweb/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -405,11 +419,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/formatters/Dockerfile b/flavors/formatters/Dockerfile index 78f8041faa1..dfbdba2e30b 100644 --- a/flavors/formatters/Dockerfile +++ b/flavors/formatters/Dockerfile @@ -24,6 +24,20 @@ FROM mvdan/shfmt:latest-alpine AS shfmt FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -198,11 +212,11 @@ RUN curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/po ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/go/Dockerfile b/flavors/go/Dockerfile index 52d2d9232e1..1482c4f3574 100644 --- a/flavors/go/Dockerfile +++ b/flavors/go/Dockerfile @@ -59,6 +59,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -335,11 +349,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/java/Dockerfile b/flavors/java/Dockerfile index 15973f80d9b..84310e5683a 100644 --- a/flavors/java/Dockerfile +++ b/flavors/java/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -394,11 +408,11 @@ RUN wget --quiet https://github.com/pmd/pmd/releases/download/pmd_releases%2F${P ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/javascript/Dockerfile b/flavors/javascript/Dockerfile index a360ec0c6e8..99596fd896f 100644 --- a/flavors/javascript/Dockerfile +++ b/flavors/javascript/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -342,11 +356,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/php/Dockerfile b/flavors/php/Dockerfile index 527596eec2b..f365aacacba 100644 --- a/flavors/php/Dockerfile +++ b/flavors/php/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -371,11 +385,11 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/python/Dockerfile b/flavors/python/Dockerfile index 9a2abd7c131..a90c137051d 100644 --- a/flavors/python/Dockerfile +++ b/flavors/python/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -333,11 +347,11 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/ruby/Dockerfile b/flavors/ruby/Dockerfile index b90f6f6ba03..edf1756a251 100644 --- a/flavors/ruby/Dockerfile +++ b/flavors/ruby/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -329,11 +343,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/rust/Dockerfile b/flavors/rust/Dockerfile index 843c5d948a9..4bdbd2ab5c4 100644 --- a/flavors/rust/Dockerfile +++ b/flavors/rust/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -318,11 +332,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/salesforce/Dockerfile b/flavors/salesforce/Dockerfile index 14b21cdd4f7..f41a11e8b69 100644 --- a/flavors/salesforce/Dockerfile +++ b/flavors/salesforce/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -363,11 +377,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/security/Dockerfile b/flavors/security/Dockerfile index ef42749ed20..069ec28b2d6 100644 --- a/flavors/security/Dockerfile +++ b/flavors/security/Dockerfile @@ -49,6 +49,20 @@ FROM tenable/terrascan:${TERRAFORM_TERRASCAN_VERSION} AS terrascan FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -260,11 +274,11 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/swift/Dockerfile b/flavors/swift/Dockerfile index c223ff02841..1383d3629ce 100644 --- a/flavors/swift/Dockerfile +++ b/flavors/swift/Dockerfile @@ -52,6 +52,20 @@ FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -321,11 +335,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/flavors/terraform/Dockerfile b/flavors/terraform/Dockerfile index f85f194773d..47db375fb40 100644 --- a/flavors/terraform/Dockerfile +++ b/flavors/terraform/Dockerfile @@ -66,6 +66,20 @@ FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt # FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -355,11 +369,11 @@ RUN wget --tries=5 -q -O - https://raw.githubusercontent.com/aquasecurity/trivy/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/action_actionlint/Dockerfile b/linters/action_actionlint/Dockerfile index 8c16588538f..29e1d523b31 100644 --- a/linters/action_actionlint/Dockerfile +++ b/linters/action_actionlint/Dockerfile @@ -26,6 +26,20 @@ FROM rhysd/actionlint:${ACTION_ACTIONLINT_VERSION} AS actionlint FROM koalaman/shellcheck:${BASH_SHELLCHECK_VERSION} AS shellcheck #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -145,11 +159,11 @@ COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/ansible_ansible_lint/Dockerfile b/linters/ansible_ansible_lint/Dockerfile index d9288ffedca..95ebaa72b80 100644 --- a/linters/ansible_ansible_lint/Dockerfile +++ b/linters/ansible_ansible_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/api_spectral/Dockerfile b/linters/api_spectral/Dockerfile index 144614e5291..137f4c2f872 100644 --- a/linters/api_spectral/Dockerfile +++ b/linters/api_spectral/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/arm_arm_ttk/Dockerfile b/linters/arm_arm_ttk/Dockerfile index 6998fbee738..f86960e3c99 100644 --- a/linters/arm_arm_ttk/Dockerfile +++ b/linters/arm_arm_ttk/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -152,11 +166,11 @@ RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/bash_exec/Dockerfile b/linters/bash_exec/Dockerfile index a0b4480d35f..73d49c2beac 100644 --- a/linters/bash_exec/Dockerfile +++ b/linters/bash_exec/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ RUN printf '#!/bin/bash \n\nif [[ -x "$1" ]]; then exit 0; else echo "Error: Fil ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/bash_shellcheck/Dockerfile b/linters/bash_shellcheck/Dockerfile index 1882260110b..e7df6479698 100644 --- a/linters/bash_shellcheck/Dockerfile +++ b/linters/bash_shellcheck/Dockerfile @@ -22,6 +22,20 @@ ARG BASH_SHELLCHECK_VERSION=v0.10.0 FROM koalaman/shellcheck:${BASH_SHELLCHECK_VERSION} AS shellcheck #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -140,11 +154,11 @@ COPY --link --from=shellcheck /bin/shellcheck /usr/bin/shellcheck ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/bash_shfmt/Dockerfile b/linters/bash_shfmt/Dockerfile index 5bd1534cf81..73c2592a4d1 100644 --- a/linters/bash_shfmt/Dockerfile +++ b/linters/bash_shfmt/Dockerfile @@ -21,6 +21,20 @@ FROM mvdan/shfmt:latest-alpine AS shfmt #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -135,11 +149,11 @@ COPY --link --from=shfmt /bin/shfmt /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/bicep_bicep_linter/Dockerfile b/linters/bicep_bicep_linter/Dockerfile index 3a53c82ce72..dc50376a8c7 100644 --- a/linters/bicep_bicep_linter/Dockerfile +++ b/linters/bicep_bicep_linter/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -141,11 +155,11 @@ RUN curl --retry 5 --retry-delay 5 -sLo ${BICEP_EXE} "${BICEP_URI}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/c_clang_format/Dockerfile b/linters/c_clang_format/Dockerfile index 2552bf22de0..607f6f19874 100644 --- a/linters/c_clang_format/Dockerfile +++ b/linters/c_clang_format/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -134,11 +148,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/c_cpplint/Dockerfile b/linters/c_cpplint/Dockerfile index f2be11c26ce..e4781566f7b 100644 --- a/linters/c_cpplint/Dockerfile +++ b/linters/c_cpplint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/clojure_clj_kondo/Dockerfile b/linters/clojure_clj_kondo/Dockerfile index ab315e357c3..8ae57303142 100644 --- a/linters/clojure_clj_kondo/Dockerfile +++ b/linters/clojure_clj_kondo/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -180,11 +194,11 @@ RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/clojure_cljstyle/Dockerfile b/linters/clojure_cljstyle/Dockerfile index 702b6782949..dda151e0bb8 100644 --- a/linters/clojure_cljstyle/Dockerfile +++ b/linters/clojure_cljstyle/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -180,11 +194,11 @@ RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/cloudformation_cfn_lint/Dockerfile b/linters/cloudformation_cfn_lint/Dockerfile index 705a32858b2..6dee428a3a4 100644 --- a/linters/cloudformation_cfn_lint/Dockerfile +++ b/linters/cloudformation_cfn_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/coffee_coffeelint/Dockerfile b/linters/coffee_coffeelint/Dockerfile index 95b63c8f97c..6b193d542e9 100644 --- a/linters/coffee_coffeelint/Dockerfile +++ b/linters/coffee_coffeelint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/copypaste_jscpd/Dockerfile b/linters/copypaste_jscpd/Dockerfile index d7e6fe0de2a..768f8eb3715 100644 --- a/linters/copypaste_jscpd/Dockerfile +++ b/linters/copypaste_jscpd/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -147,11 +161,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/cpp_clang_format/Dockerfile b/linters/cpp_clang_format/Dockerfile index dbb988bd028..bdf813d4876 100644 --- a/linters/cpp_clang_format/Dockerfile +++ b/linters/cpp_clang_format/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -134,11 +148,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/cpp_cpplint/Dockerfile b/linters/cpp_cpplint/Dockerfile index 67e89d1fef4..07534df92a9 100644 --- a/linters/cpp_cpplint/Dockerfile +++ b/linters/cpp_cpplint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/csharp_csharpier/Dockerfile b/linters/csharp_csharpier/Dockerfile index a3cd6ce0c63..e33729e0df7 100644 --- a/linters/csharp_csharpier/Dockerfile +++ b/linters/csharp_csharpier/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -139,11 +153,11 @@ RUN dotnet tool install --global csharpier ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/csharp_dotnet_format/Dockerfile b/linters/csharp_dotnet_format/Dockerfile index de37357b629..31f969d8fc6 100644 --- a/linters/csharp_dotnet_format/Dockerfile +++ b/linters/csharp_dotnet_format/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ ENV PATH="${PATH}:/root/.dotnet/tools" ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/csharp_roslynator/Dockerfile b/linters/csharp_roslynator/Dockerfile index 059fd82b785..17e1d375f88 100644 --- a/linters/csharp_roslynator/Dockerfile +++ b/linters/csharp_roslynator/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -139,11 +153,11 @@ RUN dotnet tool install -g roslynator.dotnet.cli ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/css_stylelint/Dockerfile b/linters/css_stylelint/Dockerfile index 92d93014915..63a10cdff8b 100644 --- a/linters/css_stylelint/Dockerfile +++ b/linters/css_stylelint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -149,11 +163,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/dart_dartanalyzer/Dockerfile b/linters/dart_dartanalyzer/Dockerfile index 07ab06a4bda..b5e99fa8839 100644 --- a/linters/dart_dartanalyzer/Dockerfile +++ b/linters/dart_dartanalyzer/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -181,11 +195,11 @@ RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/dockerfile_hadolint/Dockerfile b/linters/dockerfile_hadolint/Dockerfile index d48c365cc57..19ee943dfe4 100644 --- a/linters/dockerfile_hadolint/Dockerfile +++ b/linters/dockerfile_hadolint/Dockerfile @@ -22,6 +22,20 @@ ARG DOCKERFILE_HADOLINT_VERSION=v2.12.0-alpine FROM hadolint/hadolint:${DOCKERFILE_HADOLINT_VERSION} AS hadolint #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=hadolint /bin/hadolint /usr/bin/hadolint ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/editorconfig_editorconfig_checker/Dockerfile b/linters/editorconfig_editorconfig_checker/Dockerfile index eadf35ace90..4a356f0eed0 100644 --- a/linters/editorconfig_editorconfig_checker/Dockerfile +++ b/linters/editorconfig_editorconfig_checker/Dockerfile @@ -22,6 +22,20 @@ ARG EDITORCONFIG_EDITORCONFIG_CHECKER_VERSION=v3.0.3 FROM mstruebing/editorconfig-checker:${EDITORCONFIG_EDITORCONFIG_CHECKER_VERSION} AS editorconfig-checker #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=editorconfig-checker /usr/bin/ec /usr/bin/editorconfig-checke ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/env_dotenv_linter/Dockerfile b/linters/env_dotenv_linter/Dockerfile index 65473ccd09a..ef00769f4d5 100644 --- a/linters/env_dotenv_linter/Dockerfile +++ b/linters/env_dotenv_linter/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -135,11 +149,11 @@ RUN wget -q -O - https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/m ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/gherkin_gherkin_lint/Dockerfile b/linters/gherkin_gherkin_lint/Dockerfile index aade500b3ff..e257c6deb0f 100644 --- a/linters/gherkin_gherkin_lint/Dockerfile +++ b/linters/gherkin_gherkin_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/go_golangci_lint/Dockerfile b/linters/go_golangci_lint/Dockerfile index 86d6e9a114f..3fbfca4c116 100644 --- a/linters/go_golangci_lint/Dockerfile +++ b/linters/go_golangci_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -138,11 +152,11 @@ RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/go_revive/Dockerfile b/linters/go_revive/Dockerfile index ab464d8706a..1f85c93aae0 100644 --- a/linters/go_revive/Dockerfile +++ b/linters/go_revive/Dockerfile @@ -27,6 +27,20 @@ ARG GO_REVIVE_VERSION=v1.3.9 RUN GOBIN=/usr/bin go install github.com/mgechev/revive@$GO_REVIVE_VERSION #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -142,11 +156,11 @@ COPY --link --from=revive /usr/bin/revive /usr/bin/revive ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/graphql_graphql_schema_linter/Dockerfile b/linters/graphql_graphql_schema_linter/Dockerfile index d5484db5cd6..3156d6fd61d 100644 --- a/linters/graphql_graphql_schema_linter/Dockerfile +++ b/linters/graphql_graphql_schema_linter/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -147,11 +161,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/groovy_npm_groovy_lint/Dockerfile b/linters/groovy_npm_groovy_lint/Dockerfile index c0a8b336d07..af4a6473307 100644 --- a/linters/groovy_npm_groovy_lint/Dockerfile +++ b/linters/groovy_npm_groovy_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -149,11 +163,11 @@ ENV JAVA_HOME_17=/usr/lib/jvm/java-17-openjdk ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/html_djlint/Dockerfile b/linters/html_djlint/Dockerfile index f35e13d5a60..f668fea4a89 100644 --- a/linters/html_djlint/Dockerfile +++ b/linters/html_djlint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/html_htmlhint/Dockerfile b/linters/html_htmlhint/Dockerfile index 6ad144a80c8..d9cff0d947a 100644 --- a/linters/html_htmlhint/Dockerfile +++ b/linters/html_htmlhint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/java_checkstyle/Dockerfile b/linters/java_checkstyle/Dockerfile index 56fde4f8810..38bcb5efab7 100644 --- a/linters/java_checkstyle/Dockerfile +++ b/linters/java_checkstyle/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -149,11 +163,11 @@ RUN --mount=type=secret,id=GITHUB_TOKEN CHECKSTYLE_LATEST=$(curl -s \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/java_pmd/Dockerfile b/linters/java_pmd/Dockerfile index d7735795930..ed88be913a5 100644 --- a/linters/java_pmd/Dockerfile +++ b/linters/java_pmd/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -147,11 +161,11 @@ RUN wget --quiet https://github.com/pmd/pmd/releases/download/pmd_releases%2F${P ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/javascript_es/Dockerfile b/linters/javascript_es/Dockerfile index 77c6a5ee263..03cccdbcc1e 100644 --- a/linters/javascript_es/Dockerfile +++ b/linters/javascript_es/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -158,11 +172,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/javascript_prettier/Dockerfile b/linters/javascript_prettier/Dockerfile index 900823f1a1b..564bc4eeabd 100644 --- a/linters/javascript_prettier/Dockerfile +++ b/linters/javascript_prettier/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/javascript_standard/Dockerfile b/linters/javascript_standard/Dockerfile index fc40cb823a0..2e20d0bce68 100644 --- a/linters/javascript_standard/Dockerfile +++ b/linters/javascript_standard/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/json_eslint_plugin_jsonc/Dockerfile b/linters/json_eslint_plugin_jsonc/Dockerfile index ffaac496580..1955437da81 100644 --- a/linters/json_eslint_plugin_jsonc/Dockerfile +++ b/linters/json_eslint_plugin_jsonc/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -148,11 +162,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/json_jsonlint/Dockerfile b/linters/json_jsonlint/Dockerfile index dfd411066df..cf0eb72b0c6 100644 --- a/linters/json_jsonlint/Dockerfile +++ b/linters/json_jsonlint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/json_npm_package_json_lint/Dockerfile b/linters/json_npm_package_json_lint/Dockerfile index 5ce157f57e1..6987fdb4432 100644 --- a/linters/json_npm_package_json_lint/Dockerfile +++ b/linters/json_npm_package_json_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -147,11 +161,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/json_prettier/Dockerfile b/linters/json_prettier/Dockerfile index c57add9b7bd..16faf2d1eab 100644 --- a/linters/json_prettier/Dockerfile +++ b/linters/json_prettier/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/json_v8r/Dockerfile b/linters/json_v8r/Dockerfile index 6b69e04b3b0..ba935888641 100644 --- a/linters/json_v8r/Dockerfile +++ b/linters/json_v8r/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/jsx_eslint/Dockerfile b/linters/jsx_eslint/Dockerfile index 21fc144e4af..d3f774ea1fc 100644 --- a/linters/jsx_eslint/Dockerfile +++ b/linters/jsx_eslint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -149,11 +163,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/kotlin_detekt/Dockerfile b/linters/kotlin_detekt/Dockerfile index 461a947ab58..43658230e55 100644 --- a/linters/kotlin_detekt/Dockerfile +++ b/linters/kotlin_detekt/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -148,11 +162,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/detekt/detekt/releas ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/kotlin_ktlint/Dockerfile b/linters/kotlin_ktlint/Dockerfile index 0d0158d4b7c..2fdfb06d68d 100644 --- a/linters/kotlin_ktlint/Dockerfile +++ b/linters/kotlin_ktlint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -143,11 +157,11 @@ RUN curl --retry 5 --retry-delay 5 -sSLO https://github.com/pinterest/ktlint/rel ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/kubernetes_helm/Dockerfile b/linters/kubernetes_helm/Dockerfile index 82a3b410d8f..8bf987a356c 100644 --- a/linters/kubernetes_helm/Dockerfile +++ b/linters/kubernetes_helm/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -134,11 +148,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/kubernetes_kubeconform/Dockerfile b/linters/kubernetes_kubeconform/Dockerfile index b705384f41b..79a16b4e84b 100644 --- a/linters/kubernetes_kubeconform/Dockerfile +++ b/linters/kubernetes_kubeconform/Dockerfile @@ -22,6 +22,20 @@ ARG KUBERNETES_KUBECONFORM_VERSION=v0.6.7-alpine FROM ghcr.io/yannh/kubeconform:${KUBERNETES_KUBECONFORM_VERSION} AS kubeconform #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=kubeconform /kubeconform /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/kubernetes_kubescape/Dockerfile b/linters/kubernetes_kubescape/Dockerfile index 228a7e89a67..d85f832d576 100644 --- a/linters/kubernetes_kubescape/Dockerfile +++ b/linters/kubernetes_kubescape/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -139,11 +153,11 @@ RUN ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2 && \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/latex_chktex/Dockerfile b/linters/latex_chktex/Dockerfile index 35f466a119c..1fe03620967 100644 --- a/linters/latex_chktex/Dockerfile +++ b/linters/latex_chktex/Dockerfile @@ -21,6 +21,20 @@ FROM ghcr.io/assignuser/chktex-alpine:latest AS chktex #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ RUN cd ~ && touch .chktexrc && cd / ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/lua_luacheck/Dockerfile b/linters/lua_luacheck/Dockerfile index 7d687ae74f2..7c4cec2f4d0 100644 --- a/linters/lua_luacheck/Dockerfile +++ b/linters/lua_luacheck/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -150,11 +164,11 @@ RUN wget --tries=5 https://www.lua.org/ftp/lua-5.3.5.tar.gz -O - -q | tar -xzf - ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/makefile_checkmake/Dockerfile b/linters/makefile_checkmake/Dockerfile index 32c6da4c005..4ec8f3e2448 100644 --- a/linters/makefile_checkmake/Dockerfile +++ b/linters/makefile_checkmake/Dockerfile @@ -21,6 +21,20 @@ FROM mrtazz/checkmake:latest AS checkmake #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -135,11 +149,11 @@ COPY --link --from=checkmake /checkmake /usr/bin/checkmake ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/markdown_markdown_link_check/Dockerfile b/linters/markdown_markdown_link_check/Dockerfile index 869f21a9fbb..b2d9ab41ad7 100644 --- a/linters/markdown_markdown_link_check/Dockerfile +++ b/linters/markdown_markdown_link_check/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/markdown_markdown_table_formatter/Dockerfile b/linters/markdown_markdown_table_formatter/Dockerfile index 10980dc9810..060a24a52e7 100644 --- a/linters/markdown_markdown_table_formatter/Dockerfile +++ b/linters/markdown_markdown_table_formatter/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/markdown_markdownlint/Dockerfile b/linters/markdown_markdownlint/Dockerfile index 5ea3f29c37d..50d29cee079 100644 --- a/linters/markdown_markdownlint/Dockerfile +++ b/linters/markdown_markdownlint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/markdown_remark_lint/Dockerfile b/linters/markdown_remark_lint/Dockerfile index e42291cbbc3..ff4cd0b1cb4 100644 --- a/linters/markdown_remark_lint/Dockerfile +++ b/linters/markdown_remark_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -147,11 +161,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/perl_perlcritic/Dockerfile b/linters/perl_perlcritic/Dockerfile index bb4c01c890e..a9fe2c15fd9 100644 --- a/linters/perl_perlcritic/Dockerfile +++ b/linters/perl_perlcritic/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -139,11 +153,11 @@ RUN curl -fsSL https://raw.githubusercontent.com/skaji/cpm/main/cpm | perl - ins ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/php_phpcs/Dockerfile b/linters/php_phpcs/Dockerfile index a53fb7b7335..24f0a6b9ba1 100644 --- a/linters/php_phpcs/Dockerfile +++ b/linters/php_phpcs/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -169,11 +183,11 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/php_phpcsfixer/Dockerfile b/linters/php_phpcsfixer/Dockerfile index e96f51ee13e..7cb6ed92e55 100644 --- a/linters/php_phpcsfixer/Dockerfile +++ b/linters/php_phpcsfixer/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -169,11 +183,11 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/php_phplint/Dockerfile b/linters/php_phplint/Dockerfile index 79c4709caed..de3c59e10e9 100644 --- a/linters/php_phplint/Dockerfile +++ b/linters/php_phplint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -169,11 +183,11 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/php_phpstan/Dockerfile b/linters/php_phpstan/Dockerfile index d93204c7844..df2c3be72ae 100644 --- a/linters/php_phpstan/Dockerfile +++ b/linters/php_phpstan/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -168,11 +182,11 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/php_psalm/Dockerfile b/linters/php_psalm/Dockerfile index a1aee03ebc7..8bdf1a4a8ae 100644 --- a/linters/php_psalm/Dockerfile +++ b/linters/php_psalm/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -169,11 +183,11 @@ RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GI ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/powershell_powershell/Dockerfile b/linters/powershell_powershell/Dockerfile index 2b3c34f740f..96e7200989e 100644 --- a/linters/powershell_powershell/Dockerfile +++ b/linters/powershell_powershell/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -145,11 +159,11 @@ RUN curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/po ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/powershell_powershell_formatter/Dockerfile b/linters/powershell_powershell_formatter/Dockerfile index cb2f0182567..81b4d3bc8ca 100644 --- a/linters/powershell_powershell_formatter/Dockerfile +++ b/linters/powershell_powershell_formatter/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -145,11 +159,11 @@ RUN curl -L https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/po ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/protobuf_protolint/Dockerfile b/linters/protobuf_protolint/Dockerfile index 0529133c2ed..e8cd80fbffb 100644 --- a/linters/protobuf_protolint/Dockerfile +++ b/linters/protobuf_protolint/Dockerfile @@ -22,6 +22,20 @@ ARG PROTOBUF_PROTOLINT_VERSION=0.50.5 FROM yoheimuta/protolint:${PROTOBUF_PROTOLINT_VERSION} AS protolint #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=protolint /usr/local/bin/protolint /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/puppet_puppet_lint/Dockerfile b/linters/puppet_puppet_lint/Dockerfile index dde9eabf624..bbd0fcf0b77 100644 --- a/linters/puppet_puppet_lint/Dockerfile +++ b/linters/puppet_puppet_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -139,11 +153,11 @@ RUN echo 'gem: --no-document' >> ~/.gemrc && \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/python_bandit/Dockerfile b/linters/python_bandit/Dockerfile index dcefa05eb12..46265134cfd 100644 --- a/linters/python_bandit/Dockerfile +++ b/linters/python_bandit/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/python_black/Dockerfile b/linters/python_black/Dockerfile index 8da03aa8285..37c3d9d02cf 100644 --- a/linters/python_black/Dockerfile +++ b/linters/python_black/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/python_flake8/Dockerfile b/linters/python_flake8/Dockerfile index e17f7e1baa7..780fc915a54 100644 --- a/linters/python_flake8/Dockerfile +++ b/linters/python_flake8/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/python_isort/Dockerfile b/linters/python_isort/Dockerfile index 49971b0174a..9160bc9ed8f 100644 --- a/linters/python_isort/Dockerfile +++ b/linters/python_isort/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/python_mypy/Dockerfile b/linters/python_mypy/Dockerfile index 6cf0106e3a5..8fd9ea6b990 100644 --- a/linters/python_mypy/Dockerfile +++ b/linters/python_mypy/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -139,11 +153,11 @@ ENV MYPY_CACHE_DIR=/tmp ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/python_pylint/Dockerfile b/linters/python_pylint/Dockerfile index b2e9d052cc8..98bdc8a1062 100644 --- a/linters/python_pylint/Dockerfile +++ b/linters/python_pylint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/python_pyright/Dockerfile b/linters/python_pyright/Dockerfile index 2e91e80f9ff..a57c6239584 100644 --- a/linters/python_pyright/Dockerfile +++ b/linters/python_pyright/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -138,11 +152,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/python_ruff/Dockerfile b/linters/python_ruff/Dockerfile index 176314b1323..454157cd76f 100644 --- a/linters/python_ruff/Dockerfile +++ b/linters/python_ruff/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/r_lintr/Dockerfile b/linters/r_lintr/Dockerfile index 99f528bfd91..99e525952f6 100644 --- a/linters/r_lintr/Dockerfile +++ b/linters/r_lintr/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -149,11 +163,11 @@ RUN mkdir -p /home/r-library \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/raku_raku/Dockerfile b/linters/raku_raku/Dockerfile index b54c1ddb29a..196964a84e2 100644 --- a/linters/raku_raku/Dockerfile +++ b/linters/raku_raku/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -142,11 +156,11 @@ ENV PATH="~/.raku/bin:/opt/rakudo-pkg/bin:/opt/rakudo-pkg/share/perl6/site/bin:$ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_checkov/Dockerfile b/linters/repository_checkov/Dockerfile index 8be06d39fe4..02a24f51568 100644 --- a/linters/repository_checkov/Dockerfile +++ b/linters/repository_checkov/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_devskim/Dockerfile b/linters/repository_devskim/Dockerfile index 46a770c8d0d..00229014a22 100644 --- a/linters/repository_devskim/Dockerfile +++ b/linters/repository_devskim/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_dustilock/Dockerfile b/linters/repository_dustilock/Dockerfile index 2b9017db116..0b1d9015f99 100644 --- a/linters/repository_dustilock/Dockerfile +++ b/linters/repository_dustilock/Dockerfile @@ -22,6 +22,20 @@ FROM golang:alpine AS dustilock RUN GOBIN=/usr/bin go install github.com/checkmarx/dustilock@v1.2.0 #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=dustilock /usr/bin/dustilock /usr/bin/dustilock ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_git_diff/Dockerfile b/linters/repository_git_diff/Dockerfile index c62b3dccaf7..ce5d9d3bca6 100644 --- a/linters/repository_git_diff/Dockerfile +++ b/linters/repository_git_diff/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -133,11 +147,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_gitleaks/Dockerfile b/linters/repository_gitleaks/Dockerfile index 6bf963aaffc..20fd1338e55 100644 --- a/linters/repository_gitleaks/Dockerfile +++ b/linters/repository_gitleaks/Dockerfile @@ -22,6 +22,20 @@ ARG REPOSITORY_GITLEAKS_VERSION=v8.18.4 FROM zricethezav/gitleaks:${REPOSITORY_GITLEAKS_VERSION} AS gitleaks #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=gitleaks /usr/bin/gitleaks /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_grype/Dockerfile b/linters/repository_grype/Dockerfile index a06ada51373..79a30fbbf8f 100644 --- a/linters/repository_grype/Dockerfile +++ b/linters/repository_grype/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -135,11 +149,11 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_kics/Dockerfile b/linters/repository_kics/Dockerfile index 7bb31aa982a..386bcc019cb 100644 --- a/linters/repository_kics/Dockerfile +++ b/linters/repository_kics/Dockerfile @@ -22,6 +22,20 @@ ARG REPOSITORY_KICS_VERSION=v2.1.2-alpine FROM checkmarx/kics:${REPOSITORY_KICS_VERSION} AS kics #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -139,11 +153,11 @@ ENV KICS_QUERIES_PATH=/usr/bin/assets/queries KICS_LIBRARIES_PATH=/usr/bin/asset ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_ls_lint/Dockerfile b/linters/repository_ls_lint/Dockerfile index e66d4de5ad3..93f8ed7bbf1 100644 --- a/linters/repository_ls_lint/Dockerfile +++ b/linters/repository_ls_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_secretlint/Dockerfile b/linters/repository_secretlint/Dockerfile index 7f85a583aa5..9728e318241 100644 --- a/linters/repository_secretlint/Dockerfile +++ b/linters/repository_secretlint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -148,11 +162,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_semgrep/Dockerfile b/linters/repository_semgrep/Dockerfile index d2fa0a8c320..623e84e848f 100644 --- a/linters/repository_semgrep/Dockerfile +++ b/linters/repository_semgrep/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_syft/Dockerfile b/linters/repository_syft/Dockerfile index 8ef7e52affd..4cbabf85131 100644 --- a/linters/repository_syft/Dockerfile +++ b/linters/repository_syft/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -135,11 +149,11 @@ RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_trivy/Dockerfile b/linters/repository_trivy/Dockerfile index faa8c1ad67a..cba103fa849 100644 --- a/linters/repository_trivy/Dockerfile +++ b/linters/repository_trivy/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ RUN wget --tries=5 -q -O - https://raw.githubusercontent.com/aquasecurity/trivy/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_trivy_sbom/Dockerfile b/linters/repository_trivy_sbom/Dockerfile index 7a7e049ea88..066e33c1942 100644 --- a/linters/repository_trivy_sbom/Dockerfile +++ b/linters/repository_trivy_sbom/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ RUN wget --tries=5 -q -O - https://raw.githubusercontent.com/aquasecurity/trivy/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/repository_trufflehog/Dockerfile b/linters/repository_trufflehog/Dockerfile index 11297429bb1..c39a30032a2 100644 --- a/linters/repository_trufflehog/Dockerfile +++ b/linters/repository_trufflehog/Dockerfile @@ -22,6 +22,20 @@ ARG REPOSITORY_TRUFFLEHOG_VERSION=3.81.9 FROM trufflesecurity/trufflehog:${REPOSITORY_TRUFFLEHOG_VERSION} AS trufflehog #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=trufflehog /usr/bin/trufflehog /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/rst_rst_lint/Dockerfile b/linters/rst_rst_lint/Dockerfile index 65e17bf9218..5a343cc7eaf 100644 --- a/linters/rst_rst_lint/Dockerfile +++ b/linters/rst_rst_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/rst_rstcheck/Dockerfile b/linters/rst_rstcheck/Dockerfile index 01e49cfc8b9..f31591cd694 100644 --- a/linters/rst_rstcheck/Dockerfile +++ b/linters/rst_rstcheck/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/rst_rstfmt/Dockerfile b/linters/rst_rstfmt/Dockerfile index 6cf56f0b6e9..764901e2817 100644 --- a/linters/rst_rstfmt/Dockerfile +++ b/linters/rst_rstfmt/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/ruby_rubocop/Dockerfile b/linters/ruby_rubocop/Dockerfile index 90f82d91447..dc60c04adbc 100644 --- a/linters/ruby_rubocop/Dockerfile +++ b/linters/ruby_rubocop/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -144,11 +158,11 @@ RUN echo 'gem: --no-document' >> ~/.gemrc && \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/rust_clippy/Dockerfile b/linters/rust_clippy/Dockerfile index f5247cbe718..199a1456a95 100644 --- a/linters/rust_clippy/Dockerfile +++ b/linters/rust_clippy/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/salesforce_lightning_flow_scanner/Dockerfile b/linters/salesforce_lightning_flow_scanner/Dockerfile index 107b9c239d6..51956bb9612 100644 --- a/linters/salesforce_lightning_flow_scanner/Dockerfile +++ b/linters/salesforce_lightning_flow_scanner/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -167,11 +181,11 @@ RUN echo y|sf plugins install lightning-flow-scanner@${LIGHTNING_FLOW_SCANNER_VE ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/salesforce_sfdx_scanner_apex/Dockerfile b/linters/salesforce_sfdx_scanner_apex/Dockerfile index 28e69480d98..83b5bf0eb52 100644 --- a/linters/salesforce_sfdx_scanner_apex/Dockerfile +++ b/linters/salesforce_sfdx_scanner_apex/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -167,11 +181,11 @@ RUN sf plugins install @salesforce/sfdx-scanner@${SALESFORCE_SFDX_SCANNER_VERSIO ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/salesforce_sfdx_scanner_aura/Dockerfile b/linters/salesforce_sfdx_scanner_aura/Dockerfile index 8713dff0cae..c9f7984d132 100644 --- a/linters/salesforce_sfdx_scanner_aura/Dockerfile +++ b/linters/salesforce_sfdx_scanner_aura/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -167,11 +181,11 @@ RUN sf plugins install @salesforce/sfdx-scanner@${SALESFORCE_SFDX_SCANNER_VERSIO ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/salesforce_sfdx_scanner_lwc/Dockerfile b/linters/salesforce_sfdx_scanner_lwc/Dockerfile index f6dbb0d2f4d..a402fb94621 100644 --- a/linters/salesforce_sfdx_scanner_lwc/Dockerfile +++ b/linters/salesforce_sfdx_scanner_lwc/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -167,11 +181,11 @@ RUN sf plugins install @salesforce/sfdx-scanner@${SALESFORCE_SFDX_SCANNER_VERSIO ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/scala_scalafix/Dockerfile b/linters/scala_scalafix/Dockerfile index 8ec95be3443..dc8fc035395 100644 --- a/linters/scala_scalafix/Dockerfile +++ b/linters/scala_scalafix/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -142,11 +156,11 @@ RUN curl --retry-all-errors --retry 10 -fLo coursier https://git.io/coursier-cli ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/snakemake_lint/Dockerfile b/linters/snakemake_lint/Dockerfile index 7a3e575313c..d092c5e4b46 100644 --- a/linters/snakemake_lint/Dockerfile +++ b/linters/snakemake_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/snakemake_snakefmt/Dockerfile b/linters/snakemake_snakefmt/Dockerfile index 35300973b85..5f27f895adf 100644 --- a/linters/snakemake_snakefmt/Dockerfile +++ b/linters/snakemake_snakefmt/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/spell_cspell/Dockerfile b/linters/spell_cspell/Dockerfile index bb0922be783..14b36c272d6 100644 --- a/linters/spell_cspell/Dockerfile +++ b/linters/spell_cspell/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/spell_lychee/Dockerfile b/linters/spell_lychee/Dockerfile index 8b55d4f5055..5640f668cc8 100644 --- a/linters/spell_lychee/Dockerfile +++ b/linters/spell_lychee/Dockerfile @@ -21,6 +21,20 @@ FROM lycheeverse/lychee:latest-alpine AS lychee #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -135,11 +149,11 @@ COPY --link --from=lychee /usr/local/bin/lychee /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/spell_proselint/Dockerfile b/linters/spell_proselint/Dockerfile index 95724465aea..aaca8073dc9 100644 --- a/linters/spell_proselint/Dockerfile +++ b/linters/spell_proselint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/spell_vale/Dockerfile b/linters/spell_vale/Dockerfile index ea729c74d0f..b6f97176034 100644 --- a/linters/spell_vale/Dockerfile +++ b/linters/spell_vale/Dockerfile @@ -22,6 +22,20 @@ ARG SPELL_VALE_VERSION=v3.7.0 FROM jdkato/vale:${SPELL_VALE_VERSION} AS vale #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=vale /bin/vale /bin/vale ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/sql_sqlfluff/Dockerfile b/linters/sql_sqlfluff/Dockerfile index ed15beb0d1e..a9d739b5ed8 100644 --- a/linters/sql_sqlfluff/Dockerfile +++ b/linters/sql_sqlfluff/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/sql_tsqllint/Dockerfile b/linters/sql_tsqllint/Dockerfile index 08d7c095282..80c5fa6af2d 100644 --- a/linters/sql_tsqllint/Dockerfile +++ b/linters/sql_tsqllint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ RUN dotnet tool install --global TSQLLint ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/swift_swiftlint/Dockerfile b/linters/swift_swiftlint/Dockerfile index 0f8e6144877..1d1cd97c5bc 100644 --- a/linters/swift_swiftlint/Dockerfile +++ b/linters/swift_swiftlint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -135,11 +149,11 @@ RUN rc-update add docker boot && rc-service docker start || true ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/tekton_tekton_lint/Dockerfile b/linters/tekton_tekton_lint/Dockerfile index bf2ade30aa4..3a50529be03 100644 --- a/linters/tekton_tekton_lint/Dockerfile +++ b/linters/tekton_tekton_lint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/terraform_terraform_fmt/Dockerfile b/linters/terraform_terraform_fmt/Dockerfile index aea1102d265..30eabf2a274 100644 --- a/linters/terraform_terraform_fmt/Dockerfile +++ b/linters/terraform_terraform_fmt/Dockerfile @@ -22,6 +22,20 @@ ARG TERRAFORM_TERRAGRUNT_VERSION=1.9.4 FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=terragrunt /bin/terraform /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/terraform_terragrunt/Dockerfile b/linters/terraform_terragrunt/Dockerfile index 3d7b9089689..09f537de1f5 100644 --- a/linters/terraform_terragrunt/Dockerfile +++ b/linters/terraform_terragrunt/Dockerfile @@ -22,6 +22,20 @@ ARG TERRAFORM_TERRAGRUNT_VERSION=1.9.4 FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=terragrunt /usr/local/bin/terragrunt /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/terraform_terrascan/Dockerfile b/linters/terraform_terrascan/Dockerfile index a8b162106dc..055e47aa83d 100644 --- a/linters/terraform_terrascan/Dockerfile +++ b/linters/terraform_terrascan/Dockerfile @@ -22,6 +22,20 @@ ARG TERRAFORM_TERRASCAN_VERSION=1.19.2 FROM tenable/terrascan:${TERRAFORM_TERRASCAN_VERSION} AS terrascan #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=terrascan /go/bin/terrascan /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/terraform_tflint/Dockerfile b/linters/terraform_tflint/Dockerfile index cbca8f2df9a..ac9fe9a6006 100644 --- a/linters/terraform_tflint/Dockerfile +++ b/linters/terraform_tflint/Dockerfile @@ -22,6 +22,20 @@ ARG TERRAFORM_TFLINT_VERSION=0.53.0 FROM ghcr.io/terraform-linters/tflint:v${TERRAFORM_TFLINT_VERSION} AS tflint #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ COPY --link --from=tflint /usr/local/bin/tflint /usr/bin/ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/tsx_eslint/Dockerfile b/linters/tsx_eslint/Dockerfile index 46854c55c1f..008a1947738 100644 --- a/linters/tsx_eslint/Dockerfile +++ b/linters/tsx_eslint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -158,11 +172,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/typescript_es/Dockerfile b/linters/typescript_es/Dockerfile index e201f5a7e3c..485232a8c50 100644 --- a/linters/typescript_es/Dockerfile +++ b/linters/typescript_es/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -161,11 +175,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/typescript_prettier/Dockerfile b/linters/typescript_prettier/Dockerfile index c4bb88a7280..a7d359ddbeb 100644 --- a/linters/typescript_prettier/Dockerfile +++ b/linters/typescript_prettier/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -147,11 +161,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/typescript_standard/Dockerfile b/linters/typescript_standard/Dockerfile index 913631d2b19..2aad9de0076 100644 --- a/linters/typescript_standard/Dockerfile +++ b/linters/typescript_standard/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -147,11 +161,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/vbdotnet_dotnet_format/Dockerfile b/linters/vbdotnet_dotnet_format/Dockerfile index 277ab244a4e..13b99a0a377 100644 --- a/linters/vbdotnet_dotnet_format/Dockerfile +++ b/linters/vbdotnet_dotnet_format/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -136,11 +150,11 @@ ENV PATH="${PATH}:/root/.dotnet/tools" ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/xml_xmllint/Dockerfile b/linters/xml_xmllint/Dockerfile index 5a61123bc8d..d77a003a9e7 100644 --- a/linters/xml_xmllint/Dockerfile +++ b/linters/xml_xmllint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/yaml_prettier/Dockerfile b/linters/yaml_prettier/Dockerfile index 7591687794a..24674c94a76 100644 --- a/linters/yaml_prettier/Dockerfile +++ b/linters/yaml_prettier/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/yaml_v8r/Dockerfile b/linters/yaml_v8r/Dockerfile index c086ec54a56..392ea37a9f1 100644 --- a/linters/yaml_v8r/Dockerfile +++ b/linters/yaml_v8r/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -146,11 +160,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/linters/yaml_yamllint/Dockerfile b/linters/yaml_yamllint/Dockerfile index 2273c94d1d1..252495733e5 100644 --- a/linters/yaml_yamllint/Dockerfile +++ b/linters/yaml_yamllint/Dockerfile @@ -21,6 +21,20 @@ #FROM__END +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + ################## # Get base image # ################## @@ -137,11 +151,11 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ ################################ # Installs python dependencies # ################################ -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . ####################################### # Copy scripts and rules to container # diff --git a/megalinter/Linter.py b/megalinter/Linter.py index 770792a1de7..77f6fae8d80 100644 --- a/megalinter/Linter.py +++ b/megalinter/Linter.py @@ -543,9 +543,10 @@ def load_config_vars(self, params): local_config_file = self.workspace + os.path.sep + self.config_file_name existing_before = os.path.isfile(local_config_file) try: - with urllib.request.urlopen(remote_config_file) as response, open( - local_config_file, "wb" - ) as out_file: + with ( + urllib.request.urlopen(remote_config_file) as response, + open(local_config_file, "wb") as out_file, + ): shutil.copyfileobj(response, out_file) self.config_file_label = remote_config_file if existing_before is False: @@ -621,9 +622,10 @@ def load_config_vars(self, params): local_ignore_file = self.workspace + os.path.sep + self.ignore_file_name existing_before = os.path.isfile(local_ignore_file) try: - with urllib.request.urlopen(remote_ignore_file) as response, open( - local_ignore_file, "wb" - ) as out_file: + with ( + urllib.request.urlopen(remote_ignore_file) as response, + open(local_ignore_file, "wb") as out_file, + ): shutil.copyfileobj(response, out_file) self.ignore_file_label = remote_ignore_file if existing_before is False: diff --git a/megalinter/__about__.py b/megalinter/__about__.py new file mode 100644 index 00000000000..484a6d6d04e --- /dev/null +++ b/megalinter/__about__.py @@ -0,0 +1 @@ +__version__ = "7.13.0" diff --git a/megalinter/setup.py b/megalinter/setup.py deleted file mode 100644 index 3608742d69c..00000000000 --- a/megalinter/setup.py +++ /dev/null @@ -1,36 +0,0 @@ -from setuptools import setup - -setup( - name="megalinter", - version="0.1", - description="MegaLinter", - url="http://github.com/oxsecurity/megalinter", - author="Nicolas Vuillamy", - author_email="nicolas.vuillamy@gmail.com", - license="MIT", - packages=[ - "megalinter", - "megalinter.linters", - "megalinter.reporters", - "megalinter.tests", - ], - install_requires=[ - "gitpython", - "jsonpickle", - "multiprocessing_logging", - "pychalk", - "pygithub", - "python-gitlab", - "azure-devops==6.0.0b4", - "commentjson", - "pytablewriter", - "pyyaml", - "regex", - "requests", - "terminaltables", - "urllib3", - "importlib-metadata>=3.10", - "redis", - ], - zip_safe=False, -) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000000..6190a7e6f32 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,113 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "megalinter" +dynamic = ["version"] +description = "MegaLinter" +readme = "README.md" +requires-python = ">=3.9" +license = "MIT" +keywords = [] +authors = [{ name = "Nicolas Vuillamy", email = "nicolas.vuillamy@gmail.com" }] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", +] +dependencies = [ + "azure-devops==6.0.0b4", + "commentjson", + "gitpython", + "importlib-metadata>=3.10; python_version < '3.9'", + "jsonpickle", + "multiprocessing_logging", + "pychalk", + "pygithub", + "pytablewriter", + "python-gitlab", + "pyyaml", + "redis", + "regex", + "requests", + "terminaltables", + "urllib3", +] + +[project.urls] +Homepage = "https://megalinter.io/" +Documentation = "https://megalinter.io/" +Repository = "https://github.com/oxsecurity/megalinter.git" +Source = "https://github.com/oxsecurity/megalinter" +Issues = "https://github.com/oxsecurity/megalinter/issues" +Changelog = "https://github.com/oxsecurity/megalinter/blob/main/CHANGELOG.md" + +[tool.hatch.version] +path = "megalinter/__about__.py" + +[tool.hatch.envs.default] +installer = "uv" + +[tool.hatch.envs.docs] +dependencies = [ + "mkdocs", + "markdown", + "mike", + "mkdocs-material", + "pymdown-extensions", + "mkdocs-glightbox==0.3.2", + "mdx_truly_sane_lists", + "jsonschema", + "json-schema-for-humans", + "giturlparse", + "webpreview", + "github-dependents-info", +] + +[tool.hatch.envs.hatch-test] +default-args = [""] +randomize = true +parallel = true +retries = 2 + +[tool.hatch.envs.docs.scripts] +# build = "mkdocs build --clean --strict" +prettify = "hatch run python -m json.tool --sort-keys --no-indent ./site/search/search_index.json ./site/search/search_index.json" +build-only = ["mkdocs build --clean {args}"] +build = ["build-only {args}", "prettify"] +serve = "mkdocs serve --dev-addr localhost:8000 {args}" + +[tool.hatch.envs.build] +template = "docs" +[tool.hatch.envs.build.scripts] +all = ["build --doc --stats --dependents {args}", "hatch run docs:build"] +build-sh = "./build.sh {args}" +build-py = "hatch run python .automation/build.py {args}" +build = ["build-py", "hatch run docs:build"] +docs = ["./build.sh --doc {args}", "hatch run docs:build"] +stats = "build --stats" +changelog = "hatch run python .automation/build.py --changelog {args}" + +[tool.hatch.envs.types] +extra-dependencies = ["mypy>=1.0.0"] +[tool.hatch.envs.types.scripts] +check = "mypy --install-types --non-interactive {args:megalinter}" + +[tool.coverage.run] +source_pkgs = ["megalinter"] +branch = false +parallel = true +omit = ["megalinter/__about__.py"] + +[tool.coverage.paths] +megalinter = ["megalinter", "*/megalinter/megalinter"] +tests = [".automation/test", "*/megalinter/tests"] + +[tool.coverage.report] +exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"] + +[tool.ruff] +src = ["megalinter"] +extend-exclude = [".automation/test"] diff --git a/server/Dockerfile b/server/Dockerfile index 02e044f8b87..08d5eed50e5 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,3 +1,17 @@ +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + FROM python:3.12-alpine RUN apk add --upgrade --no-cache git @@ -6,11 +20,11 @@ WORKDIR / COPY logging.conf logging.conf -COPY megalinter /megalinter -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . COPY server /server COPY server/requirements.txt requirements.txt diff --git a/server/Dockerfile-dev b/server/Dockerfile-dev index 496e27d10d2..65b6d8d9448 100644 --- a/server/Dockerfile-dev +++ b/server/Dockerfile-dev @@ -1,6 +1,20 @@ FROM hadolint/hadolint:v2.12.0-alpine as hadolint FROM trufflesecurity/trufflehog:latest as trufflehog +################## +# Build wheel for megalinter python package +################## +FROM ghcr.io/astral-sh/uv:0.2.37 AS uv +FROM python:3.12.5-alpine3.20 AS build-ml-core +WORKDIR / +COPY pyproject.toml . +COPY --from=uv /uv /bin/uv +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system -r pyproject.toml +COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv pip install --system . + FROM python:3.12-alpine WORKDIR / @@ -19,14 +33,11 @@ COPY --link --from=trufflehog /usr/bin/trufflehog /usr/bin/ ENV MEGALINTER_FLAVOR=security # Core MegaLinter -COPY megalinter /megalinter - - - -RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ - && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ - && rm -rf /var/cache/apk/* \ - && find . \( -type f \( -iname \*.pyc -o -iname \*.pyo \) -o -type d -iname __pycache__ \) -delete +COPY --from=build-ml-core pyproject.toml README.md ./ +COPY --from=build-ml-core megalinter /megalinter/ +RUN --mount=type=cache,target=/root/.cache/uv,from=build-ml-core \ + --mount=from=uv,source=/uv,target=/bin/uv \ + uv pip install --system -e . COPY megalinter/descriptors /megalinter-descriptors COPY TEMPLATES /action/lib/.automation