pigallery2 icon indicating copy to clipboard operation
pigallery2 copied to clipboard

Upgrade sharp package

Open mcdamo opened this issue 4 years ago • 18 comments

sharp v0.23.4 doesn't appear to support PNG on FreeBSD.

Latest compatible sharp is v0.26.3, if this is also supported by ARM then it would be a good upgrade.

mcdamo avatar May 08 '21 07:05 mcdamo

I can take a look. I tried bumping the version already a couple of times: https://github.com/bpatrik/pigallery2/search?q=sharp&type=commits

bpatrik avatar May 09 '21 06:05 bpatrik

No it does not work: https://github.com/bpatrik/pigallery2/runs/2537824403 kép

I wonder if we can actually build it on our own somehow.

bpatrik avatar May 09 '21 07:05 bpatrik

Is there specific reason that we use alpine 3.11? as vips 8.10.0 exist in alpine 3.13.

martadinata666 avatar May 17 '21 10:05 martadinata666

Last time I checked It also failed for debian too, but need to double check that.

Alpine can be updated, that should not be an issue.

bpatrik avatar May 17 '21 20:05 bpatrik

Here is a related issue at sharp: https://github.com/lovell/sharp/issues/2366

Requirements: https://sharp.pixelplumbing.com/install#prebuilt-binaries

The following platforms have prebuilt libvips but not sharp:

    macOS ARM64
    Linux ARMv6
    Linux ARMv7 (glibc >= 2.28)
    Windows ARM64

The following platforms require compilation of both libvips and sharp from source:

    Linux x86
    Linux x64 (glibc <= 2.16, includes RHEL/CentOS 6)
    Linux ARM64 (glibc <= 2.28)
    Linux PowerPC
    FreeBSD
    OpenBSD

bpatrik avatar May 17 '21 20:05 bpatrik

thanks for updating alpine, it build on arm64 and x64 correctly. As the debian has old version vips, somehow we need compile it manually. So i tried few times.

Dockerfile vips building

FROM debian:buster-slim
ARG RELEASE=8.10.6
WORKDIR /vips
RUN apt update && \
    apt install -y --no-install-recommends \
                    build-essential \
                   pkg-config \
                   libglib2.0-dev \
                   libexpat1-dev \
                   libtool \
                   libfftw3-dev \
                   libexif-dev \
                   libgif-dev \
                   libgsf-1-dev \
                   libjpeg-dev \
                   liblcms2-dev \
                   libmagickcore-dev \
                   libmagickwand-dev \
                   libmatio-dev \
                   libopenexr-dev \
                   libopenslide-dev \
                   liborc-0.4-dev \
                   libpango1.0-dev \
                   libpng-dev \
                   libpoppler-glib-dev \
                   librsvg2-dev \
                   libtiff-dev \
                   libwebp-dev \
                   libimagequant-dev \
                   libheif-dev \
                   libcfitsio-dev \
                   zlib1g-dev unzip gtk-doc-tools gobject-introspection && \
                   rm -rf /var/lib/apt/lists/* && \
                   apt clean

ADD https://github.com/libvips/libvips/archive/refs/tags/v$RELEASE.zip /vips
RUN unzip v$RELEASE.zip -d /vips
WORKDIR /vips/libvips-$RELEASE
RUN pwd
RUN ./autogen.sh && make && make install

The vips libs will installed at /usr/local/ path.

martadinata666 avatar May 18 '21 09:05 martadinata666

Unfortunately it failed yesterday, lets give it an other try: 0a46388 kép

bpatrik avatar May 18 '21 21:05 bpatrik

Thanks, @martadinata666

Would you have the time to prepare a PR with the update?

bpatrik avatar May 18 '21 21:05 bpatrik

I see the actions build, the error abt python unavailable, it need change to python2, i can't pull request because im using gitlab so it a bit different, but i will paste the dockerfile i'm using here. I will try create PR to match up your version. python

#-----------------BUILDER-----------------
#-----------------------------------------
FROM node:14-alpine3.13 AS builder
ARG VERSION=1.8.5
RUN apk add --update-cache --repository https://alpine.global.ssl.fastly.net/alpine/v3.13/community/ \
  python2 build-base sqlite-dev sqlite-libs vips-dev fftw-dev gcc g++ make libc6-compat unzip
WORKDIR /app
ADD https://github.com/bpatrik/pigallery2/releases/download/$VERSION/pigallery2-release.zip /app
RUN unzip pigallery2-release.zip -d /app
RUN npm install --unsafe-perm
RUN mkdir -p /app/data/config && \
    mkdir -p /app/data/db && \
    mkdir -p /app/data/images && \
    mkdir -p /app/data/tmp


#-----------------MAIN--------------------
#-----------------------------------------
FROM node:14-alpine3.13 AS main
WORKDIR /app
ENV NODE_ENV=production \
    # overrides only the default value of the settings (the actualy value can be overwritten through config.json)
    default-Server-Database-dbFolder=/app/data/db \
    default-Server-Media-folder=/app/data/images \
    default-Server-Media-tempFolder=/app/data/tmp \
    # flagging dockerized environemnt
    PI_DOCKER=true
EXPOSE 80
RUN apk add --update-cache --repository https://alpine.global.ssl.fastly.net/alpine/v3.13/community/ \
    vips ffmpeg
COPY --from=builder --chown=node:node /app /app
USER node
VOLUME ["/app/data/config", "/app/data/db", "/app/data/images", "/app/data/tmp"]
HEALTHCHECK --interval=40s --timeout=30s --retries=3 --start-period=60s \
  CMD wget --quiet --tries=1 --no-check-certificate --spider \
  http://localhost:80/heartbeat || exit 1
# after a extensive job (like video converting), pigallery calls gc, to clean up everthing as fast as possible
# Exec form entrypoint is need otherwise (using shell form) ENV variables are not properly passed down to the app
ENTRYPOINT ["node", "./src/backend/index", "--expose-gc",  "--config-path=/app/data/config/config.json"]

martadinata666 avatar May 18 '21 23:05 martadinata666

yeah I'll fix (instead of just try-and-fail push my code) it up once I have a few hours to spare.

bpatrik avatar May 19 '21 19:05 bpatrik

As this sharp version stuck thing, i suggest to drop Alpine armv7 image or build only arm64 + x64, doesn't really worth save few MBs ~80MBs and preventing us to support new image format. 🤔

martadinata666 avatar Feb 07 '22 12:02 martadinata666

Alright. Lets give it a try. It seems that with buster armv7 still works (which I need for my rpi 4), but with stretch and alpine not anymore. But the arm64 and amd64 are ok with all three.

My issue that docker hub says that people are also using the armv7 version of alpine and stretch too, but I could not figure how much. (Like if one person using, that is ok, but if that is the main platform than I cannot really remove it.)

With f44e9eb and f44e9eb I give this a try. Lets see if people will complain.

FYI: last time I tried to upgrade to node v16, it was sharp again that caused the issue (0.23 does not run with node16 anymore). So it needs a solution anyway in the near future.

bpatrik avatar Feb 07 '22 19:02 bpatrik

Usually when buster/stretch cant run bullseye image related to this package `libseccomp2

dpkg-query -W libseccomp2

Should be 2.5+ to make it run docker container with bullseye, alpine 3.14+ afaik. If this is the case, we can add some notes to force user to upgrade the package.

martadinata666 avatar Feb 07 '22 19:02 martadinata666

That is fine. I only build Debian stretch, buster and alpine docker images at the moment.

bpatrik avatar Feb 07 '22 20:02 bpatrik

I rethink again, isnt it weird dropping armv7 on stretch / alpine3.13? As majority of stretch usually at 32bit which is armv7?

martadinata666 avatar Feb 08 '22 01:02 martadinata666

I'm a bit worried about alpine (its actually 3.15, not 3.13). Stretch not that much, we can probably just drop it.

Raspbian has buster for more than 2 years and bullseye since oct: https://en.wikipedia.org/wiki/Raspberry_Pi_OS

RPI only has 64bit OS since a few days: https://www.raspberrypi.com/news/raspberry-pi-os-64-bit/

bpatrik avatar Feb 08 '22 12:02 bpatrik

Once alpine also has prebuilt libvips 8.12.2 package: https://pkgs.alpinelinux.org/packages?name=vips&branch=v3.15. We can add sharp v0.30.0 support for alpine armv7 again.

Until then its buster only. Stretch we can def. drop. LTS also end in july.

bpatrik avatar Feb 08 '22 12:02 bpatrik

We can go v0.30.1 , this issue https://github.com/lovell/sharp/issues/3066 on v0.30.0 making thumbnail generation blurry 👍🏼

martadinata666 avatar Feb 10 '22 04:02 martadinata666

tried to reenable sharp on arm, but since the latest sharp bump to 0.30.1, it needs Prebuilt libvips 8.13.3 binaries. Once node alppine will have 3.17, it should work: https://pkgs.alpinelinux.org/packages?name=vips&branch=v3.17&repo=&arch=&maintainer=

bpatrik avatar Nov 29 '22 21:11 bpatrik

works now.

bpatrik avatar Jan 07 '23 14:01 bpatrik