From 8e2eacb1b06797346d98757e6079d681a124dd0c Mon Sep 17 00:00:00 2001 From: infi Date: Mon, 24 Aug 2026 19:56:15 +0200 Subject: [PATCH] fix: internal server error when uploading AVIF (#937) * fix: add avif feature to dependencies the comment should also say decode, encode uses rav1e not dav1d Signed-off-by: infi * chore: upgrade to debian 13 Signed-off-by: infi * fix: revert unrelated EOF newlines Signed-off-by: infi * ci: provide dav1d also in nix Signed-off-by: infi * chore: move feature definition to autumn Cargo.toml Signed-off-by: infi * fix: avif feature also required in revolt-files Signed-off-by: infi --------- Signed-off-by: infi --- .github/workflows/rust.yaml | 12 +- .mise/config.toml | 1 + Cargo.lock | 183 +++++++++++++++++++++++- Cargo.toml | 2 +- Dockerfile | 3 +- Dockerfile.useCurrentArch | 3 +- crates/bonfire/Dockerfile | 4 +- crates/core/files/Cargo.toml | 2 +- crates/daemons/crond/Dockerfile | 4 +- crates/daemons/pushd/Dockerfile | 4 +- crates/daemons/voice-ingress/Dockerfile | 4 +- crates/delta/Dockerfile | 4 +- crates/services/autumn/Cargo.toml | 2 +- crates/services/autumn/Dockerfile | 11 +- crates/services/gifbox/Dockerfile | 2 +- crates/services/january/Dockerfile | 11 +- default.nix | 2 + 17 files changed, 228 insertions(+), 26 deletions(-) diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index 99f218ee..a6e7d6c2 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -26,6 +26,16 @@ jobs: # run: | # sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc + - name: Install dav1d + run: | + sudo apt-get update + sudo apt-get install --yes libdav1d-dev pkg-config + + if ! pkg-config --atleast-version=1.3.0 dav1d; then + echo "The runner's dav1d is older than 1.3, will install build tools" + sudo apt-get install --yes meson ninja-build nasm + fi + - name: Setup Mise uses: immich-app/devtools/actions/use-mise@cd24790a7f5f6439ac32cc94f5523cb2de8bfa8c # use-mise-action-v1.1.0 with: @@ -33,7 +43,7 @@ jobs: - run: mise build - run: mise docker:start - + - name: Reference Test env: TEST_DB: REFERENCE diff --git a/.mise/config.toml b/.mise/config.toml index 331ba797..17bade80 100644 --- a/.mise/config.toml +++ b/.mise/config.toml @@ -21,6 +21,7 @@ run = [{ task = "service:*" }] [env] BUILDER = "cargo" +SYSTEM_DEPS_DAV1D_BUILD_INTERNAL = "auto" # enable building dav1d iff the system doesn't have a new enough version DOCKER_NETWORK_NAME = "stoatchat_default" DATABASE_PORT = "27017" RABBIT_PORT = "5672" diff --git a/Cargo.lock b/Cargo.lock index c0347df2..7eb8f049 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -472,6 +472,19 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" +[[package]] +name = "av-data" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fca67ba5d317924c02180c576157afd54babe48a76ebc66ce6d34bb8ba08308e" +dependencies = [ + "byte-slice-cast", + "bytes", + "num-derive", + "num-rational", + "num-traits", +] + [[package]] name = "av-scenechange" version = "0.14.1" @@ -1234,6 +1247,15 @@ version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" +[[package]] +name = "bitreader" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "886559b1e163d56c765bc3a985febb4eee8009f625244511d8ee3c432e08c066" +dependencies = [ + "cfg-if", +] + [[package]] name = "bitstream-io" version = "4.10.0" @@ -1360,6 +1382,12 @@ version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" +[[package]] +name = "byte-slice-cast" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7575182f7272186991736b70173b0ea045398f984bf5ebbb3804736ce1330c9d" + [[package]] name = "bytemuck" version = "1.25.0" @@ -1477,6 +1505,16 @@ dependencies = [ "uuid", ] +[[package]] +name = "cfg-expr" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb693542bcafa528e198be0ebd9d3632ca5b7c93dbe7237460e199910835997c" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.4" @@ -2122,6 +2160,28 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" +[[package]] +name = "dav1d" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ee89cb860616069c67520dcd66cacdb900b57c799f634a0eb6d91f6e2a82b61" +dependencies = [ + "av-data", + "bitflags 2.13.0", + "dav1d-sys", + "static_assertions", +] + +[[package]] +name = "dav1d-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c91aea6668645415331133ed6f8ddf0e7f40160cd97a12d59e68716a58704b" +dependencies = [ + "libc", + "system-deps", +] + [[package]] name = "deadqueue" version = "0.2.5" @@ -2676,6 +2736,15 @@ dependencies = [ "zune-inflate", ] +[[package]] +name = "fallible_collections" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88c69768c0a15262df21899142bc6df9b9b823546d4b4b9a7bc2d6c448ec6fd" +dependencies = [ + "hashbrown 0.13.2", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -3329,6 +3398,9 @@ name = "hashbrown" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.12", +] [[package]] name = "hashbrown" @@ -3952,10 +4024,12 @@ dependencies = [ "bytemuck", "byteorder-lite", "color_quant", + "dav1d", "exr", "gif 0.14.2", "image-webp 0.2.4", "moxcms", + "mp4parse", "num-traits", "png 0.18.1", "qoi", @@ -5182,6 +5256,20 @@ dependencies = [ "pxfm", ] +[[package]] +name = "mp4parse" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63a35203d3c6ce92d5251c77520acb2e57108c88728695aa883f70023624c570" +dependencies = [ + "bitreader", + "byteorder", + "fallible_collections", + "log", + "num-traits", + "static_assertions", +] + [[package]] name = "multer" version = "3.1.0" @@ -8643,6 +8731,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +dependencies = [ + "serde_core", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -8965,6 +9062,12 @@ dependencies = [ "loom", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strict-num" version = "0.1.1" @@ -9187,6 +9290,19 @@ dependencies = [ "libc", ] +[[package]] +name = "system-deps" +version = "7.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396a35feb67335377e0251fcbc1092fc85c484bd4e3a7a54319399da127796e7" +dependencies = [ + "cfg-expr", + "heck 0.5.0", + "pkg-config", + "toml 1.1.4+spec-1.1.0", + "version-compare", +] + [[package]] name = "tagptr" version = "0.2.0" @@ -9205,6 +9321,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "target-lexicon" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" + [[package]] name = "tcp-stream" version = "0.34.14" @@ -9539,11 +9661,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" dependencies = [ "serde", - "serde_spanned", - "toml_datetime", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", "toml_edit 0.22.27", ] +[[package]] +name = "toml" +version = "1.1.4+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5" +dependencies = [ + "indexmap 2.14.0", + "serde_core", + "serde_spanned 1.1.1", + "toml_datetime 1.1.1+spec-1.1.0", + "toml_parser", + "toml_writer", + "winnow 1.0.4", +] + [[package]] name = "toml_datetime" version = "0.6.11" @@ -9553,6 +9690,15 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "1.1.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +dependencies = [ + "serde_core", +] + [[package]] name = "toml_edit" version = "0.19.15" @@ -9560,7 +9706,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.14.0", - "toml_datetime", + "toml_datetime 0.6.11", "winnow 0.5.40", ] @@ -9572,18 +9718,33 @@ checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" dependencies = [ "indexmap 2.14.0", "serde", - "serde_spanned", - "toml_datetime", + "serde_spanned 0.6.9", + "toml_datetime 0.6.11", "toml_write", "winnow 0.7.15", ] +[[package]] +name = "toml_parser" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" +dependencies = [ + "winnow 1.0.4", +] + [[package]] name = "toml_write" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" +[[package]] +name = "toml_writer" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" + [[package]] name = "totp-lite" version = "2.0.1" @@ -10173,6 +10334,12 @@ dependencies = [ "time", ] +[[package]] +name = "version-compare" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e" + [[package]] name = "version_check" version = "0.9.5" @@ -10817,6 +10984,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" + [[package]] name = "winreg" version = "0.50.0" diff --git a/Cargo.toml b/Cargo.toml index 5a0f8fee..7fc8d2b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -133,7 +133,7 @@ jxl-oxide = "0.12.5" sha2 = "0.10.8" kamadak-exif = "0.5.4" webp = "0.3.0" -image = "0.25.2" # avif encode requires dav1d system library: features = ["avif-native"] +image = "0.25.2" thumbhash = "0.1.0" lcms2 = "6.1.1" # for color profile processing diff --git a/Dockerfile b/Dockerfile index ec61859b..9f4e1250 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build Stage -FROM --platform="${BUILDPLATFORM}" rust:1.92.0-slim-bookworm +FROM --platform="${BUILDPLATFORM}" rust:1.92.0-slim-trixie USER 0:0 WORKDIR /home/rust/src @@ -14,6 +14,7 @@ RUN apt-get update && \ apt-get install -y \ make \ pkg-config \ + libdav1d-dev:"${TARGETARCH}" \ libssl-dev:"${TARGETARCH}" COPY scripts/build-image-layer.sh /tmp/ RUN sh /tmp/build-image-layer.sh tools diff --git a/Dockerfile.useCurrentArch b/Dockerfile.useCurrentArch index 37ab8248..0d25b19c 100644 --- a/Dockerfile.useCurrentArch +++ b/Dockerfile.useCurrentArch @@ -1,5 +1,5 @@ # Build Stage -FROM rust:1.92.0-slim-bookworm +FROM rust:1.92.0-slim-trixie USER 0:0 WORKDIR /home/rust/src @@ -11,6 +11,7 @@ RUN apt-get update && \ apt-get install -y \ make \ pkg-config \ + libdav1d-dev \ libssl-dev COPY scripts/build-image-layer.sh /tmp/ diff --git a/crates/bonfire/Dockerfile b/crates/bonfire/Dockerfile index 9a608d93..d55b8f7d 100644 --- a/crates/bonfire/Dockerfile +++ b/crates/bonfire/Dockerfile @@ -1,9 +1,9 @@ # Build Stage FROM ghcr.io/stoatchat/base:latest AS builder -FROM debian:12 AS debian +FROM debian:13 AS debian # Bundle Stage -FROM gcr.io/distroless/cc-debian12:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot COPY --from=builder /home/rust/src/target/release/revolt-bonfire ./ COPY --from=debian /usr/bin/uname /usr/bin/uname diff --git a/crates/core/files/Cargo.toml b/crates/core/files/Cargo.toml index dbd57ec0..0fce543c 100644 --- a/crates/core/files/Cargo.toml +++ b/crates/core/files/Cargo.toml @@ -34,7 +34,7 @@ revolt-result = { workspace = true } # image processing jxl-oxide = { workspace = true, features = ["image"] } -image = { workspace = true } +image = { workspace = true, features = ["avif-native"] } # AVIF decoding requires dav1d # svg rendering usvg = { workspace = true } diff --git a/crates/daemons/crond/Dockerfile b/crates/daemons/crond/Dockerfile index f1852457..697e7f82 100644 --- a/crates/daemons/crond/Dockerfile +++ b/crates/daemons/crond/Dockerfile @@ -1,9 +1,9 @@ # Build Stage FROM ghcr.io/stoatchat/base:latest AS builder -FROM debian:12 AS debian +FROM debian:13 AS debian # Bundle Stage -FROM gcr.io/distroless/cc-debian12:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot COPY --from=builder /home/rust/src/target/release/revolt-crond ./ COPY --from=debian /usr/bin/uname /usr/bin/uname diff --git a/crates/daemons/pushd/Dockerfile b/crates/daemons/pushd/Dockerfile index 38bfbc0e..f4df1f21 100644 --- a/crates/daemons/pushd/Dockerfile +++ b/crates/daemons/pushd/Dockerfile @@ -1,9 +1,9 @@ # Build Stage FROM ghcr.io/stoatchat/base:latest AS builder -FROM debian:12 AS debian +FROM debian:13 AS debian # Bundle Stage -FROM gcr.io/distroless/cc-debian12:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot COPY --from=builder /home/rust/src/target/release/revolt-pushd ./ COPY --from=debian /usr/bin/uname /usr/bin/uname diff --git a/crates/daemons/voice-ingress/Dockerfile b/crates/daemons/voice-ingress/Dockerfile index 18d82e4b..590e9135 100644 --- a/crates/daemons/voice-ingress/Dockerfile +++ b/crates/daemons/voice-ingress/Dockerfile @@ -1,9 +1,9 @@ # Build Stage FROM ghcr.io/stoatchat/base:latest AS builder -FROM debian:12 AS debian +FROM debian:13 AS debian # Bundle Stage -FROM gcr.io/distroless/cc-debian12:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot COPY --from=builder /home/rust/src/target/release/revolt-voice-ingress ./ COPY --from=debian /usr/bin/uname /usr/bin/uname diff --git a/crates/delta/Dockerfile b/crates/delta/Dockerfile index 7537ec51..dc70e7d0 100644 --- a/crates/delta/Dockerfile +++ b/crates/delta/Dockerfile @@ -1,9 +1,9 @@ # Build Stage FROM ghcr.io/stoatchat/base:latest AS builder -FROM debian:12 AS debian +FROM debian:13 AS debian # Bundle Stage -FROM gcr.io/distroless/cc-debian12:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot COPY --from=builder /home/rust/src/target/release/revolt-delta ./ COPY --from=debian /usr/bin/uname /usr/bin/uname diff --git a/crates/services/autumn/Cargo.toml b/crates/services/autumn/Cargo.toml index 7ab39b2b..6baea84d 100644 --- a/crates/services/autumn/Cargo.toml +++ b/crates/services/autumn/Cargo.toml @@ -16,7 +16,7 @@ sha2 = { workspace = true } jxl-oxide = { workspace = true } kamadak-exif = { workspace = true } # revolt_little_exif = "0.5.1" -image = { workspace = true } +image = { workspace = true, features = ["avif-native"] } # note: avif decoding requires dav1d on the system thumbhash = { workspace = true } lcms2 = { workspace = true } diff --git a/crates/services/autumn/Dockerfile b/crates/services/autumn/Dockerfile index 940703fe..1eb469af 100644 --- a/crates/services/autumn/Dockerfile +++ b/crates/services/autumn/Dockerfile @@ -1,10 +1,17 @@ # Build Stage FROM ghcr.io/stoatchat/base:latest AS builder -FROM debian:12 AS debian +FROM debian:13 AS debian +RUN apt-get update && \ + apt-get install -y --no-install-recommends libdav1d7 && \ + mkdir -p /runtime-libs && \ + for library in /usr/lib/*-linux-gnu/libdav1d.so.7*; do \ + cp -a --parents "$library" /runtime-libs; \ + done # Bundle Stage -FROM gcr.io/distroless/cc-debian12:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot COPY --from=builder /home/rust/src/target/release/revolt-autumn ./ +COPY --from=debian /runtime-libs/ / COPY --from=mwader/static-ffmpeg:7.1.1 /ffmpeg /usr/local/bin/ COPY --from=mwader/static-ffmpeg:7.1.1 /ffprobe /usr/local/bin/ COPY --from=debian /usr/bin/uname /usr/bin/uname diff --git a/crates/services/gifbox/Dockerfile b/crates/services/gifbox/Dockerfile index a6af49ee..097e147b 100644 --- a/crates/services/gifbox/Dockerfile +++ b/crates/services/gifbox/Dockerfile @@ -2,7 +2,7 @@ FROM ghcr.io/stoatchat/base:latest AS builder # Bundle Stage -FROM gcr.io/distroless/cc-debian12:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot COPY --from=builder /home/rust/src/target/release/revolt-gifbox ./ EXPOSE 14706 diff --git a/crates/services/january/Dockerfile b/crates/services/january/Dockerfile index 35d812ea..86292ae5 100644 --- a/crates/services/january/Dockerfile +++ b/crates/services/january/Dockerfile @@ -1,10 +1,17 @@ # Build Stage FROM ghcr.io/stoatchat/base:latest AS builder -FROM debian:12 AS debian +FROM debian:13 AS debian +RUN apt-get update && \ + apt-get install -y --no-install-recommends libdav1d7 && \ + mkdir -p /runtime-libs && \ + for library in /usr/lib/*-linux-gnu/libdav1d.so.7*; do \ + cp -a --parents "$library" /runtime-libs; \ + done # Bundle Stage -FROM gcr.io/distroless/cc-debian12:nonroot +FROM gcr.io/distroless/cc-debian13:nonroot COPY --from=builder /home/rust/src/target/release/revolt-january ./ +COPY --from=debian /runtime-libs/ / COPY --from=mwader/static-ffmpeg:7.1.1 /ffmpeg /usr/local/bin/ COPY --from=mwader/static-ffmpeg:7.1.1 /ffprobe /usr/local/bin/ COPY --from=debian /usr/bin/uname /usr/bin/uname diff --git a/default.nix b/default.nix index 68fb5384..58221d83 100644 --- a/default.nix +++ b/default.nix @@ -11,6 +11,7 @@ let stdenv.cc.cc.lib zlib openssl.out + dav1d ]; pathsToLink = [ "/lib" ]; }; @@ -27,6 +28,7 @@ in pkgs.mkShell { buildInputs = with pkgs; [ pkg-config openssl.dev + dav1d ]; shellHook = ''