The ipx Dockerfile built its dependencies in a layer of stub crates, which any change to Cargo.toml or Cargo.lock invalidated: all of them compiled again in release, 405 crates, 170 s at the builder's cap. The directory's had no such layer and compiled everything every time. Both now build with cargo's registry and target/ as BuildKit cache mounts. Measured on Tower: a Cargo.toml change rebuilds three crates in 52 s instead of 405 in 170 s. The peak is about the same, since the ipx crate itself is most of it; what goes is the minutes at the cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.6 KiB
Docker
30 lines
1.6 KiB
Docker
# ipx-directory (#204). Built from the repo's root: docker buildx build -f Dockerfile.directory .
|
|
# No node here: only ipx's own build runs web/build.mts.
|
|
FROM rust:1-slim-trixie AS build
|
|
# SQLite is compiled from source for sqlx, which needs a C toolchain.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /src
|
|
# Every member of the workspace, since cargo reads them all to build one.
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY crates ./crates
|
|
# The logo and icon the public pages serve (#215), compiled into the binary.
|
|
COPY web/logo.svg web/logo-dark.svg web/favicon.png ./web/
|
|
# Compiled crates kept in the builder between builds, as in the main Dockerfile (#438). A target
|
|
# of its own: built with ipx's, the two would rebuild shared crates for each other's features.
|
|
RUN --mount=type=cache,id=ipx-cargo-registry,target=/usr/local/cargo/registry,sharing=locked \
|
|
--mount=type=cache,id=ipx-directory-target,target=/src/target,sharing=locked \
|
|
touch crates/directory/src/main.rs crates/directory/src/lib.rs crates/feed/src/lib.rs \
|
|
&& cargo build --release --locked -p ipx-directory \
|
|
&& cp target/release/ipx-directory /usr/local/bin/ipx-directory
|
|
|
|
FROM debian:trixie-slim
|
|
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
COPY --from=build /usr/local/bin/ipx-directory /usr/local/bin/ipx-directory
|
|
ENV DIRECTORY_CONFIG=/config/directory.toml
|
|
# Unraid's nobody:users. It writes nothing to disk: the database is elsewhere.
|
|
USER 99:100
|
|
EXPOSE 8100
|
|
CMD ["ipx-directory"]
|