From 3f05ae4ceaaffa8be9c34047ac336b9cf64905c8 Mon Sep 17 00:00:00 2001 From: "Michael B. Klein" Date: Tue, 21 Feb 2023 21:21:19 +0000 Subject: [PATCH] Update Dockerfile to work with the new libvips build system --- .dockerignore | 3 ++- Dockerfile | 65 +++++++++++++++++++++++++++++------------------- build-libvips.sh | 13 ++++++++++ template.yml | 1 + 4 files changed, 56 insertions(+), 26 deletions(-) create mode 100755 build-libvips.sh diff --git a/.dockerignore b/.dockerignore index ade3b37..e184be7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,5 @@ !package.json !webpack.config.js !test.js -!build-sharp.sh \ No newline at end of file +!build-sharp.sh +!build-libvips.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8590c9b..86089e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,10 +8,9 @@ ############################################################################### # Use AWS Lambda node build environment -FROM public.ecr.aws/sam/build-nodejs16.x:latest +FROM public.ecr.aws/sam/build-nodejs16.x:latest AS core + -ARG GHOSTSCRIPT_VERSION=9.52 \ - LIBVIPS_VERSION=8.12.1 # Update all existing packages RUN yum update -y @@ -21,39 +20,60 @@ ENV CFLAGS "-Os" ENV CXXFLAGS $CFLAGS # RUN yum groupinstall "Development Tools" -RUN yum install -y tar gzip libjpeg-devel libpng-devel libtiff-devel libwebp-devel +RUN yum install -y tar gzip giflib-devel libjpeg-devel libpng-devel libtiff-devel ############################################################################### # GhostScript ############################################################################### +ARG GHOSTSCRIPT_VERSION=9.52 WORKDIR /root -RUN curl -LO \ - https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/ghostscript-${GHOSTSCRIPT_VERSION}.tar.gz -RUN tar zxvf ghostscript-${GHOSTSCRIPT_VERSION}.tar.gz +RUN curl -Lv \ + https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/ghostscript-${GHOSTSCRIPT_VERSION}.tar.gz | tar zxv WORKDIR /root/ghostscript-${GHOSTSCRIPT_VERSION} RUN ./configure --prefix=/opt RUN make install ############################################################################### -# libvips +# libwebp ############################################################################### +ARG LIBWEBP_VERSION=1.3.0 WORKDIR /root -RUN yum install -y gtk-doc gobject-introspection-devel expat-devel openjpeg2 openjpeg2-devel openjpeg2-tools +RUN curl https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${LIBWEBP_VERSION}.tar.gz | tar zxv -RUN curl -o libvips-${LIBVIPS_VERSION}.tar.gz \ - https://codeload.github.com/libvips/libvips/tar.gz/v${LIBVIPS_VERSION} -RUN tar zxvf libvips-${LIBVIPS_VERSION}.tar.gz +WORKDIR /root/libwebp-${LIBWEBP_VERSION} -WORKDIR /root/libvips-${LIBVIPS_VERSION} -RUN ./autogen.sh --prefix=/opt RUN ./configure --prefix=/opt +RUN make RUN make install +############################################################################### +# libvips +############################################################################### +ARG LIBVIPS_VERSION=8.14.1 + +RUN pip3 install meson \ + && curl -Lo /tmp/ninja-linux.zip https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip \ + && unzip -d /usr/local/bin /tmp/ninja-linux.zip \ + && rm /tmp/ninja-linux.zip + +WORKDIR /root + +RUN yum install -y gtk-doc gobject-introspection-devel expat-devel lcms2-devel openjpeg2 openjpeg2-devel openjpeg2-tools + +RUN curl https://codeload.github.com/libvips/libvips/tar.gz/v${LIBVIPS_VERSION} | tar zxv + +WORKDIR /root/libvips-${LIBVIPS_VERSION} + +FROM core + +COPY build-libvips.sh . +RUN ./build-libvips.sh + ############################################################################### # RPM dependencies ############################################################################### @@ -64,25 +84,20 @@ WORKDIR /root RUN yum install -y yum-utils rpmdevtools RUN mkdir rpms -WORKDIR rpms +WORKDIR /root/rpms # Download dependency RPMs RUN yumdownloader libjpeg-turbo.x86_64 libpng.x86_64 libtiff.x86_64 \ - libgomp.x86_64 libwebp.x86_64 jbigkit-libs.x86_64 openjpeg2.x86_64 \ - glib2.x86_64 libmount.x86_64 libblkid.x86_64 libwebp.x86_64 + libgomp.x86_64 jbigkit-libs.x86_64 openjpeg2.x86_64 \ + glib2.x86_64 libmount.x86_64 libblkid.x86_64 giflib.x86_64 \ + lcms2.x86_64 # Extract RPMs RUN rpmdev-extract *.rpm RUN rm *.rpm - -# Copy all package files into /opt/rpms +RUN for d in $(find . -name lib64 -type d); do mv $d ${d%%64}; done RUN cp -vR */usr/* /opt -# The x86_64 packages extract as lib64, we need to move these files to lib -RUN yum install -y rsync -RUN rsync -av /opt/lib64/ /opt/lib/ -RUN rm -r /opt/lib64 - ############################################################################### # Node Dependencies ############################################################################### @@ -98,7 +113,7 @@ WORKDIR /root RUN mkdir -p sharp COPY build-sharp.sh /root/sharp WORKDIR /root/sharp -RUN PKG_CONFIG_PATH=/opt/lib/pkgconfig ./build-sharp.sh +RUN PKG_CONFIG_PATH=/opt/lib/pkgconfig:/opt/lib64/pkgconfig ./build-sharp.sh ############################################################################### # Zip all dependencies diff --git a/build-libvips.sh b/build-libvips.sh new file mode 100755 index 0000000..5b999a8 --- /dev/null +++ b/build-libvips.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/opt/lib/pkgconfig +if [[ -e ./autogen.sh ]]; then + ./autogen.sh --prefix=/opt + ./configure --prefix=/opt + make install +else + meson setup build --prefix /opt --libdir lib + cd build + meson compile + meson install +fi diff --git a/template.yml b/template.yml index 1283e04..e730880 100644 --- a/template.yml +++ b/template.yml @@ -13,6 +13,7 @@ Resources: - nodejs16.x - nodejs18.x LicenseInfo: Apache-2.0 + RetentionPolicy: Retain LayerPermission: Type: AWS::Lambda::LayerVersionPermission Properties: