Skip to content

Commit

Permalink
Update Dockerfile to work with the new libvips build system
Browse files Browse the repository at this point in the history
  • Loading branch information
mbklein committed Feb 22, 2023
1 parent b8199ff commit 859b30c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
!package.json
!webpack.config.js
!test.js
!build-sharp.sh
!build-sharp.sh
!build-libvips.sh
36 changes: 16 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 \
Expand All @@ -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
###############################################################################
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions build-libvips.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 859b30c

Please sign in to comment.