Repository navigation
feat(forge): P38 F5b structured logs, graceful drain, bind-gate tests, container image, ops guide #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(forge): P38 F5b structured logs, graceful drain, bind-gate tests, container image, ops guide #312
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8566548
feat(forge): P38 F5b structured logs, graceful SIGTERM drain, bind-ga…
tonibergholm-codento f83bbac
fix(forge): P38 F5b tini as PID 1, bounded transport pack threads, se…
tonibergholm-codento 52283a4
fix(forge): P38 F5b non-blocking log writer, sturdier process tests, …
tonibergholm-codento d23838c
fix(forge): P38 F5b dropped-lines note shares the queue entry of the …
tonibergholm-codento File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| .git | ||
| .worktrees | ||
| target | ||
| **/target | ||
| **/node_modules | ||
| apps/desktop/dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # sc-forge image. Build from the repository root: | ||
| # docker build -f crates/forge/Dockerfile -t sc-forge . | ||
| # Base images are pinned by digest; bump them together with rust-toolchain.toml. | ||
|
|
||
| FROM rust:1.96.1-bookworm@sha256:a339861ae23e9abb272cea45dfafde21760d2ce6577a70f8a926153677902663 AS build | ||
| WORKDIR /src | ||
| COPY . . | ||
| RUN cargo build --release --locked -p scl-forge --bin sc-forge | ||
|
|
||
| # trixie, not bookworm: sc-forge needs git 2.40 or newer (merge-tree --write-tree, quarantine | ||
| # naming) and bookworm ships 2.39. No sshd, no shell tooling beyond the base. | ||
| FROM debian:trixie-slim@sha256:62bd423aeee912639ca8ee681c2b762cb3e25137e0a92b20be455898a9f034ad | ||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends git ca-certificates tini \ | ||
| && rm -rf /var/lib/apt/lists/* \ | ||
| && useradd --system --uid 10001 --home-dir /data --shell /usr/sbin/nologin forge \ | ||
| && mkdir /data && chown forge:forge /data | ||
| COPY --from=build /src/target/release/sc-forge /usr/local/bin/sc-forge | ||
| USER forge | ||
| VOLUME /data | ||
| EXPOSE 3000 | ||
| # SIGTERM drains (see docs/FORGE-OPERATIONS.md); give the orchestrator longer than --shutdown-timeout. | ||
| STOPSIGNAL SIGTERM | ||
| # tini is PID 1: it reaps the git processes that outlive a killed transport (orphans are re-parented | ||
| # to PID 1 and would otherwise stay zombies until pids.max runs out) and forwards SIGTERM. | ||
| ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/sc-forge"] | ||
| CMD ["--help"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| # Smoke test of the sc-forge image: it starts, answers /healthz, git is new enough, a repository | ||
| # can be created and cloned, and `docker stop` ends it with exit code 0 (the SIGTERM drain). | ||
| # Usage: smoke.sh <image> | ||
| set -euo pipefail | ||
| image=${1:?usage: smoke.sh <image>} | ||
| name=sc-forge-smoke-$$ | ||
| port=${SMOKE_PORT:-13000} | ||
| cleanup() { docker rm -f "$name" >/dev/null 2>&1 || true; docker volume rm -f "$name-data" >/dev/null 2>&1 || true; } | ||
| trap cleanup EXIT | ||
|
|
||
| docker run --rm --entrypoint git "$image" --version | ||
| docker volume create "$name-data" >/dev/null | ||
| docker run --rm -v "$name-data:/data" "$image" admin user create --data-dir /data \ | ||
| --username siteadmin --password "$(head -c 24 /dev/urandom | base64)" \ | ||
| --email admin@example.invalid --admin --must-change-password=false >/dev/null | ||
| token=$(docker run --rm -v "$name-data:/data" "$image" admin user generate-access-token --data-dir /data \ | ||
| --username siteadmin --token-name smoke --scopes all --raw) | ||
| docker run -d --name "$name" -v "$name-data:/data" -p "127.0.0.1:$port:3000" "$image" serve \ | ||
| --data-dir /data --listen 0.0.0.0:3000 --behind-proxy --public-url "http://127.0.0.1:$port" >/dev/null | ||
|
|
||
| for _ in $(seq 1 60); do | ||
| curl -fsS "http://127.0.0.1:$port/api/healthz" >/dev/null 2>&1 && break | ||
| sleep 0.5 | ||
| done | ||
| curl -fsS "http://127.0.0.1:$port/api/healthz" >/dev/null | ||
| curl -fsS -H "Authorization: token $token" -H 'Content-Type: application/json' \ | ||
| -d '{"name":"smoke","auto_init":true}' "http://127.0.0.1:$port/api/v1/user/repos" >/dev/null | ||
| work=$(mktemp -d) | ||
| git clone -q "http://siteadmin:$token@127.0.0.1:$port/siteadmin/smoke.git" "$work/smoke" | ||
| test -f "$work/smoke/README.md" | ||
| rm -rf "$work" | ||
|
|
||
| docker stop -t 40 "$name" >/dev/null | ||
| code=$(docker inspect -f '{{.State.ExitCode}}' "$name") | ||
| [ "$code" = 0 ] || { echo "sc-forge exited with $code after SIGTERM" >&2; docker logs "$name" >&2; exit 1; } | ||
| echo "smoke ok" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.