kornelski / cavif-rs

AVIF image creator in pure Rust

Home Page:https://lib.rs/cavif

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cavif on Alpine linux

jessedobbelaere opened this issue Β· comments

πŸ‘‹ I use images running PHP on alpine linux, on ARM64 Hetzner instances.

When I download the latest release cavif-1.5.5, unzip and run the linux-generic binary, then I get:

curl -sSL https://github.com/kornelski/cavif-rs/releases/download/v1.5.5/cavif-1.5.5.zip --output cavif.zip && \
    unzip cavif.zip -d cavif && \
    install cavif/linux-generic/cavif /usr/local/bin

cavif --version
/usr/local/bin/cavif: line 0: syntax error: unexpected word (expecting ")")

So I proceeded to build cavif-rs in a rust image specific for platform=linux/arm64, then copying the binary over the alpine image:

FROM rust:latest AS cavif
WORKDIR /build
RUN curl -sSL https://github.com/kornelski/cavif-rs/archive/refs/tags/v1.5.5.zip --output cavif.zip && \
    unzip cavif.zip && \
    mv cavif-rs-1.5.5/* /build && \
    rustup update && \
    cargo install cavif

FROM alpine as cavif-test
RUN apk add libc6-compat gcc make openssl-dev musl-dev linux-headers libintl icu-libs
COPY --from=cavif /usr/local/cargo/bin/cavif /usr/local/bin/
RUN cavif --version

but I end up with new errors:

#11 [cavif-test 4/4] RUN cavif --version
#11 0.035 thread 'main' panicked at library/alloc/src/raw_vec.rs:545:5:
#11 0.035 capacity overflow
#11 0.035 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm not a Rust expert at all. Any clue how I can build/run cavif on an arm64 instance running Alpine linux? I suppose Alpine is missing some essential libraries.

Install Rust from rustup.rs and run cargo install cavif.

Thanks for the suggestion.

I was indeed on the wrong path by building cavif with a Rust container. I installed rustup in an Alpine container, and with some adjustments that seems to do the trick πŸ‘

FROM alpine:latest AS cavif
RUN apk add --no-cache curl gcc musl-dev
SHELL ["/bin/ash", "-o", "pipefail", "-c"]
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
    /root/.cargo/bin/cargo install cavif

FROM craftcms/php-fpm:8.2 AS app
COPY --from=cavif /root/.cargo/bin/cavif /usr/local/bin/cavif
...