Skip to content

Commit 3f05ae4

Browse files
committed
Update Dockerfile to work with the new libvips build system
1 parent b8199ff commit 3f05ae4

File tree

4 files changed

+56
-26
lines changed

4 files changed

+56
-26
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
!package.json
44
!webpack.config.js
55
!test.js
6-
!build-sharp.sh
6+
!build-sharp.sh
7+
!build-libvips.sh

Dockerfile

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
###############################################################################
99

1010
# Use AWS Lambda node build environment
11-
FROM public.ecr.aws/sam/build-nodejs16.x:latest
11+
FROM public.ecr.aws/sam/build-nodejs16.x:latest AS core
12+
1213

13-
ARG GHOSTSCRIPT_VERSION=9.52 \
14-
LIBVIPS_VERSION=8.12.1
1514
# Update all existing packages
1615
RUN yum update -y
1716

@@ -21,39 +20,60 @@ ENV CFLAGS "-Os"
2120
ENV CXXFLAGS $CFLAGS
2221

2322
# RUN yum groupinstall "Development Tools"
24-
RUN yum install -y tar gzip libjpeg-devel libpng-devel libtiff-devel libwebp-devel
23+
RUN yum install -y tar gzip giflib-devel libjpeg-devel libpng-devel libtiff-devel
2524

2625
###############################################################################
2726
# GhostScript
2827
###############################################################################
28+
ARG GHOSTSCRIPT_VERSION=9.52
2929

3030
WORKDIR /root
3131

32-
RUN curl -LO \
33-
https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/ghostscript-${GHOSTSCRIPT_VERSION}.tar.gz
34-
RUN tar zxvf ghostscript-${GHOSTSCRIPT_VERSION}.tar.gz
32+
RUN curl -Lv \
33+
https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/ghostscript-${GHOSTSCRIPT_VERSION}.tar.gz | tar zxv
3534

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

4039
###############################################################################
41-
# libvips
40+
# libwebp
4241
###############################################################################
42+
ARG LIBWEBP_VERSION=1.3.0
4343

4444
WORKDIR /root
4545

46-
RUN yum install -y gtk-doc gobject-introspection-devel expat-devel openjpeg2 openjpeg2-devel openjpeg2-tools
46+
RUN curl https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${LIBWEBP_VERSION}.tar.gz | tar zxv
4747

48-
RUN curl -o libvips-${LIBVIPS_VERSION}.tar.gz \
49-
https://codeload.github.com/libvips/libvips/tar.gz/v${LIBVIPS_VERSION}
50-
RUN tar zxvf libvips-${LIBVIPS_VERSION}.tar.gz
48+
WORKDIR /root/libwebp-${LIBWEBP_VERSION}
5149

52-
WORKDIR /root/libvips-${LIBVIPS_VERSION}
53-
RUN ./autogen.sh --prefix=/opt
5450
RUN ./configure --prefix=/opt
51+
RUN make
5552
RUN make install
5653

54+
###############################################################################
55+
# libvips
56+
###############################################################################
57+
ARG LIBVIPS_VERSION=8.14.1
58+
59+
RUN pip3 install meson \
60+
&& curl -Lo /tmp/ninja-linux.zip https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip \
61+
&& unzip -d /usr/local/bin /tmp/ninja-linux.zip \
62+
&& rm /tmp/ninja-linux.zip
63+
64+
WORKDIR /root
65+
66+
RUN yum install -y gtk-doc gobject-introspection-devel expat-devel lcms2-devel openjpeg2 openjpeg2-devel openjpeg2-tools
67+
68+
RUN curl https://codeload.github.com/libvips/libvips/tar.gz/v${LIBVIPS_VERSION} | tar zxv
69+
70+
WORKDIR /root/libvips-${LIBVIPS_VERSION}
71+
72+
FROM core
73+
74+
COPY build-libvips.sh .
75+
RUN ./build-libvips.sh
76+
5777
###############################################################################
5878
# RPM dependencies
5979
###############################################################################
@@ -64,25 +84,20 @@ WORKDIR /root
6484
RUN yum install -y yum-utils rpmdevtools
6585

6686
RUN mkdir rpms
67-
WORKDIR rpms
87+
WORKDIR /root/rpms
6888

6989
# Download dependency RPMs
7090
RUN yumdownloader libjpeg-turbo.x86_64 libpng.x86_64 libtiff.x86_64 \
71-
libgomp.x86_64 libwebp.x86_64 jbigkit-libs.x86_64 openjpeg2.x86_64 \
72-
glib2.x86_64 libmount.x86_64 libblkid.x86_64 libwebp.x86_64
91+
libgomp.x86_64 jbigkit-libs.x86_64 openjpeg2.x86_64 \
92+
glib2.x86_64 libmount.x86_64 libblkid.x86_64 giflib.x86_64 \
93+
lcms2.x86_64
7394

7495
# Extract RPMs
7596
RUN rpmdev-extract *.rpm
7697
RUN rm *.rpm
77-
78-
# Copy all package files into /opt/rpms
98+
RUN for d in $(find . -name lib64 -type d); do mv $d ${d%%64}; done
7999
RUN cp -vR */usr/* /opt
80100

81-
# The x86_64 packages extract as lib64, we need to move these files to lib
82-
RUN yum install -y rsync
83-
RUN rsync -av /opt/lib64/ /opt/lib/
84-
RUN rm -r /opt/lib64
85-
86101
###############################################################################
87102
# Node Dependencies
88103
###############################################################################
@@ -98,7 +113,7 @@ WORKDIR /root
98113
RUN mkdir -p sharp
99114
COPY build-sharp.sh /root/sharp
100115
WORKDIR /root/sharp
101-
RUN PKG_CONFIG_PATH=/opt/lib/pkgconfig ./build-sharp.sh
116+
RUN PKG_CONFIG_PATH=/opt/lib/pkgconfig:/opt/lib64/pkgconfig ./build-sharp.sh
102117

103118
###############################################################################
104119
# Zip all dependencies

build-libvips.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/opt/lib/pkgconfig
4+
if [[ -e ./autogen.sh ]]; then
5+
./autogen.sh --prefix=/opt
6+
./configure --prefix=/opt
7+
make install
8+
else
9+
meson setup build --prefix /opt --libdir lib
10+
cd build
11+
meson compile
12+
meson install
13+
fi

template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Resources:
1313
- nodejs16.x
1414
- nodejs18.x
1515
LicenseInfo: Apache-2.0
16+
RetentionPolicy: Retain
1617
LayerPermission:
1718
Type: AWS::Lambda::LayerVersionPermission
1819
Properties:

0 commit comments

Comments
 (0)