From ad50b9a3b3824776f35590e13edd5553dec69cec Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Wed, 18 Nov 2026 12:37:15 +0000 Subject: [PATCH] fix(complement): Enable using container builds as a base --- bin/complement | 20 +++++++++++++++++--- docker/complement.Dockerfile | 24 +++++++++++++++++++++--- docs/development/testing.mdx | 14 ++++++++++++++ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/bin/complement b/bin/complement index 1c4281987..0d5a56e98 100755 --- a/bin/complement +++ b/bin/complement @@ -52,8 +52,10 @@ else fi # The base docker image to use for complement tests -# You can build the default with `docker build -t continuwuity:complement -f ./docker/complement.Dockerfile .` -# after running `cargo build -p conduwuit --features openreg`. Only the debug binary is used. +# On Linux, you can build the default with `docker build -t continuwuity:complement -f ./docker/complement.Dockerfile .` +# after running `cargo build -p conduwuit --features openreg`. +# On non-Linux platforms (or to use a container build), build `docker/Dockerfile` with debuginfo and openreg `--build-arg RUST_PROFILE=dev --build-arg CARGO_FEATURES=default,openreg` +# and then run `docker build -t continuwuity:complement --target container -f ./docker/complement.Dockerfile .`. COMPLEMENT_BASE_IMAGE="${COMPLEMENT_BASE_IMAGE:-continuwuity:complement}" # Complement tests that are skipped due to flakiness/reliability issues or we don't implement such features and won't for a long time @@ -83,6 +85,13 @@ for command in docker go jq; do fi done +if [ -z "${DOCKER_HOST:-}" ]; then + DOCKER_HOST="$(docker context inspect --format '{{.Endpoints.docker.Host}}' 2>/dev/null || true)" + if [ -n "$DOCKER_HOST" ]; then + export DOCKER_HOST + fi +fi + if [ -n "$IMAGE_ARCHIVE" ]; then if [ ! -f "$IMAGE_ARCHIVE" ]; then echo "Docker image archive not found: $IMAGE_ARCHIVE" @@ -99,7 +108,12 @@ fi if ! docker image inspect "$COMPLEMENT_BASE_IMAGE" > /dev/null 2>&1; then echo "Complement base image not found: $COMPLEMENT_BASE_IMAGE" - echo "Build it with: cargo build -p conduwuit --features openreg && docker build -t $COMPLEMENT_BASE_IMAGE -f docker/complement.Dockerfile ." + if [ "$(uname -s)" != "Linux" ]; then + echo "Build it with: docker buildx build --load -t continuwuity:latest-openreg --build-arg RUST_PROFILE=dev --build-arg CARGO_FEATURES=default,openreg -f docker/Dockerfile . && docker build -t $COMPLEMENT_BASE_IMAGE --target container -f docker/complement.Dockerfile ." + else + echo "Build it with: cargo build -p conduwuit --features openreg && docker build -t $COMPLEMENT_BASE_IMAGE -f docker/complement.Dockerfile ." + echo "Or from a container build: docker buildx build --load -t continuwuity:latest-openreg --build-arg RUST_PROFILE=dev --build-arg CARGO_FEATURES=default,openreg -f docker/Dockerfile . && docker build -t $COMPLEMENT_BASE_IMAGE --target container -f docker/complement.Dockerfile ." + fi exit 1 fi diff --git a/docker/complement.Dockerfile b/docker/complement.Dockerfile index 1cef3527d..82dd1a970 100644 --- a/docker/complement.Dockerfile +++ b/docker/complement.Dockerfile @@ -1,11 +1,29 @@ -FROM ubuntu:latest +ARG CONTINUWUITY_IMAGE=continuwuity:latest-openreg +ARG BINARY_SOURCE=host + +FROM ${CONTINUWUITY_IMAGE} AS container-binary + +FROM scratch AS host-binary +ARG BINARY_PATH=target/debug/conduwuit +COPY ${BINARY_PATH} /sbin/conduwuit + +FROM ubuntu:latest AS base EXPOSE 8008 EXPOSE 8448 RUN apt-get update && apt-get install -y ca-certificates liburing2 && rm -rf /var/lib/apt/lists/* RUN mkdir -p /etc/continuwuity /var/lib/continuwuity /usr/local/bin/ COPY complement/complement-entrypoint.sh /usr/local/bin/complement-entrypoint.sh COPY complement/complement.config.toml /etc/continuwuity/config.toml -COPY target/debug/conduwuit /usr/local/bin/conduwuit -RUN chmod +x /usr/local/bin/conduwuit /usr/local/bin/complement-entrypoint.sh +RUN chmod +x /usr/local/bin/complement-entrypoint.sh #HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://localhost:8008/_continuwuity/server_version || exit 1 ENTRYPOINT ["/usr/local/bin/complement-entrypoint.sh"] + +FROM base AS container +COPY --from=container-binary /sbin/conduwuit /usr/local/bin/conduwuit +RUN chmod +x /usr/local/bin/conduwuit + +FROM base AS host +COPY --from=host-binary /sbin/conduwuit /usr/local/bin/conduwuit +RUN chmod +x /usr/local/bin/conduwuit + +FROM ${BINARY_SOURCE} diff --git a/docs/development/testing.mdx b/docs/development/testing.mdx index 3e6aa0201..62e9eb1fe 100644 --- a/docs/development/testing.mdx +++ b/docs/development/testing.mdx @@ -20,6 +20,20 @@ docker build -t continuwuity:complement -f docker/complement.Dockerfile . The `openreg` feature is required: without it the server refuses the open registrations Complement uses to create test users, and almost every test fails. +On non-Linux (or to build inside a container instead of on the host), build the Continuwuity image with the `openreg` feature and `RUST_PROFILE=dev` first (open +registration is only enabled when `debug_assertions` are active), then build +the Complement image using the `container` target: + +```bash +docker buildx build --load -t continuwuity:latest-openreg --build-arg RUST_PROFILE=dev --build-arg CARGO_FEATURES=default,openreg -f docker/Dockerfile . +docker build -t continuwuity:complement --target container -f docker/complement.Dockerfile . +./bin/complement +``` + +Pass `--build-arg CONTINUWUITY_IMAGE=your-image:tag` when building +`docker/complement.Dockerfile` if your Continuwuity container image uses a +different tag. + The run can take up to an hour. The runner writes the full Go test stream to `tests/test_results/complement/test_logs.jsonl` and a sorted pass/fail/skip summary to `tests/test_results/complement/test_results.jsonl`. It exits nonzero