A client sending Accept: application/x-protobuf gets protobuf, and one sending Content-Type: application/x-protobuf may send its body so; JSON stays the default, so the page, the TUI and older iOS builds see nothing new. ipx's own calls to the directory and ipx-play now go in protobuf. The handlers are untouched. A new crate, ipx-wire, holds the .proto files (compiled by protox in build.rs, so no protoc anywhere) and one layer, negotiate, that converts JSON at the edge through prost-reflect, by a table of each route's messages. Writing prost structs beside every serde one would have doubled each type and every handler. Protobuf cannot tell absent from empty or from null, and the PATCH bodies depend on that: an Option<Vec> left out leaves the list, an empty one clears it, and null clears a folder. So a list in a body is a one-field message (absent or present), and null-to-clear is a google.protobuf.Value. Numbers in a Value come back whole, or 3.0 would not read as a usize. Debug builds convert every JSON answer strictly and answer 500 for a field missing from the .proto or a route missing from a table; the cargo tests and the browser suite (125 tests) ran clean that way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2.3 KiB
Docker
49 lines
2.3 KiB
Docker
# Build. rusqlite is bundled (compiles SQLite from source) and librqbit needs a C
|
|
# toolchain, so the builder needs cc. TLS is rustls throughout, so no OpenSSL headers.
|
|
# The pages are ipx-web's (Dockerfile.web), so no node here (#203).
|
|
FROM rust:1-slim-trixie AS build
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /src
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY crates ./crates
|
|
# ipx builds the directory crate in, whose public pages serve these (#215).
|
|
COPY web/logo.svg web/logo-dark.svg web/favicon.png ./web/
|
|
# cargo's registry and target/ are BuildKit cache mounts, kept in the builder between builds, so
|
|
# a Cargo.lock change compiles only the crates that changed (#438): a dependency layer of stub
|
|
# crates went with any change to it and compiled all 500 again, holding the builder's memory cap
|
|
# for minutes. A cache mount is not part of the image, so the binary is copied out in the same
|
|
# step. The workspace's own crates are touched because cargo goes by mtimes and skips a rebuild
|
|
# if they look untouched.
|
|
RUN --mount=type=cache,id=ipx-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \
|
|
--mount=type=cache,id=ipx-target,target=/src/target,sharing=locked \
|
|
touch crates/ipx/src/main.rs crates/ipx/src/lib.rs crates/feed/src/lib.rs \
|
|
crates/directory/src/lib.rs crates/play/src/lib.rs crates/wire/src/lib.rs crates/wire/proto/*.proto \
|
|
&& cargo build --release --locked -p ipx \
|
|
&& cp target/release/ipxd /usr/local/bin/ipxd
|
|
|
|
FROM debian:trixie-slim
|
|
# ffmpeg is DeadAir's (#171): it finds the silences and copies the frames kept. Debian's adds
|
|
# about 480 MB, once: the layer stays cached until the base image changes.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates gosu ffmpeg \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
COPY --from=build /usr/local/bin/ipxd /usr/local/bin/ipxd
|
|
COPY docker-entrypoint.sh /usr/local/bin/
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
|
|
ENV IPX_CONFIG=/config/config.toml \
|
|
IPX_DATA_DIR=/data \
|
|
IPX_LOG=ipx=info \
|
|
PUID=99 \
|
|
PGID=100
|
|
VOLUME ["/config", "/data", "/downloads"]
|
|
|
|
# Web UI, and the BitTorrent peer port (TCP and UDP -- DHT needs the UDP side).
|
|
EXPOSE 8099/tcp 6881/tcp 6881/udp
|
|
|
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
|
CMD ["ipxd", "daemon"]
|