Skip to content

Instantly share code, notes, and snippets.

@vacri
Created July 4, 2023 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vacri/164f5a51e8408372dd80731f16b924c9 to your computer and use it in GitHub Desktop.
Save vacri/164f5a51e8408372dd80731f16b924c9 to your computer and use it in GitHub Desktop.
Dockerfile for XML::Enc issue with Net::SAML2
# XML::Enc version bump from 0.11 to 0.12 kills our Net::SAML2 build's tests
# this dockerfile creates some perl .debs for use in another docker image
# the failure happens with either cpanminus or dh-make-perl (.deb package builder)
# lines 103 - 117 have 3 different build options for using XML::Enc
FROM debian:bookworm-slim AS perlbuilder
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR root
RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests --yes \
dh-make-perl \
git \
perl \
curl \
&& git config --global user.email "perlbuilder@example.com" \
&& git config --global user.name "Perl Builder" \
&& echo perlbuilder > /etc/mailname
## build HTML::PageIndex. It has no deps.
# the 'echo yes' autoconfigures cpan on the first run. Doesn't need to be repeated
RUN echo yes | dh-make-perl --build --cpan HTML::PageIndex
## build Net::SAML2
# install deps for building Net::SAML2
# following items doen't have debian packages and need to be built/installed before Net::SAML2
# - Crypt::OpenSSL::Verify
# - XML::Enc
# - XML::Sig
# - Test::Mock::One
# - URN::OASIS::SAML2
# they are also runtime deps, so we copy them to install them in filesystembuilder (except Test::Mock::One)
# these are the deps for building the cpan deps for Net::SAML2 (below, before the Net::SAML2 build step)
RUN apt-get install --yes \
libimport-into-perl \
libpath-tiny-perl \
libsub-override-perl \
libtest-deep-perl \
libtest-exception-perl \
libtest-fatal-perl \
libtest-lib-perl \
libtest-notabs-perl \
libtest-pod-coverage-perl \
libtest-pod-perl \
libtest-simple-perl \
liburi-perl \
libxml-libxml-perl \
libcrypt-openssl-x509-perl \
libcrypt-openssl-guess-perl \
libcryptx-perl \
libfile-slurper-perl \
libssl-dev \
libtest-exception-perl \
libnamespace-autoclean-perl \
libxml-libxml-perl \
libcrypt-openssl-dsa-perl \
libcrypt-openssl-rsa-perl \
pristine-tar
# these are the Net::SAML2 runtime deps from the buildlog (some are also build deps)
# there are additional runtime deps not listed here, but are installed in the main image
RUN apt-get install --yes \
libcrypt-openssl-bignum-perl \
libcrypt-openssl-random-perl \
libcrypt-openssl-rsa-perl \
#libcrypt-openssl-verify-perl \
libcrypt-openssl-x509-perl \
libdatetime-format-xsd-perl \
libdatetime-hires-perl \
libdatetime-perl \
libfile-slurper-perl \
libhttp-message-perl \
libio-compress-perl \
liblwp-protocol-https-perl \
libmoose-perl \
libmoosex-types-common-perl \
libmoosex-types-datetime-perl \
libmoosex-types-perl \
libmoosex-types-uri-perl \
libnamespace-autoclean-perl \
libscalar-list-utils-perl \
libtry-tiny-perl \
libtypes-serialiser-perl \
liburi-encode-perl \
liburi-perl \
#liburn-oasis-saml2-perl \
libwww-perl \
#libxml-enc-perl \
libxml-generator-perl \
libxml-libxml-perl \
#libxml-sig-perl \
libxml-writer-perl
# the order of these dh-make-perl commands matters
RUN dh-make-perl --install --cpan Test::Mock::One
RUN dh-make-perl --install --cpan Crypt::OpenSSL::Verify
## OPTION 1: the usual way, pulls v0.12 (=current), which fails a test in Net:SAML2's build
RUN dh-make-perl --install --cpan XML::Enc
### OPTION 2: handhold dh-make-perl to install v0.11. Net::SAML2 builds correctly
#ARG PACKAGE=XML-Enc-0.11
## the chown is needed otherwise git balks at unfamiliar UIDs in the extracted tarfile (git called by dh-make-perl)
#RUN curl https://cpan.metacpan.org/authors/id/T/TI/TIMLEGGE/${PACKAGE}.tar.gz -o ${PACKAGE}.tar.gz \
# && tar zxf ${PACKAGE}.tar.gz \
# && chown -R root:root ${PACKAGE} \
# && cd XML-Enc-0.11 && git init && cd - \
# && dh-make-perl --install ${PACKAGE}/
## OPTION 3: install v0.11 with cpanm, but then we don't get a .deb to copy around. Net::SAML2 builds correctly
#RUN apt install cpanminus --yes \
# && cpanm https://cpan.metacpan.org/authors/id/T/TI/TIMLEGGE/XML-Enc-0.11.tar.gz
RUN dh-make-perl --install --cpan XML::Sig
RUN dh-make-perl --install --cpan URN::OASIS::SAML2
RUN dh-make-perl --build --cpan Net::SAML2
# use this line to get docker buildx to print out the buildlog if using cpanm to build stuff
#RUN apt install cpanminus --yes && cpanm Net::SAML2 || cat /root/.cpanm/work/*/build.log && exit 111
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment