From ec5d3f50ea1aab927893039ea2e3e88a7109d903 Mon Sep 17 00:00:00 2001 From: Michael Valdron Date: Mon, 4 Nov 2024 12:04:11 +0000 Subject: [PATCH] add license to container images Signed-off-by: Michael Valdron --- index/server/Dockerfile | 4 ++++ index/server/build-multi-arch.sh | 8 +++++++- index/server/build.sh | 8 ++++++++ oci-registry/Dockerfile | 6 ++++++ oci-registry/build-multi-arch.sh | 7 ++++++- oci-registry/build.sh | 6 ++++++ tests/integration/Dockerfile | 4 ++++ tests/integration/docker-build.sh | 6 ++++++ 8 files changed, 47 insertions(+), 2 deletions(-) diff --git a/index/server/Dockerfile b/index/server/Dockerfile index a377f3ad1..002c8ff81 100644 --- a/index/server/Dockerfile +++ b/index/server/Dockerfile @@ -40,6 +40,10 @@ RUN set -x ; \ # Modify the permissions on the necessary files to allow the container to properly run as a non-root UID RUN mkdir -p /www/data && chmod -R g+rwx /www/data +# Add license +RUN mkdir -p /licenses +COPY LICENSE /licenses + # disable http/2 on the index server by default ARG ENABLE_HTTP2=false ENV ENABLE_HTTP2=${ENABLE_HTTP2} diff --git a/index/server/build-multi-arch.sh b/index/server/build-multi-arch.sh index 6dc1d1fe1..87b5ff05c 100644 --- a/index/server/build-multi-arch.sh +++ b/index/server/build-multi-arch.sh @@ -30,6 +30,9 @@ PLATFORMS="linux/amd64,linux/arm64" # Generate OpenAPI endpoint and type definitions bash ${buildfolder}/codegen.sh +# Copy license to include in image build +cp ${buildfolder}/../../LICENSE ${buildfolder}/LICENSE + if [ ${podman} == true ]; then echo "Executing with podman" @@ -52,4 +55,7 @@ else docker buildx rm index-base-builder -fi \ No newline at end of file +fi + +# Remove license from build directory +rm ${buildfolder}/LICENSE diff --git a/index/server/build.sh b/index/server/build.sh index c7e8d3cdc..53fbd9e7f 100755 --- a/index/server/build.sh +++ b/index/server/build.sh @@ -41,6 +41,14 @@ echo "RUNNING: bash ${buildfolders}/codegen.sh" # Generate OpenAPI endpoint and type definitions bash ${buildfolder}/codegen.sh +echo "RUNNING: cp ${buildfolder}/../../LICENSE ${buildfolder}/LICENSE" +# Copy license to include in image build +cp ${buildfolder}/../../LICENSE ${buildfolder}/LICENSE + echo "RUNNING: docker build -t devfile-index-base:latest --platform ${arch} --build-arg ENABLE_HTTP2=${ENABLE_HTTP2} $buildfolder" # Build the index server docker build -t devfile-index-base:latest --platform "${arch}" --build-arg ENABLE_HTTP2=${ENABLE_HTTP2} $buildfolder + +echo "RUNNING: rm ${buildfolder}/LICENSE" +# Remove license from build directory +rm ${buildfolder}/LICENSE diff --git a/oci-registry/Dockerfile b/oci-registry/Dockerfile index d29d55e40..e0f5fe1ba 100644 --- a/oci-registry/Dockerfile +++ b/oci-registry/Dockerfile @@ -21,7 +21,13 @@ RUN microdnf update -y && rm -rf /var/cache/yum && microdnf install ca-certifica RUN set -x ; \ adduser registry -u 1001 -G root && exit 0 +# Copy OCI registry binary from container image COPY --from=registry --chown=registry:0 /bin/registry /bin/registry + +# Add license +RUN mkdir -p /licenses +COPY LICENSE /licenses + USER 1001 EXPOSE 5000 ENTRYPOINT ["registry"] diff --git a/oci-registry/build-multi-arch.sh b/oci-registry/build-multi-arch.sh index ade1e7b05..bdf4ef36c 100644 --- a/oci-registry/build-multi-arch.sh +++ b/oci-registry/build-multi-arch.sh @@ -48,6 +48,8 @@ function engine-handler { done } +# Copy license to include in image build +cp ${buildfolder}/../LICENSE ${buildfolder}/LICENSE if [ ${podman} == true ]; then echo "Executing with podman" @@ -78,4 +80,7 @@ else docker manifest push "$DEFAULT_MANIFEST" docker manifest rm "$DEFAULT_MANIFEST" -fi \ No newline at end of file +fi + +# Remove license from build directory +rm ${buildfolder}/LICENSE diff --git a/oci-registry/build.sh b/oci-registry/build.sh index ca8f7eeb0..e7103646a 100755 --- a/oci-registry/build.sh +++ b/oci-registry/build.sh @@ -32,4 +32,10 @@ fi # set podman alias if necessary . ${buildfolder}/../setenv.sh +# Copy license to include in image build +cp ${buildfolder}/../LICENSE ${buildfolder}/LICENSE + docker build -t oci-registry:next --platform "${arch}" "$buildfolder" + +# Remove license from build directory +rm ${buildfolder}/LICENSE diff --git a/tests/integration/Dockerfile b/tests/integration/Dockerfile index d719062bf..38324ce25 100644 --- a/tests/integration/Dockerfile +++ b/tests/integration/Dockerfile @@ -24,4 +24,8 @@ RUN cd /registry-test/registry-library && ./build.sh && cp /registry-test/regist # Build the test binary RUN /registry-test/build.sh +# Add license +RUN mkdir -p /licenses +COPY LICENSE /licenses + CMD /registry-test/devfile-registry-integration \ No newline at end of file diff --git a/tests/integration/docker-build.sh b/tests/integration/docker-build.sh index a9facd38f..e6bd6fa59 100755 --- a/tests/integration/docker-build.sh +++ b/tests/integration/docker-build.sh @@ -20,7 +20,13 @@ # Get the registry-library cp -rf ../../registry-library ./ +# Copy license to include in image build +cp ../../LICENSE LICENSE + # Build the container image docker build -t devfile-registry-integration ./ +# Remove license from build directory +rm LICENSE + rm -rf ./registry-library/ \ No newline at end of file