Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ jobs:
sources=()
for digest in *; do sources+=("$IMAGE@sha256:$digest"); done
docker buildx imagetools create -t "$IMAGE:$VERSION" "${sources[@]}"
# the JSON comes pretty-printed ("architecture": "arm64", with a space): read it with jq, not grep
- name: check it
run: |
docker buildx imagetools inspect "$IMAGE:$VERSION"
docker buildx imagetools inspect "$IMAGE:$VERSION" --format '{{json .Manifest.Manifests}}' \
| grep -q '"architecture":"arm64"'
| jq -e '[.[].platform.architecture] | (index("amd64") != null) and (index("arm64") != null)'
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,18 @@ python scripts/provision.py --zip \
`--peers` lists every hospital with the address the others reach it at: a LAN
IP, a Tailscale name or a domain. Every address is HTTPS (a bare `host:port`
gets `https://`; `http://` is rejected). The order is the directory's placement
order between runs. The command writes `kits/hospital-a/` ... `kits/hospital-d/`
order between runs. One hospital (your own) is enough when everyone else will
join with a code from the dashboard.

**Only Docker installed (no Python)?** Run `provision.py` inside the published node
image, from the repository folder (a clone or the release's source zip). The same
command works in PowerShell and in a Mac or Linux terminal:

```sh
docker run --rm -v "${PWD}:/src" -w /src ghcr.io/denimworld12/medchain-node:v1.1.0 python scripts/provision.py --zip --peers hospital-a=sam-laptop.tail1234.ts.net:8001 --directory sam-laptop.tail1234.ts.net:8100
```

On Linux, add `--user "$(id -u):$(id -g)"` after `--rm` so the kits belong to you, not root. The command writes `kits/hospital-a/` ... `kits/hospital-d/`
and `kits/directory/`, plus a `.zip` of each. The network's CA and keys live in
`kits/.pki/` (or `--pki DIR`) and are reused on every later run, so the network
is never re-keyed. Every hospital kit holds:
Expand Down Expand Up @@ -641,6 +652,13 @@ make hub # on the hub,
docker compose --project-directory . -f deploy/node.yml up -d # on each hospital machine, in its kit
```

No `make` (a stock Windows laptop has none)? `make hub` is exactly this, run from the
repository folder:

```sh
docker compose --project-directory . --env-file kits/directory/hub.env -f deploy/hub.yml up -d --wait
```

Start training from any one node (`POST /round/start`, as above). The start
floods along the chain.

Expand Down Expand Up @@ -769,7 +787,10 @@ else's hospital rejected. The dashboard's **Nodes** page shows each hospital's f
with a **Signature verified** badge and the key's fingerprint, or **Rejected** with the
reason. This is in addition to the Start/Pause controls. One limit: the host's uptime
counts from the boot time the install script saw, so after a reboot, run the installer
again to refresh it. The round-trip times and data rows are always live.
again to refresh it. Another: a hospital started from a kit (such as the organiser's own)
had no install script to read the laptop's facts, so it shows what its container sees,
the container's hostname and the Docker VM's Linux. The round-trip times and data rows
are always live.

### Prove it

Expand Down
52 changes: 50 additions & 2 deletions dashboard/src/pages/JoinCodes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,65 @@ import { notAuthorized } from "../auth.js";

const RAW = "https://raw.githubusercontent.com/Denimworld12/Hospital-Chain";

// navigator.clipboard exists only in a secure context (https, or localhost): a dashboard opened at the hub's
// Tailscale IP over http falls back to the older selection copy
async function copyText(text) {
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(text);
return;
}
const area = document.createElement("textarea");
area.value = text;
area.setAttribute("readonly", "");
area.style.position = "fixed";
area.style.opacity = "0";
document.body.appendChild(area);
area.select();
try {
if (!document.execCommand("copy")) throw new Error("copy refused");
} finally {
document.body.removeChild(area);
}
}

function CopyButton({ text, label = "Copy", testId }) {
const [state, setState] = useState("idle");
useEffect(() => {
if (state === "idle") return undefined;
const t = setTimeout(() => setState("idle"), 2000);
return () => clearTimeout(t);
}, [state]);
const copy = async () => {
try {
await copyText(text);
setState("copied");
} catch {
setState("failed");
}
};
return (
<PillButton variant="secondary" onClick={copy} data-testid={testId} aria-live="polite">
{state === "copied" ? "Copied" : state === "failed" ? "Select and copy by hand" : label}
</PillButton>
);
}

// The one command a friend runs (Docker Desktop and Tailscale already installed, on this tailnet).
function InstallCommands({ install }) {
if (!install) return null;
const hub = install.hub || "<this hub's Tailscale IP>";
const base = `${RAW}/${install.version}/deploy/install`;
const windows = `$env:MEDCHAIN_HUB = "${hub}"; irm ${base}/install.ps1 | iex`;
const unix = `curl -fsSL ${base}/install.sh | MEDCHAIN_HUB=${hub} bash`;
return (
<div className="card join-code">
<p className="field__label">On the hospital's laptop</p>
<p>Windows (PowerShell):</p>
<pre className="join-code__cmd" data-testid="install-windows">{`$env:MEDCHAIN_HUB = "${hub}"; irm ${base}/install.ps1 | iex`}</pre>
<pre className="join-code__cmd" data-testid="install-windows">{windows}</pre>
<CopyButton text={windows} label="Copy the Windows command" testId="copy-install-windows" />
<p>macOS or Linux (Terminal):</p>
<pre className="join-code__cmd">{`curl -fsSL ${base}/install.sh | MEDCHAIN_HUB=${hub} bash`}</pre>
<pre className="join-code__cmd">{unix}</pre>
<CopyButton text={unix} label="Copy the macOS/Linux command" testId="copy-install-unix" />
<p>It asks for the hospital&apos;s name and the join code, checks Docker, Tailscale, this hub and disk space, and starts the hospital.</p>
</div>
);
Expand Down Expand Up @@ -120,6 +167,7 @@ export default function JoinCodes() {
<>
<p className="field__label">Give this code to one hospital. It is shown only now.</p>
<p className="join-code__code" data-testid="join-code">{created.code}</p>
<CopyButton text={created.code} label="Copy the code" testId="copy-join-code" />
<p>Expires {when(created.expires_at)}. Works once.</p>
</>
) : (
Expand Down
Loading
Loading