Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile to work with new libvips build system #4

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
65 changes: 40 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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-nodejs18.x:latest AS core


ARG GHOSTSCRIPT_VERSION=9.52 \
LIBVIPS_VERSION=8.12.1
# Update all existing packages
RUN yum update -y

Expand All @@ -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=10.01.2
ARG GHOSTSCRIPT_URL=https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs10012/ghostscript-${GHOSTSCRIPT_VERSION}.tar.gz

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 ${GHOSTSCRIPT_URL} | tar zxv

WORKDIR /root/ghostscript-${GHOSTSCRIPT_VERSION}
RUN ./configure --prefix=/opt
RUN make install

###############################################################################
# libvips
# libwebp
###############################################################################
ARG LIBWEBP_VERSION=1.3.1

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.2

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