build(docker): add JXL, AVIF, and ImageMagick support via updated dependencies (#102)
This commit is contained in:
parent
d01256b982
commit
5408775a46
2 changed files with 36 additions and 58 deletions
66
.github/workflows/docker.yml
vendored
66
.github/workflows/docker.yml
vendored
|
|
@ -1,14 +1,13 @@
|
|||
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:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches:
|
||||
- master
|
||||
tags: [ 'v*.*.*' ]
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -17,77 +16,52 @@ jobs:
|
|||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
# This is used to complete the identity challenge
|
||||
# with sigstore/fulcio when running outside of PRs.
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Setup qemu for Docker buildx
|
||||
- name: Set up QEMU
|
||||
id: qemu
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
image: tonistiigi/binfmt:latest
|
||||
platforms: arm64
|
||||
|
||||
# Workaround: https://github.com/docker/build-push-action/issues/461
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
version: latest
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# Login against a Docker registry except on PR
|
||||
# https://github.com/docker/login-action
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Login to Docker Hub
|
||||
if: github.repository == 'cshum/imagorvideo'
|
||||
uses: docker/login-action@v2
|
||||
if: github.repository == 'cshum/imagorvideo' && github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# Extract metadata (tags, labels) for Docker
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
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' }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
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)
|
||||
# https://github.com/docker/build-push-action
|
||||
- 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
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
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
|
||||
platforms: ${{ startsWith(github.ref, 'refs/tags/v') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
|
|
|||
28
Dockerfile
28
Dockerfile
|
|
@ -8,8 +8,9 @@ ARG TARGETARCH
|
|||
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||
ENV MAKEFLAGS="-j8"
|
||||
|
||||
# Installs libvips + required libraries
|
||||
RUN DEBIAN_FRONTEND=noninteractive \
|
||||
# Installs libvips + FFmpeg + required libraries including modern image formats
|
||||
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 install --no-install-recommends -y \
|
||||
ca-certificates \
|
||||
|
|
@ -17,10 +18,12 @@ RUN DEBIAN_FRONTEND=noninteractive \
|
|||
meson ninja-build pkg-config \
|
||||
gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg62-turbo-dev libpng-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 \
|
||||
libgsf-1-dev libfftw3-dev liborc-0.4-dev librsvg2-dev libimagequant-dev libaom-dev libheif-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 \
|
||||
libspng-dev libcgif-dev libmagickwand-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 && \
|
||||
curl -fsSLO https://github.com/libvips/libvips/releases/download/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz && \
|
||||
tar xf vips-${VIPS_VERSION}.tar.xz && \
|
||||
|
|
@ -30,7 +33,8 @@ RUN DEBIAN_FRONTEND=noninteractive \
|
|||
--strip \
|
||||
--prefix=/usr/local \
|
||||
--libdir=lib \
|
||||
-Dmagick=disabled \
|
||||
-Dmagick=enabled \
|
||||
-Djpeg-xl=enabled \
|
||||
-Dintrospection=disabled && \
|
||||
ninja -C _build && \
|
||||
ninja -C _build install && \
|
||||
|
|
@ -74,24 +78,24 @@ COPY . .
|
|||
RUN if [ "$TARGETARCH" = "amd64" ]; then go test ./...; fi
|
||||
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"
|
||||
|
||||
COPY --from=builder /usr/local/lib /usr/local/lib
|
||||
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 && \
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get update && \
|
||||
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 \
|
||||
libpango1.0-0 libmatio11 libopenslide0 libopenjp2-7 libjemalloc2 \
|
||||
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 && \
|
||||
apt-get install --no-install-recommends -y -t bookworm-backports libheif1 && \
|
||||
libspng0 libcgif0 libdav1d6 libmagickwand-6.q16-6 \
|
||||
libx264-dev libx265-dev libnuma-dev libvpx7 libtheora0 libvorbis-dev && \
|
||||
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 && \
|
||||
apt-get autoremove -y && \
|
||||
apt-get autoclean && \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue