From 2c366e308c74361449099cbc46af018b779d9d26 Mon Sep 17 00:00:00 2001 From: Wolfgang Klenk Date: Thu, 19 Dec 2024 10:55:20 +0100 Subject: [PATCH] fix(reporter): Add ScanCode license texts to reporter docker image Dump the ScanCode license texts to directory /opt/scancode-license-data when creating the reporter docker container. This directory is used by ORT as fallback option if the ScanCode license texts cannot be located by the existing heuristic look-up algorithm. See oss-review-toolkit/ort#9622. Signed-off-by: Wolfgang Klenk --- workers/reporter/docker/Reporter.Dockerfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/workers/reporter/docker/Reporter.Dockerfile b/workers/reporter/docker/Reporter.Dockerfile index 56a0d2dec..a0f4ff74f 100644 --- a/workers/reporter/docker/Reporter.Dockerfile +++ b/workers/reporter/docker/Reporter.Dockerfile @@ -19,6 +19,24 @@ # SPDX-License-Identifier: Apache-2.0 # License-Filename: LICENSE +# Build-Stage for Python executing scancode-license-data to get the license texts in a directory +FROM python:3.11-slim AS scancode-license-data-build + +# Keep in sync with Scanner.Dockerfile +ARG SCANCODE_VERSION=32.2.1 + +RUN apt-get update && apt-get install -y curl libgomp1 && rm -rf /var/lib/apt/lists/* + +# Use pip to install ScanCode +RUN curl -Os https://raw.githubusercontent.com/nexB/scancode-toolkit/v$SCANCODE_VERSION/requirements.txt && \ + pip install -U --constraint requirements.txt scancode-toolkit==$SCANCODE_VERSION && \ + rm requirements.txt + +# Extract ScanCode license data to directory. +RUN scancode-license-data --path /opt/scancode-license-data \ + && find /opt/scancode-license-data -type f -not -name "*.LICENSE" -exec rm -f {} + \ + && rm -rf /opt/scancode-license-data/static + # When updating this version make sure to keep it in sync with the other worker Dockerfiles and libs.version.toml. FROM eclipse-temurin:21.0.4_7-jdk-jammy@sha256:0472478e22da0f66043fa6acd8cd30126592349f47937adafc2340794e5bf06a @@ -51,4 +69,6 @@ RUN chgrp -R 0 /home/ort && chmod -R g+rwX /home/ort USER $USERNAME WORKDIR $HOMEDIR +COPY --from=scancode-license-data-build --chown=$USER:$USER /opt/scancode-license-data /opt/scancode-license-data + ENTRYPOINT ["/bin/bash"]