Skip to content

Instantly share code, notes, and snippets.

@d30jeff
Last active April 1, 2020 01:34
Show Gist options
  • Save d30jeff/857c55741b8aa39590c9ebd3402328b8 to your computer and use it in GitHub Desktop.
Save d30jeff/857c55741b8aa39590c9ebd3402328b8 to your computer and use it in GitHub Desktop.
libvips libimagequant
FROM amazonlinux:2
# general build stuff
RUN yum update -y \
&& yum groupinstall -y "Development Tools" \
&& yum install -y wget tar
# libvips needs libwebp 0.5 or later and the one on amazonlinux2 is 0.3.0, so
# we have to build it ourselves
# packages needed by libwebp
RUN yum install -y \
libjpeg-devel \
libpng-devel \
libtiff-devel \
libgif-devel \
&& ldconfig
# stuff we need to build our own libvips ... this is a pretty basic selection
# of dependencies, you'll want to adjust these
# dzsave needs libgsf
RUN yum install -y \
libpng-devel \
glib2-devel \
libjpeg-devel \
expat-devel \
zlib-devel \
orc-devel \
lcms2-devel \
libexif-devel \
libgsf-devel \
&& ldconfig
# openslide is in epel -- extra packages for enterprise linux
RUN yum install -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y \
openslide-devel \
&& ldconfig
# Install libimagequant
RUN cd /usr/local/src \
&& wget https://github.com/ImageOptim/libimagequant/archive/2.12.6.tar.gz \
&& tar xf 2.12.6.tar.gz \
&& cd libimagequant-2.12.6 \
&& ./configure \
&& make \
&& make install \
&& ldconfig
# non-standard stuff we build from source goes here
ENV VIPSHOME /usr/local/vips
ENV PKG_CONFIG_PATH $VIPSHOME/lib/pkgconfig
ARG WEBP_VERSION=1.0.2
ARG WEBP_URL=https://storage.googleapis.com/downloads.webmproject.org/releases/webp
RUN cd /usr/local/src \
&& wget ${WEBP_URL}/libwebp-${WEBP_VERSION}.tar.gz \
&& tar xzf libwebp-${WEBP_VERSION}.tar.gz \
&& cd libwebp-${WEBP_VERSION} \
&& ./configure --enable-libwebpmux --enable-libwebpdemux \
--prefix=$VIPSHOME \
&& make V=0 \
&& make install \
&& ldconfig
ARG VIPS_VERSION=8.9.1
ARG VIPS_URL=https://github.com/libvips/libvips/releases/download
RUN cd /usr/local/src \
&& wget ${VIPS_URL}/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz \
&& tar xzf vips-${VIPS_VERSION}.tar.gz \
&& cd vips-${VIPS_VERSION} \
&& ./configure --prefix=$VIPSHOME \
&& make V=0 \
&& make install \
&& ldconfig
RUN ls $VIPSHOME/lib
# Download sample PNG image
RUN cd /usr/local/src \
&& wget https://i.imgur.com/ych5v6c.png -O input.png -P src/
COPY ./src /usr/local/src
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash \
&& . ~/.nvm/nvm.sh \
&& nvm install 12.12.0
RUN cd /usr/local/src \
&& . ~/.nvm/nvm.sh \
&& npm install sharp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment