Skip to content

Commit

Permalink
test: modernize pdfbox test (#420)
Browse files Browse the repository at this point in the history
* 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'.
  • Loading branch information
vpa1977 authored Sep 17, 2024
1 parent 2dd8b9b commit 76513c8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
26 changes: 17 additions & 9 deletions tests/containers/maven/Dockerfile.22.04
Original file line number Diff line number Diff line change
@@ -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

Expand Down
29 changes: 8 additions & 21 deletions tests/pdfbox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 /
2 changes: 1 addition & 1 deletion tests/pdfbox/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down

0 comments on commit 76513c8

Please sign in to comment.