From 76513c890a19720d3c082d67174f701ad1af6fbd Mon Sep 17 00:00:00 2001 From: Vladimir Petko Date: Tue, 17 Sep 2024 21:58:54 +1200 Subject: [PATCH] test: modernize pdfbox test (#420) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: use Ubuntu base image only Use the same Ubuntu base image to provide shell to avoid binary incompatibility. * test: modernize pdfbox example Bump version to 3.0.3 and use the release chisel. Note: had to add workaround due the missing CA certificate: wget https://mirror.math.princeton.edu/pub/CTAN/fonts/opensans/type1/ --2024-09-17 15:05:03-- https://mirror.math.princeton.edu/pub/CTAN/fonts/opensans/type1/ Resolving mirror.math.princeton.edu (mirror.math.princeton.edu)... 128.112.18.21 Connecting to mirror.math.princeton.edu (mirror.math.princeton.edu)|128.112.18.21|:443... connected. ERROR: cannot verify mirror.math.princeton.edu's certificate, issued by ‘CN=InCommon RSA Server CA 2,O=Internet2,C=US’: Unable to locally verify the issuer's authority. To connect to mirror.math.princeton.edu insecurely, use `--no-check-certificate'. --- tests/containers/maven/Dockerfile.22.04 | 26 ++++++++++++++-------- tests/pdfbox/Dockerfile | 29 +++++++------------------ tests/pdfbox/runtest | 2 +- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/tests/containers/maven/Dockerfile.22.04 b/tests/containers/maven/Dockerfile.22.04 index 6f7826a..818e35a 100644 --- a/tests/containers/maven/Dockerfile.22.04 +++ b/tests/containers/maven/Dockerfile.22.04 @@ -1,29 +1,37 @@ ARG UBUNTU_RELEASE=22.04 ARG BASE_IMAGE=ubuntu/jre:17_edge -ARG MAVEN_IMAGE=maven:3.9.9-eclipse-temurin-17 -FROM $MAVEN_IMAGE as builder +ARG CHISEL_VERSION=0.10.0 +ARG TARGETARCH=amd64 + FROM public.ecr.aws/ubuntu/ubuntu:$UBUNTU_RELEASE@sha256:1582c29f34a48752e406f1a261fe9545fad895da3f6bb4be55bc82485557564e AS jdk +ARG CHISEL_VERSION +ARG TARGETARCH + RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates \ ca-certificates-java \ binutils \ openjdk-17-jdk \ + maven \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* RUN jlink --no-header-files --no-man-pages --strip-debug \ --add-modules ALL-MODULE-PATH --output /opt/java +SHELL ["/bin/bash", "-oeux", "pipefail", "-c"] +ADD https://github.com/canonical/chisel/releases/download/v${CHISEL_VERSION}/chisel_v${CHISEL_VERSION}_linux_${TARGETARCH}.tar.gz chisel.tar.gz +RUN tar -xvf chisel.tar.gz -C /usr/bin/ +RUN mkdir -p /rootfs \ + && chisel cut --root /rootfs coreutils_bins dash_bins + FROM $BASE_IMAGE -COPY --from=builder /bin/sh /bin/sh -COPY --from=builder /usr/bin/chmod /usr/bin/chmod -COPY --from=builder /usr/bin/uname /usr/bin/uname -COPY --from=builder /usr/bin/dirname /usr/bin/dirname -# note, Temurin base does not install into /etc/maven and /usr/share/java -# other base might require copying those folders -COPY --from=builder /usr/share/maven /usr/share/maven +COPY --from=jdk /rootfs / +COPY --from=jdk /etc/maven /etc/maven +COPY --from=jdk /usr/share/java /usr/share/java +COPY --from=jdk /usr/share/maven /usr/share/maven ENV JAVA_HOME=/opt/java diff --git a/tests/pdfbox/Dockerfile b/tests/pdfbox/Dockerfile index c14df44..b26472a 100644 --- a/tests/pdfbox/Dockerfile +++ b/tests/pdfbox/Dockerfile @@ -4,39 +4,26 @@ ARG USER=app ARG UID=101 ARG GROUP=app ARG GID=101 - -FROM golang:1.22 AS chisel -ARG UBUNTU_RELEASE -RUN git clone --depth 1 -b ubuntu-22.04 https://github.com/canonical/chisel-releases /opt/chisel-releases \ - && git clone --depth 1 -b main https://github.com/canonical/chisel /opt/chisel -WORKDIR /opt/chisel -RUN go generate internal/deb/version.go \ - && go build ./cmd/chisel +ARG CHISEL_VERSION=0.10.0 +ARG TARGETARCH=amd64 FROM public.ecr.aws/ubuntu/ubuntu:$UBUNTU_RELEASE@sha256:1582c29f34a48752e406f1a261fe9545fad895da3f6bb4be55bc82485557564e AS builder -SHELL ["/bin/bash", "-oeux", "pipefail", "-c"] +ARG CHISEL_VERSION +ARG TARGETARCH RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates \ - ca-certificates-java \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* -COPY --from=chisel /opt/chisel/chisel /usr/bin/ - -### BOILERPLATE END ### -FROM builder AS sliced-deps -ARG USER -ARG UID -ARG GROUP -ARG GID SHELL ["/bin/bash", "-oeux", "pipefail", "-c"] -COPY --from=chisel /opt/chisel-releases /opt/chisel-releases +ADD https://github.com/canonical/chisel/releases/download/v${CHISEL_VERSION}/chisel_v${CHISEL_VERSION}_linux_${TARGETARCH}.tar.gz chisel.tar.gz +RUN tar -xvf chisel.tar.gz -C /usr/bin/ RUN mkdir -p /rootfs \ - && chisel cut --release /opt/chisel-releases --root /rootfs \ + && chisel cut --root /rootfs \ liblcms2-2_libs \ libfontconfig1_libs \ libfreetype6_libs \ libjpeg-turbo8_libs FROM $MAVEN_IMAGE -COPY --from=sliced-deps /rootfs / +COPY --from=builder /rootfs / diff --git a/tests/pdfbox/runtest b/tests/pdfbox/runtest index 0b8249d..2d49a21 100755 --- a/tests/pdfbox/runtest +++ b/tests/pdfbox/runtest @@ -17,7 +17,7 @@ if [ -z $M2_CACHE ]; then fi PDFBOX_REPO=https://github.com/vpa1977/pdfbox -VERSION=3.0.0-alpha3 +VERSION=3.0.3 APP=pdfbox TEST_DIR=`pwd`