From 859b30ca0c17e663db914d04308579bc9c9ec3bf 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 | 36 ++++++++++++++++-------------------- build-libvips.sh | 12 ++++++++++++ 3 files changed, 30 insertions(+), 21 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..51be216 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,7 @@ # Use AWS Lambda node build environment FROM public.ecr.aws/sam/build-nodejs16.x:latest -ARG GHOSTSCRIPT_VERSION=9.52 \ - LIBVIPS_VERSION=8.12.1 + # Update all existing packages RUN yum update -y @@ -26,12 +25,12 @@ RUN yum install -y tar gzip libjpeg-devel libpng-devel libtiff-devel libwebp-dev ############################################################################### # 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 @@ -40,19 +39,22 @@ 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 openjpeg2 openjpeg2-devel openjpeg2-tools -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 +RUN curl https://codeload.github.com/libvips/libvips/tar.gz/v${LIBVIPS_VERSION} | tar zxv WORKDIR /root/libvips-${LIBVIPS_VERSION} -RUN ./autogen.sh --prefix=/opt -RUN ./configure --prefix=/opt -RUN make install +COPY build-libvips.sh . +RUN ./build-libvips.sh ############################################################################### # RPM dependencies @@ -64,7 +66,7 @@ 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 \ @@ -74,15 +76,9 @@ RUN yumdownloader libjpeg-turbo.x86_64 libpng.x86_64 libtiff.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 +94,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..8d7d32d --- /dev/null +++ b/build-libvips.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +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