Skip to content

Commit cf4c016

Browse files
committed
add libvips on heroku22
1 parent 45287c7 commit cf4c016

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

libvips-heroku22/Dockerfile

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
FROM heroku/heroku:22
2+
3+
# generic build tools ... libgsf needs intltool
4+
RUN apt-get update \
5+
&& apt-get install -y \
6+
build-essential \
7+
wget \
8+
python3-pip \
9+
ninja-build \
10+
pkg-config
11+
12+
RUN pip3 install meson
13+
14+
# use the heroku platform libraries when we can
15+
#
16+
# see https://devcenter.heroku.com/articles/stack-packages
17+
#
18+
# this should only pull in header files and should not create any extra run
19+
# time dependencies
20+
RUN apt-get install -y \
21+
glib-2.0-dev \
22+
libexpat1-dev \
23+
libpango1.0-dev \
24+
librsvg2-dev \
25+
libpng-dev \
26+
libwebp-dev \
27+
libjpeg-turbo8-dev \
28+
libtiff5-dev \
29+
libexif-dev \
30+
liblcms2-dev \
31+
libgsf-1-dev \
32+
liborc-0.4-dev \
33+
libimagequant-dev \
34+
libcgif-dev \
35+
libheif-dev \
36+
libfftw3-dev
37+
38+
WORKDIR /usr/local/src
39+
40+
# build to this prefix
41+
# - heroku has /usr/local/lib on the default ld.so.conf search path, so
42+
# this is convenient
43+
# - heroku has a basic dir structure in /usr/local, but no files
44+
ARG PREFIX=/usr/local
45+
ENV PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
46+
47+
# last updated 16sep23
48+
ARG PDFIUM_VERSION=6002
49+
ARG PDFIUM_URL=https://github.com/bblanchon/pdfium-binaries/releases/download/chromium
50+
51+
RUN wget $PDFIUM_URL/$PDFIUM_VERSION/pdfium-linux-x64.tgz \
52+
&& mkdir pdfium \
53+
&& cd pdfium \
54+
&& tar xf ../pdfium-linux-x64.tgz \
55+
&& cp lib/* $PREFIX/lib \
56+
&& cp -r include/* $PREFIX/include
57+
58+
# make a pdfium.pc file libvips can use
59+
RUN mkdir -p $PREFIX/lib/pkgconfig \
60+
&& cd $PREFIX/lib/pkgconfig \
61+
&& echo "prefix=$PREFIX" >> pdfium.pc \
62+
&& echo "exec_prefix=\${prefix}" >> pdfium.pc \
63+
&& echo "libdir=\${exec_prefix}/lib" >> pdfium.pc \
64+
&& echo "includedir=\${prefix}/include" >> pdfium.pc \
65+
&& echo "Name: pdfium" >> pdfium.pc \
66+
&& echo "Description: pdfium" >> pdfium.pc \
67+
&& echo "Version: $PDFIUM_VERSION" >> pdfium.pc \
68+
&& echo "Requires: " >> pdfium.pc \
69+
&& echo "Libs: -L\${libdir} -lpdfium" >> pdfium.pc \
70+
&& echo "Cflags: -I\${includedir}" >> pdfium.pc
71+
72+
# use libspng for PNG load and save
73+
ARG SPNG_VERSION=0.7.4
74+
ARG SPNG_URL=https://github.com/randy408/libspng/archive/refs/tags
75+
76+
RUN wget ${SPNG_URL}/v${SPNG_VERSION}.tar.gz \
77+
&& tar xf v${SPNG_VERSION}.tar.gz \
78+
&& cd libspng-${SPNG_VERSION} \
79+
&& meson build --prefix=${PREFIX} --libdir=lib \
80+
&& cd build \
81+
&& ninja \
82+
&& ninja install
83+
84+
ARG VIPS_VERSION=8.14.4
85+
ARG VIPS_URL=https://github.com/libvips/libvips/releases/download
86+
87+
RUN wget ${VIPS_URL}/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz \
88+
&& tar xf vips-${VIPS_VERSION}.tar.xz \
89+
&& cd vips-${VIPS_VERSION} \
90+
&& meson setup build \
91+
--prefix=$PREFIX \
92+
--libdir=lib \
93+
--buildtype=release \
94+
-Dradiance=false \
95+
-Danalyze=false \
96+
-Dintrospection=false \
97+
&& cd build \
98+
&& meson compile \
99+
&& meson install
100+
101+
# clean and package
102+
RUN cd $PREFIX \
103+
&& cp -r lib libvips-heroku22 \
104+
&& cd libvips-heroku22 \
105+
&& strip lib*.so* \
106+
&& strip vips-modules-8.14/*.so \
107+
&& rm -rf pkgconfig \
108+
&& rm -rf python* \
109+
&& tar cfz ../libvips-heroku22.tar.gz * \
110+
&& echo built libvips-heroku22.tar.gz \
111+
&& ls -l $PREFIX/libvips-heroku22.tar.gz
112+
113+
# install and test ruby-vips to confirm we can pick up the libraries
114+
# correctly
115+
# we need ruby-dev to install ruby-ffi
116+
ENV LD_LIBRAY_PATH=$PREFIX/lib
117+
RUN apt-get install -y ruby-dev
118+
RUN gem install ruby-vips
119+
RUN ruby -e 'require "vips"; puts "ruby-vips: libvips #{Vips::LIBRARY_VERSION}"'

libvips-heroku22/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# libvips on heroku 22
2+
3+
This uses platform libraries when we can. It builds to `/usr/local/vips` in the
4+
container, so tar that up and send it off to s3 or whatever ready to deploy.
5+
6+
# Rebuild the image
7+
8+
```
9+
docker pull heroku/heroku:22
10+
docker build -t libvips-heroku22 .
11+
```
12+
13+
# TODO
14+
15+
- check the size of the binary tarball, and the size on disc
16+
- strip a bit more?
17+
- remove C++ libs and headers?
18+
- pull the packaged tarball back out of the container
16.7 MB
Binary file not shown.

0 commit comments

Comments
 (0)