From f317447b7702640d84b1484ed0b56d8b69ed5167 Mon Sep 17 00:00:00 2001 From: Matthias Ahouansou Date: Tue, 15 Jul 2025 21:50:23 +0100 Subject: [PATCH] tests: make complement work & switch to Caddyfile --- bin/complement | 2 +- complement/Caddyfile | 30 ++++++++++++++++++ complement/Dockerfile | 11 ++++--- complement/caddy.json | 72 ------------------------------------------- 4 files changed, 38 insertions(+), 77 deletions(-) create mode 100644 complement/Caddyfile delete mode 100644 complement/caddy.json diff --git a/bin/complement b/bin/complement index 291953dd..a3d296e1 100755 --- a/bin/complement +++ b/bin/complement @@ -33,5 +33,5 @@ cat "$LOG_FILE" | jq -c ' select( (.Action == "pass" or .Action == "fail" or .Action == "skip") and .Test != null - ) | {Action: .Action, Test: .Test} + ) | {Test: .Test, Action: .Action} ' | sort > "$RESULTS_FILE" diff --git a/complement/Caddyfile b/complement/Caddyfile new file mode 100644 index 00000000..ec08b962 --- /dev/null +++ b/complement/Caddyfile @@ -0,0 +1,30 @@ +{ + log default { + level WARN + } + https_port 8448 + default_sni your.server.name + local_certs + pki { + ca local { + name "Complement CA" + root { + cert /complement/ca/ca.crt + key /complement/ca/ca.key + } + intermediate { + cert /complement/ca/ca.crt + key /complement/ca/ca.key + } + } + } +} + +your.server.name + +reverse_proxy 127.0.0.1:8008 +tls { + issuer internal { + ca local + } +} diff --git a/complement/Dockerfile b/complement/Dockerfile index ce067ec3..06171b1c 100644 --- a/complement/Dockerfile +++ b/complement/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.81.0 +FROM rust:1.85.0 WORKDIR /workdir @@ -8,6 +8,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ COPY Cargo.toml Cargo.toml COPY Cargo.lock Cargo.lock COPY src src +COPY .cargo .cargo RUN cargo build --release \ && mv target/release/conduit conduit \ && rm -rf target @@ -27,7 +28,7 @@ RUN apt-get update \ && apt-get install -y caddy COPY conduit-example.toml conduit.toml -COPY complement/caddy.json caddy.json +COPY complement/Caddyfile Caddyfile ENV SERVER_NAME=localhost ENV CONDUIT_CONFIG=/workdir/conduit.toml @@ -35,11 +36,13 @@ ENV CONDUIT_CONFIG=/workdir/conduit.toml RUN sed -i "s/port = 6167/port = 8008/g" conduit.toml RUN echo "log = \"warn,_=off,sled=off\"" >> conduit.toml RUN sed -i "s/address = \"127.0.0.1\"/address = \"0.0.0.0\"/g" conduit.toml +RUN sed -i "s/registration_token = \"\"//g" conduit.toml +RUN sed -i "s/allow_check_for_updates = true/allow_check_for_updates = false/g" conduit.toml EXPOSE 8008 8448 CMD uname -a && \ sed -i "s/#server_name = \"your.server.name\"/server_name = \"${SERVER_NAME}\"/g" conduit.toml && \ - sed -i "s/your.server.name/${SERVER_NAME}/g" caddy.json && \ - caddy start --config caddy.json > /dev/null && \ + sed -i "s/your.server.name/${SERVER_NAME}/g" Caddyfile && \ + caddy start > /dev/null && \ /workdir/conduit diff --git a/complement/caddy.json b/complement/caddy.json deleted file mode 100644 index ea52c2c9..00000000 --- a/complement/caddy.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "logging": { - "logs": { - "default": { - "level": "WARN" - } - } - }, - "apps": { - "http": { - "https_port": 8448, - "servers": { - "srv0": { - "listen": [":8448"], - "routes": [{ - "match": [{ - "host": ["your.server.name"] - }], - "handle": [{ - "handler": "subroute", - "routes": [{ - "handle": [{ - "handler": "reverse_proxy", - "upstreams": [{ - "dial": "127.0.0.1:8008" - }] - }] - }] - }], - "terminal": true - }], - "tls_connection_policies": [{ - "match": { - "sni": ["your.server.name"] - } - }] - } - } - }, - "pki": { - "certificate_authorities": { - "local": { - "name": "Complement CA", - "root": { - "certificate": "/complement/ca/ca.crt", - "private_key": "/complement/ca/ca.key" - }, - "intermediate": { - "certificate": "/complement/ca/ca.crt", - "private_key": "/complement/ca/ca.key" - } - } - } - }, - "tls": { - "automation": { - "policies": [{ - "subjects": ["your.server.name"], - "issuers": [{ - "module": "internal" - }], - "on_demand": true - }, { - "issuers": [{ - "module": "internal", - "ca": "local" - }] - }] - } - } - } -} \ No newline at end of file