FROM node:18-alpine

ARG VIPS_VERSION=8.14.5

RUN apk -U upgrade \
  && apk add \
  bash pkgconf \
  libjpeg-turbo libexif librsvg cgif tiff libspng libimagequant \
  --no-cache \
  && apk add \
  build-base gobject-introspection-dev meson \
  libjpeg-turbo-dev libexif-dev librsvg-dev cgif-dev tiff-dev libspng-dev libimagequant-dev \
  --virtual vips-dependencies \
  --no-cache \
  && wget -O- https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz | tar xJC /tmp \
  && cd /tmp/vips-${VIPS_VERSION} \
  && meson setup build-dir \
  && cd build-dir \
  && ninja \
  && ninja test \
  && ninja install \
  && rm -rf /tmp/vips-${VIPS_VERSION}
