build(docker): add JXL, AVIF, and ImageMagick support via updated dependencies (#102)

This commit is contained in:
Adrian Shum 2025-07-21 21:01:29 +08:00 committed by GitHub
parent d01256b982
commit 5408775a46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 58 deletions

View file

@ -1,14 +1,13 @@
name: docker name: docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on: on:
push: push:
branches: [ master ] branches:
- master
tags: [ 'v*.*.*' ] tags: [ 'v*.*.*' ]
pull_request:
branches:
- master
jobs: jobs:
build: build:
@ -17,77 +16,52 @@ jobs:
permissions: permissions:
contents: read contents: read
packages: write packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
# Setup qemu for Docker buildx
- name: Set up QEMU - name: Set up QEMU
id: qemu uses: docker/setup-qemu-action@v3
uses: docker/setup-qemu-action@v2
with: with:
image: tonistiigi/binfmt:latest
platforms: arm64 platforms: arm64
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx - name: Setup Docker buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
with:
version: latest
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v2 if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub - name: Login to Docker Hub
if: github.repository == 'cshum/imagorvideo' if: github.repository == 'cshum/imagorvideo' && github.event_name != 'pull_request'
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata - name: Extract Docker metadata
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@v5
with: with:
images: | images: |
name=${{ format('ghcr.io/{0}', github.repository) }},enable=true name=ghcr.io/${{ github.repository }},enable=true
name=shumc/imagorvideo,enable=${{ github.repository == 'cshum/imagorvideo' }} name=shumc/imagorvideo,enable=${{ github.repository == 'cshum/imagorvideo' }}
tags: | tags: |
type=ref,event=branch type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}} type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
# Build and push Docker image with Buildx (don't push on PR) - name: Build and push Docker image
# https://github.com/docker/build-push-action uses: docker/build-push-action@v5
- name: Build and push Docker image tag
if: startsWith(github.ref, 'refs/tags/v')
id: build-and-push-tag
uses: docker/build-push-action@v3
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: ${{ startsWith(github.ref, 'refs/tags/v') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: true push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker image branch
if: startsWith(github.ref, 'refs/heads')
id: build-and-push-branch
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}

View file

@ -8,8 +8,9 @@ ARG TARGETARCH
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
ENV MAKEFLAGS="-j8" ENV MAKEFLAGS="-j8"
# Installs libvips + required libraries # Installs libvips + FFmpeg + required libraries including modern image formats
RUN DEBIAN_FRONTEND=noninteractive \ RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list && \
DEBIAN_FRONTEND=noninteractive \
apt-get update && \ apt-get update && \
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
ca-certificates \ ca-certificates \
@ -17,10 +18,12 @@ RUN DEBIAN_FRONTEND=noninteractive \
meson ninja-build pkg-config \ meson ninja-build pkg-config \
gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg62-turbo-dev libpng-dev \ gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg62-turbo-dev libpng-dev \
libwebp-dev libtiff-dev libexif-dev libxml2-dev libpoppler-glib-dev \ libwebp-dev libtiff-dev libexif-dev libxml2-dev libpoppler-glib-dev \
swig libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio-dev libopenjp2-7-dev \ swig libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio-dev libopenjp2-7-dev liblcms2-dev \
libgsf-1-dev libfftw3-dev liborc-0.4-dev librsvg2-dev libimagequant-dev libaom-dev libheif-dev \ libgsf-1-dev libfftw3-dev liborc-0.4-dev librsvg2-dev libimagequant-dev libaom-dev \
libspng-dev libcgif-dev libmagickwand-dev \
yasm libx264-dev libx265-dev libnuma-dev libvpx-dev libtheora-dev \ yasm libx264-dev libx265-dev libnuma-dev libvpx-dev libtheora-dev \
libspng-dev libcgif-dev librtmp-dev libvorbis-dev libdav1d-dev && \ librtmp-dev libvorbis-dev libdav1d-dev && \
apt-get install --no-install-recommends -y -t bookworm-backports libheif-dev libheif-plugin-x265 libheif-plugin-aomenc libjxl-dev && \
cd /tmp && \ cd /tmp && \
curl -fsSLO https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz && \ curl -fsSLO https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz && \
tar xf vips-${VIPS_VERSION}.tar.xz && \ tar xf vips-${VIPS_VERSION}.tar.xz && \
@ -30,7 +33,8 @@ RUN DEBIAN_FRONTEND=noninteractive \
--strip \ --strip \
--prefix=/usr/local \ --prefix=/usr/local \
--libdir=lib \ --libdir=lib \
-Dmagick=disabled \ -Dmagick=enabled \
-Djpeg-xl=enabled \
-Dintrospection=disabled && \ -Dintrospection=disabled && \
ninja -C _build && \ ninja -C _build && \
ninja -C _build install && \ ninja -C _build install && \
@ -74,24 +78,24 @@ COPY . .
RUN if [ "$TARGETARCH" = "amd64" ]; then go test ./...; fi RUN if [ "$TARGETARCH" = "amd64" ]; then go test ./...; fi
RUN go build -o ${GOPATH}/bin/imagorvideo ./cmd/imagorvideo/main.go RUN go build -o ${GOPATH}/bin/imagorvideo ./cmd/imagorvideo/main.go
FROM debian:bookworm-slim FROM debian:bookworm-slim as runtime
LABEL maintainer="adrian@cshum.com" LABEL maintainer="adrian@cshum.com"
COPY --from=builder /usr/local/lib /usr/local/lib COPY --from=builder /usr/local/lib /usr/local/lib
COPY --from=builder /etc/ssl/certs /etc/ssl/certs COPY --from=builder /etc/ssl/certs /etc/ssl/certs
# Install runtime dependencies # Install runtime dependencies including modern image formats and ImageMagick
RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list && \ RUN echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list && \
DEBIAN_FRONTEND=noninteractive \ DEBIAN_FRONTEND=noninteractive \
apt-get update && \ apt-get update && \
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
procps libglib2.0-0 libjpeg62-turbo libpng16-16 libopenexr-3-1-30 \ procps curl libglib2.0-0 libjpeg62-turbo libpng16-16 libopenexr-3-1-30 \
libwebp7 libwebpmux3 libwebpdemux2 libtiff6 libexif12 libxml2 libpoppler-glib8 \ libwebp7 libwebpmux3 libwebpdemux2 libtiff6 libexif12 libxml2 libpoppler-glib8 \
libpango1.0-0 libmatio11 libopenslide0 libopenjp2-7 libjemalloc2 \ libpango1.0-0 libmatio11 libopenslide0 libopenjp2-7 libjemalloc2 \
libgsf-1-114 libfftw3-bin liborc-0.4-0 librsvg2-2 libcfitsio10 libimagequant0 libaom3 \ libgsf-1-114 libfftw3-bin liborc-0.4-0 librsvg2-2 libcfitsio10 libimagequant0 libaom3 \
libx264-dev libx265-dev libnuma-dev libvpx7 libtheora0 libvorbis-dev \ libspng0 libcgif0 libdav1d6 libmagickwand-6.q16-6 \
libspng0 libcgif0 libdav1d6 && \ libx264-dev libx265-dev libnuma-dev libvpx7 libtheora0 libvorbis-dev && \
apt-get install --no-install-recommends -y -t bookworm-backports libheif1 && \ apt-get install --no-install-recommends -y -t bookworm-backports libheif1 libheif-plugin-x265 libheif-plugin-aomenc libjxl0.7 && \
ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \ ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \
apt-get autoremove -y && \ apt-get autoremove -y && \
apt-get autoclean && \ apt-get autoclean && \