ruby-vips icon indicating copy to clipboard operation
ruby-vips copied to clipboard

libvips & libvips-dev with docker makes the docker image so large

Open houssemFat opened this issue 2 years ago • 2 comments

Hi, thank you for the fantastic work with libvips.

I'm not sure if this is the right repo to report my issue but any help would be appreciated .

I'm using ruby-vips (with active storage for rails) in a docker based on ruby:3.1.3-slim-bullseye. For that, i need to install libvips-dev or libvips (I tested the both). The result docker image size is too large and when i did some inspection i noticed that libvips layer takes a considerable size. I created simple docker file for testing purpose.

Env Mac : MacOs Big Sur , V 11.6 (20G165) , MacBook Air (M1, 2020) Docker version 20.10.13

** Ubuntu :** Ubuntu 22.04.1 LTS Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.3

test Dockerfile for libvips-dev :

FROM ruby:3.1.3-slim-bullseye

RUN bash -c "set -o pipefail  && apt-get update "

RUN bash -c "apt-get install -y libvips-dev"

ENTRYPOINT ["tail", "-f", "/dev/null"]

#CMD ["sh", "-c", "echo 'test'"]

Inspection result

image

I tested the use case with libvips with the example below :

Simple Dockerfile to reproduce the same use case with libvips :

FROM ruby:3.1.3-slim-bullseye

RUN bash -c "set -o pipefail  && apt-get update "

RUN bash -c "set -o pipefail && apt-get install -y libvips"

ENTRYPOINT ["tail", "-f", "/dev/null"]

image

houssemFat avatar Sep 12 '23 23:09 houssemFat

Hi @houssemFat,

The libvips package on Debian recommends the libvips GUI, which in turn brings in most of X. Try --no-install-recommends.

You don't need libvips-dev, you can just use plain libvips.

I see:

$ docker run -it --rm --entrypoint /bin/bash ruby:3.1.3-slim-bullseye 
root@b651079273de:/# apt update && apt upgrade
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
...
root@b651079273de:/# apt install libvips
Reading package lists... Done
...
Need to get 129 MB/135 MB of archives.
After this operation, 507 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
^C

But with --no-install-recommends it's:

root@b651079273de:/# apt install libvips --no-install-recommends
Reading package lists... Done
...
Need to get 37.4 MB/40.5 MB of archives.
After this operation, 146 MB of additional disk space will be used.
Do you want to continue? [Y/n] 

Then install ruby-vips with:

root@b651079273de:/# apt install build-essential
Reading package lists... Done
...
root@b651079273de:/# gem install ruby-vips
Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Successfully installed ruby-vips-2.1.4
2 gems installed
root@b651079273de:/# 

You need build-essential to get the C compiler for the FFI gem.

jcupitt avatar Sep 13 '23 04:09 jcupitt

Hi @jcupitt , thank you for your response. I replaced apt-get install -y --no-install-recommends libvips, the layer size is about 130MB now which very nice comparing to old size. Thank you for your time again.

houssemFat avatar Sep 13 '23 17:09 houssemFat