From 00ecfe62a30ddb1608832ad909f320eeb9b69fdc Mon Sep 17 00:00:00 2001 From: ziad hany Date: Fri, 4 Sep 2026 18:00:33 +0300 Subject: [PATCH 1/5] Add a docker file Signed-off-by: ziad hany --- Dockerfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..71d0073 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.13-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + git build-essential \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /opt/healthycode + +RUN pip install --no-cache-dir poetry +RUN poetry config virtualenvs.in-project true + +COPY pyproject.toml poetry.lock* ./ +RUN poetry install --no-interaction --no-ansi --no-root + +COPY . . + +RUN poetry build -f wheel \ + && .venv/bin/pip install dist/*.whl \ No newline at end of file From 204823069a8739b9acc1a522fa97c9130b145d94 Mon Sep 17 00:00:00 2001 From: ziad hany Date: Mon, 7 Sep 2026 14:37:57 +0300 Subject: [PATCH 2/5] Add CI for publishing docker images Signed-off-by: ziad hany --- .github/workflows/publish-docker-image.yml | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/publish-docker-image.yml diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml new file mode 100644 index 0000000..41c51d9 --- /dev/null +++ b/.github/workflows/publish-docker-image.yml @@ -0,0 +1,102 @@ +name: Publish Docker image on GitHub Container Registry +# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions + +on: + workflow_dispatch: + push: + tags: + - "v*.*.*" + +# Defines two custom environment variables for the workflow. +# These are used for the Container registry domain, +# and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-publish-image: + runs-on: ubuntu-24.04 + + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false # do not keep the token around + + # Uses the `docker/login-action` action to log in to the Container registry using + # the account and password that will publish the packages. + - name: Log in to the Container registry + uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for core image + id: meta + uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Extract metadata (tags, labels) for full image + id: meta-full + uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + suffix=-full + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 + + - name: Build and push core Docker image + id: push + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 + with: + context: . + target: core + push: true + tags: | + ${{ steps.meta.outputs.tags }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} + annotations: ${{ steps.meta.outputs.annotations }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and push full Docker image + id: push-full + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 + with: + context: . + target: full + push: true + tags: | + ${{ steps.meta-full.outputs.tags }} + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-full + labels: ${{ steps.meta-full.outputs.labels }} + annotations: ${{ steps.meta-full.outputs.annotations }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Generate artifact attestation for core image + uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true + + - name: Generate artifact attestation for full image + uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push-full.outputs.digest }} + push-to-registry: true \ No newline at end of file From 3d85ab569c7177b0e04db97cdd4757b95d9ea732 Mon Sep 17 00:00:00 2001 From: ziad hany Date: Mon, 14 Sep 2026 23:17:31 +0300 Subject: [PATCH 3/5] Add a label for dockerfile and simplify the CI for publish-docker-image Signed-off-by: ziad hany --- .github/workflows/publish-docker-image.yml | 42 ++-------------------- Dockerfile | 4 +++ 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 41c51d9..39e34b6 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -7,9 +7,6 @@ on: tags: - "v*.*.*" -# Defines two custom environment variables for the workflow. -# These are used for the Container registry domain, -# and a name for the Docker image that this workflow builds. env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} @@ -40,63 +37,30 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for core image + - name: Extract metadata (tags, labels) for image id: meta uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Extract metadata (tags, labels) for full image - id: meta-full - uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - flavor: | - suffix=-full - - name: Set up Docker Buildx uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 - - name: Build and push core Docker image + - name: Build and push Docker image id: push uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 with: context: . - target: core push: true tags: | ${{ steps.meta.outputs.tags }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Build and push full Docker image - id: push-full - uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 - with: - context: . - target: full - push: true - tags: | - ${{ steps.meta-full.outputs.tags }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-full - labels: ${{ steps.meta-full.outputs.labels }} - annotations: ${{ steps.meta-full.outputs.annotations }} - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Generate artifact attestation for core image + - name: Generate artifact attestation for Docker image uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 with: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true - - - name: Generate artifact attestation for full image - uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 - with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - subject-digest: ${{ steps.push-full.outputs.digest }} push-to-registry: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 71d0073..b53e4c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,9 @@ FROM python:3.13-slim +LABEL org.opencontainers.image.source="https://github.com/aboutcode-org/healthycode" +LABEL org.opencontainers.image.description="healthycode" +LABEL org.opencontainers.image.licenses="GPL-3.0-or-later" + RUN apt-get update && apt-get install -y --no-install-recommends \ git build-essential \ && rm -rf /var/lib/apt/lists/* From 1fc603211ef4c0b04e8f10d305bc98ee52c05114 Mon Sep 17 00:00:00 2001 From: ziad hany Date: Wed, 16 Sep 2026 15:53:59 +0300 Subject: [PATCH 4/5] Update publish docker image CI and add a label Update Docker image description Signed-off-by: ziad hany --- .github/workflows/publish-docker-image.yml | 12 +++++++++++- Dockerfile | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-docker-image.yml b/.github/workflows/publish-docker-image.yml index 39e34b6..3a70035 100644 --- a/.github/workflows/publish-docker-image.yml +++ b/.github/workflows/publish-docker-image.yml @@ -42,6 +42,17 @@ jobs: uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=sha,event=workflow_dispatch,enable=${{ !startsWith(github.ref, 'refs/tags/') }} + type=semver,pattern={{version}} + labels: | + org.opencontainers.image.title=HealthyCode + org.opencontainers.image.description=Client to generate GrimoireLab metrics for Project Health using the software analytics platform GrimoireLab + org.opencontainers.image.licenses=GPL-3.0-or-later + annotations: | + org.opencontainers.image.title=HealthyCode + org.opencontainers.image.description=Client to generate GrimoireLab metrics for Project Health using the software analytics platform GrimoireLab + org.opencontainers.image.licenses=GPL-3.0-or-later - name: Set up Docker Buildx uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0 @@ -54,7 +65,6 @@ jobs: push: true tags: | ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} diff --git a/Dockerfile b/Dockerfile index b53e4c4..a6b2e9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.13-slim LABEL org.opencontainers.image.source="https://github.com/aboutcode-org/healthycode" -LABEL org.opencontainers.image.description="healthycode" +LABEL org.opencontainers.image.description="Client to generate GrimoireLab metrics for Project Health using the software analytics platform GrimoireLab" LABEL org.opencontainers.image.licenses="GPL-3.0-or-later" RUN apt-get update && apt-get install -y --no-install-recommends \ From 784972556fd849e3d9e599226b68d96d6506374c Mon Sep 17 00:00:00 2001 From: ziad hany Date: Wed, 16 Sep 2026 19:19:21 +0300 Subject: [PATCH 5/5] Update a README.md with instructions on how to run the Docker image. Signed-off-by: ziad hany --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index ae14350..666b956 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ grimoirelab-metrics spdx.xml \ --pony-threshold 0.5 \ --elephant-threshold 0.5 \ --dev-categories-thresholds 0.8 0.95 \ + --grimoirelab-ecosystem "npm-training-set" \ + --grimoirelab-project "npm-popular-components" \ --output metrics.json ``` @@ -109,6 +111,39 @@ This is an example of a valid SPDX file: ``` +### Running with Docker +The tool can also be run using the published Docker image. This is useful when you +do not want to install Poetry and the tool's dependencies locally. + +Build the Docker image from the repository: +```bash +docker build -t healthycode . +``` + +Then run the tool with a Git repository as the input: + +```bash +docker run --rm \ + healthycode \ + /opt/healthycode/.venv/bin/grimoirelab-metrics https://github.com/aboutcode/example.git \ + --grimoirelab-url http://localhost:8000 \ + --grimoirelab-user user --grimoirelab-password password \ + --opensearch-url https://127.0.0.1:9200 \ + --opensearch-index events \ + --opensearch-user 'admin' --opensearch-password 'admin' \ + --verify-certs --opensearch-ca-certs /path/to/ca.pem \ + --from-date 2024-01-01 --to-date 2025-01-01 \ + --repository-timeout 3600 \ + --code-file-pattern "\.py$|\.js$" \ + --binary-file-pattern "\.exe$|\.tar$" \ + --pony-threshold 0.5 \ + --elephant-threshold 0.5 \ + --dev-categories-thresholds 0.8 0.95 \ + --grimoirelab-ecosystem "npm-training-set" \ + --grimoirelab-project "npm-popular-components" \ + --output metrics.json +``` + ## Project Health Metrics This is the list of the metrics generated by this tool: