Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit cbb45fe

Browse files
committed
Build for Ruby 2.7
1 parent 3a5c506 commit cbb45fe

File tree

4 files changed

+155
-82
lines changed

4 files changed

+155
-82
lines changed

Dockerfile

Lines changed: 106 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,139 @@ FROM lambci/lambda:build-ruby2.7
22

33
WORKDIR /build
44

5-
ARG VIPS_VERSION=8.9.1
6-
ARG IMAGEQUANT_VERSION=2.12.6
5+
ARG VIPS_VERSION=8.9.2
76

8-
ENV WORKDIR="/build"
9-
ENV INSTALLDIR="/opt"
107
ENV VIPS_VERSION=$VIPS_VERSION
11-
ENV IMAGEQUANT_VERSION=$IMAGEQUANT_VERSION
8+
ENV PATH=/opt/bin:$PATH
9+
ENV LD_LIBRARY_PATH=/opt/lib:/opt/lib64:$LD_LIBRARY_PATH
10+
ENV PKG_CONFIG_PATH=/opt/lib/pkgconfig:/opt/lib64/pkgconfig
1211

1312
# Setup Some Dirs
1413
#
1514
RUN mkdir -p \
1615
share/lib \
16+
share/lib64 \
1717
share/include
1818

19-
# Install xpat
19+
# Install expat
2020
#
21-
RUN yum install -y expat-devel
21+
RUN curl https://codeload.github.com/libexpat/libexpat/zip/R_2_2_9 > libexpat-R_2_2_9.zip && \
22+
unzip libexpat-R_2_2_9.zip && \
23+
cd ./libexpat-R_2_2_9/expat && \
24+
./buildconf.sh && \
25+
./configure --prefix=/opt && \
26+
make install
2227

23-
# Install libimagequant. Details: https://github.com/libvips/libvips/pull/1009
28+
RUN cp -a /opt/lib/libexpat.so* /build/share/lib
29+
30+
# Install libpng
31+
#
32+
RUN curl -L https://downloads.sourceforge.net/libpng/libpng-1.6.37.tar.xz > libpng-1.6.37.tar.xz && \
33+
tar -xf libpng-1.6.37.tar.xz && \
34+
cd libpng-1.6.37 && \
35+
./configure --prefix=/opt --disable-static && \
36+
make && \
37+
make install
38+
39+
RUN cp -a /opt/lib/libpng.so* /build/share/lib && \
40+
cp -a /opt/lib/libpng16.so* /build/share/lib
41+
42+
# Install giflib
43+
#
44+
RUN curl -L https://sourceforge.net/projects/giflib/files/giflib-5.2.1.tar.gz > giflib-5.2.1.tar.gz && \
45+
tar -xf giflib-5.2.1.tar.gz && \
46+
cd giflib-5.2.1 && \
47+
make && \
48+
make PREFIX=/opt install
49+
50+
RUN cp -a /opt/lib/libgif.so* /build/share/lib
51+
52+
# Install libjpeg-turbo
53+
#
54+
RUN curl -L https://downloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-2.0.4.tar.gz > libjpeg-turbo-2.0.4.tar.gz && \
55+
tar -xf libjpeg-turbo-2.0.4.tar.gz && \
56+
cd libjpeg-turbo-2.0.4 && \
57+
cmake -DCMAKE_INSTALL_PREFIX=/opt && \
58+
make && \
59+
make install
60+
61+
RUN cp -a /opt/lib64/libjpeg.so* /build/share/lib && \
62+
cp -a /opt/lib64/libturbojpeg.so* /build/share/lib
63+
64+
# Install libimagequant
2465
#
25-
RUN git clone git://github.com/ImageOptim/libimagequant.git && \
66+
RUN git clone https://github.com/ImageOptim/libimagequant.git && \
2667
cd ./libimagequant && \
27-
git checkout "${IMAGEQUANT_VERSION}" && \
28-
CC=clang CXX=clang++ ./configure --prefix=/opt && \
68+
git checkout 2.12.6 && \
69+
./configure --prefix=/opt && \
2970
make libimagequant.so && \
3071
make install && \
3172
echo /opt/lib > /etc/ld.so.conf.d/libimagequant.conf && \
3273
ldconfig
33-
RUN cp -a $INSTALLDIR/lib/libimagequant.so* $WORKDIR/share/lib/ && \
34-
cp -a $INSTALLDIR/include/libimagequant.h $WORKDIR/share/include/
3574

75+
RUN cp -a /opt/lib/libimagequant.so* /build/share/lib/ && \
76+
cp -a /opt/include/libimagequant.h /build/share/include/
3677

37-
# Install deps for libvips. Details: https://libvips.github.io/libvips/install.html
78+
# Install libvips. Primary deps https://libvips.github.io/libvips/install.html
3879
#
3980
RUN yum install -y \
40-
gtk-doc \
41-
gobject-introspection \
42-
gobject-introspection-devel
81+
gtk-doc \
82+
ninja-build
4383

44-
# Clone repo and checkout version tag.
45-
#
46-
RUN git clone git://github.com/libvips/libvips.git && \
47-
cd libvips && \
48-
git checkout "v${VIPS_VERSION}"
84+
RUN pip3 install meson && \
85+
pip3 install ninja
86+
87+
RUN curl -L http://ftp.gnome.org/pub/gnome/sources/glib/2.64/glib-2.64.2.tar.xz > glib-2.64.2.tar.xz && \
88+
tar -xf glib-2.64.2.tar.xz && \
89+
cd glib-2.64.2 && \
90+
mkdir ./_build && \
91+
cd ./_build && \
92+
meson --prefix=/opt .. && \
93+
ninja && \
94+
ninja install
4995

50-
# Compile from source.
96+
RUN cp -a /opt/lib64/libffi.so* /build/share/lib && \
97+
cp -a /opt/lib64/libglib-2.0.so* /build/share/lib && \
98+
cp -a /opt/lib64/libgmodule-2.0.so* /build/share/lib && \
99+
cp -a /opt/lib64/libgobject-2.0.so* /build/share/lib && \
100+
cp -a /opt/lib64/libgthread-2.0.so* /build/share/lib
101+
102+
RUN curl -L http://ftp.gnome.org/pub/gnome/sources/gobject-introspection/1.64/gobject-introspection-1.64.1.tar.xz > gobject-introspection-1.64.1.tar.xz && \
103+
tar -xf gobject-introspection-1.64.1.tar.xz && \
104+
cd gobject-introspection-1.64.1 && \
105+
mkdir ./_build && \
106+
cd ./_build && \
107+
meson --prefix=/opt .. && \
108+
ninja && \
109+
ninja install
110+
111+
# Install libvips.
51112
#
52-
RUN cd ./libvips && \
53-
CC=clang CXX=clang++ \
54-
IMAGEQUANT_CFLAGS="-I/opt/include" \
55-
IMAGEQUANT_LIBS="-L/opt/lib -limagequant" \
56-
./autogen.sh \
57-
--prefix=${INSTALLDIR} \
58-
--disable-static && \
59-
make install && \
60-
echo /opt/lib > /etc/ld.so.conf.d/libvips.conf && \
61-
ldconfig
62-
63-
# Copy only needed so files to new share/lib.
113+
RUN curl -L https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz > vips-${VIPS_VERSION}.tar.gz && \
114+
tar -xf vips-${VIPS_VERSION}.tar.gz && \
115+
cd vips-${VIPS_VERSION} && \
116+
./configure \
117+
--prefix=/opt \
118+
--disable-gtk-doc \
119+
--without-magick \
120+
--with-expat=/opt && \
121+
make && \
122+
make install && \
123+
echo /opt/lib > /etc/ld.so.conf.d/libvips.conf && \
124+
ldconfig
125+
126+
RUN cp -a /opt/lib/libvips.so* /build/share/lib
127+
128+
# Store the VIPS_VERSION variable in a file, accessible to the deploy script.
64129
#
65-
RUN mkdir -p share/lib && \
66-
cp -a $INSTALLDIR/lib/libvips.so* $WORKDIR/share/lib/
67-
68-
# Copy glib and gobject with their deps over.
69-
RUN cd ./share/lib/ && \
70-
cp /usr/lib64/libglib-2.0* . && \
71-
cp /usr/lib64/libgobject-2.0* . && \
72-
cp /usr/lib64/libgthread-2.0* . && \
73-
cp /usr/lib64/libgmodule-2.0* . && \
74-
cp /usr/lib64/libexpat* . && \
75-
ldconfig
130+
RUN echo $VIPS_VERSION > "./share/VIPS_VERSION"
76131

77-
# Zip up contents so final `lib` can be placed in /opt layer.
132+
# Create an /opt/lib64 symlink for linked objects.
78133
#
79134
RUN cd ./share && \
80-
zip --symlinks -r libvips.zip .
135+
ln -s /opt/lib /opt/lib64
81136

82-
# Store the VIPS_VERSION variable in a file, accessible to the deploy script.
137+
# Zip up contents so final `lib` can be placed in /opt layer.
83138
#
84-
RUN echo $VIPS_VERSION >> $WORKDIR/share/.VIPS_VERSION
139+
RUN cd ./share && \
140+
zip --symlinks -r libvips.zip .

README.md

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,46 @@ Lastly, we were happy to find that `glib` and `gobject` were already installed a
2929

3030
## Contents
3131

32-
Current size of the layer's un-compressed contents is around `15MB` in size.
32+
Current size of the layer's un-compressed contents is around `21MB` in size. Contents include:
3333

3434
```shell
3535
$ ls -lAGp /opt/lib
36-
-rwxr-xr-x 1 root 201K Apr 27 20:30 libexpat.so
37-
-rwxr-xr-x 1 root 201K Apr 27 20:30 libexpat.so.1
38-
-rwxr-xr-x 1 root 201K Apr 27 20:30 libexpat.so.1.6.0
39-
-rwxr-xr-x 1 root 1.1M Apr 27 20:30 libglib-2.0.so
40-
-rwxr-xr-x 1 root 1.1M Apr 27 20:30 libglib-2.0.so.0
41-
-rwxr-xr-x 1 root 1.1M Apr 27 20:30 libglib-2.0.so.0.5600.1
42-
-rwxr-xr-x 1 root 15K Apr 27 20:30 libgmodule-2.0.so
43-
-rwxr-xr-x 1 root 15K Apr 27 20:30 libgmodule-2.0.so.0
44-
-rwxr-xr-x 1 root 15K Apr 27 20:30 libgmodule-2.0.so.0.5600.1
45-
-rwxr-xr-x 1 root 327K Apr 27 20:30 libgobject-2.0.so
46-
-rwxr-xr-x 1 root 327K Apr 27 20:30 libgobject-2.0.so.0
47-
-rwxr-xr-x 1 root 327K Apr 27 20:30 libgobject-2.0.so.0.5600.1
48-
-rwxr-xr-x 1 root 6.7K Apr 27 20:30 libgthread-2.0.so
49-
-rwxr-xr-x 1 root 6.7K Apr 27 20:30 libgthread-2.0.so.0
50-
-rwxr-xr-x 1 root 6.7K Apr 27 20:30 libgthread-2.0.so.0.5600.1
51-
lrwxrwxrwx 1 root 18B Apr 27 20:26 libimagequant.so -> libimagequant.so.0
52-
-rw-r--r-- 1 root 65K Apr 27 20:26 libimagequant.so.0
53-
lrwxrwxrwx 1 root 18B Apr 27 20:29 libvips.so -> libvips.so.42.12.2
54-
lrwxrwxrwx 1 root 18B Apr 27 20:29 libvips.so.42 -> libvips.so.42.12.2
55-
-rwxr-xr-x 1 root 9.6M Apr 27 20:29 libvips.so.42.12.2
36+
lrwxrwxrwx 1 root 18B Apr 29 23:53 libexpat.so -> libexpat.so.1.6.11
37+
lrwxrwxrwx 1 root 18B Apr 29 23:53 libexpat.so.1 -> libexpat.so.1.6.11
38+
-rwxr-xr-x 1 root 543K Apr 29 23:53 libexpat.so.1.6.11
39+
lrwxrwxrwx 1 root 11B Apr 29 23:53 libffi.so -> libffi.so.7
40+
lrwxrwxrwx 1 root 15B Apr 29 23:53 libffi.so.7 -> libffi.so.7.1.0
41+
-rwxr-xr-x 1 root 158K Apr 29 23:53 libffi.so.7.1.0
42+
lrwxrwxrwx 1 root 11B Apr 29 23:53 libgif.so -> libgif.so.7
43+
lrwxrwxrwx 1 root 15B Apr 29 23:53 libgif.so.7 -> libgif.so.7.2.0
44+
-rwxr-xr-x 1 root 36K Apr 29 23:53 libgif.so.7.2.0
45+
lrwxrwxrwx 1 root 16B Apr 29 23:53 libglib-2.0.so -> libglib-2.0.so.0
46+
lrwxrwxrwx 1 root 23B Apr 29 23:53 libglib-2.0.so.0 -> libglib-2.0.so.0.6400.2
47+
-rwxr-xr-x 1 root 4.7M Apr 29 23:53 libglib-2.0.so.0.6400.2
48+
lrwxrwxrwx 1 root 19B Apr 29 23:53 libgmodule-2.0.so -> libgmodule-2.0.so.0
49+
lrwxrwxrwx 1 root 26B Apr 29 23:53 libgmodule-2.0.so.0 -> libgmodule-2.0.so.0.6400.2
50+
-rwxr-xr-x 1 root 49K Apr 29 23:53 libgmodule-2.0.so.0.6400.2
51+
lrwxrwxrwx 1 root 19B Apr 29 23:53 libgobject-2.0.so -> libgobject-2.0.so.0
52+
lrwxrwxrwx 1 root 26B Apr 29 23:53 libgobject-2.0.so.0 -> libgobject-2.0.so.0.6400.2
53+
-rwxr-xr-x 1 root 1.7M Apr 29 23:53 libgobject-2.0.so.0.6400.2
54+
lrwxrwxrwx 1 root 19B Apr 29 23:53 libgthread-2.0.so -> libgthread-2.0.so.0
55+
lrwxrwxrwx 1 root 26B Apr 29 23:53 libgthread-2.0.so.0 -> libgthread-2.0.so.0.6400.2
56+
-rwxr-xr-x 1 root 14K Apr 29 23:53 libgthread-2.0.so.0.6400.2
57+
lrwxrwxrwx 1 root 18B Apr 29 23:53 libimagequant.so -> libimagequant.so.0
58+
-rw-r--r-- 1 root 85K Apr 29 23:53 libimagequant.so.0
59+
lrwxrwxrwx 1 root 13B Apr 29 23:53 libjpeg.so -> libjpeg.so.62
60+
lrwxrwxrwx 1 root 17B Apr 29 23:53 libjpeg.so.62 -> libjpeg.so.62.3.0
61+
-rwxr-xr-x 1 root 464K Apr 29 23:53 libjpeg.so.62.3.0
62+
lrwxrwxrwx 1 root 11B Apr 29 23:53 libpng.so -> libpng16.so
63+
lrwxrwxrwx 1 root 19B Apr 29 23:53 libpng16.so -> libpng16.so.16.37.0
64+
lrwxrwxrwx 1 root 19B Apr 29 23:53 libpng16.so.16 -> libpng16.so.16.37.0
65+
-rwxr-xr-x 1 root 891K Apr 29 23:53 libpng16.so.16.37.0
66+
lrwxrwxrwx 1 root 17B Apr 29 23:53 libturbojpeg.so -> libturbojpeg.so.0
67+
lrwxrwxrwx 1 root 21B Apr 29 23:53 libturbojpeg.so.0 -> libturbojpeg.so.0.2.0
68+
-rwxr-xr-x 1 root 583K Apr 29 23:53 libturbojpeg.so.0.2.0
69+
lrwxrwxrwx 1 root 18B Apr 29 23:53 libvips.so -> libvips.so.42.12.2
70+
lrwxrwxrwx 1 root 18B Apr 29 23:53 libvips.so.42 -> libvips.so.42.12.2
71+
-rwxr-xr-x 1 root 11M Apr 29 23:53 libvips.so.42.12.2
5672

5773
$ ls -lAGp /opt/include
58-
-rw-r--r-- 1 root 6942 Jan 30 18:08 libimagequant.h
59-
```
74+
-rw-r--r-- 1 root 6.8K Apr 29 23:53 libimagequant.h```

bin/build

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
set -e
44

5-
IMAGE_NAME=ruby-vips-lambda
6-
VIPS_VERSION=${VIPS_VERSION:=8.9.2}
5+
export IMAGE_NAME=ruby-vips-lambda
6+
export VIPS_VERSION=${VIPS_VERSION:=8.9.2}
77

88
rm -rf ./share
99
mkdir ./share
1010

1111
docker build \
1212
--no-cache \
1313
--build-arg VIPS_VERSION=${VIPS_VERSION} \
14-
-t $IMAGE_NAME .
14+
--tag $IMAGE_NAME \
15+
.
1516

16-
docker run --rm \
17-
-v "${PWD}/share:/share" \
18-
$IMAGE_NAME \
19-
sh -c "cp /build/share/{libvips.zip,.VIPS_VERSION} /share"
17+
docker run \
18+
--rm \
19+
--volume "${PWD}/share:/share" \
20+
"${IMAGE_NAME}:latest" \
21+
sh -c "cp -r /build/share/* /share"

bin/deploy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set -e
44

55
./bin/build
66

7-
VIPS_VERSION=$(cat share/.VIPS_VERSION)
8-
LAYER_NAME="rubyvips${VIPS_VERSION//./}-27"
7+
export VIPS_VERSION=$(cat share/VIPS_VERSION)
8+
export LAYER_NAME="rubyvips${VIPS_VERSION//./}-27"
99

1010
aws lambda publish-layer-version \
1111
--layer-name $LAYER_NAME \

0 commit comments

Comments
 (0)