Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (52 loc) · 3.14 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (52 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# syntax=docker/dockerfile:1.7
FROM rust:1.91-slim-bookworm AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential pkg-config perl \
&& rm -rf /var/lib/apt/lists/*
# Copy every workspace member so cargo can resolve the workspace manifest,
# even though we only compile the `asp` binary.
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY desktop/engine ./desktop/engine
COPY tests ./tests
RUN cargo build --release -p asp --bin asp
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/asp /usr/local/bin/asp
ENV ASP_LOG=info
# Transport is iroh (QUIC, dial-by-key): the hub makes an OUTBOUND connection to
# the iroh relays and is reached by peers through them (or a hole-punched direct
# path), so there is no inbound port to publish — `EXPOSE`/`[http_service]` are
# gone. The hub prints a connection TICKET on start (see the logs); peers
# `clone`/`sync`/`watch --peer` against that ticket.
#
# On startup:
# - init the vault at $ASP_DIR if it doesn't exist yet (asp stores its
# genesis config + log inside <vault>/.asp/asp.db, so that file is the
# "already initialized" marker).
# - keep the node identity on the persisted volume by pointing $ASP_HOME
# there (default ~/.asp/id_ed25519). `asp init`/`asp watch` generate and
# persist it on first use, so the hub keeps the same identity across
# container/machine restarts and peers don't have to re-trust it.
# - merge any pubkeys from $ASP_AUTHORIZED_KEYS into the synced
# authorized_keys on every start (env var read directly by `watch`).
# Restart-safe: keys already present are skipped.
#
# Environment knobs:
# ASP_DIR vault directory (default /mnt/workspace/vault). Set
# this to match the mounted persistent volume.
# ASP_HOME device-identity dir (default /mnt/workspace/.asp-home).
# ASP_RELAY_URL pin a self-hosted `asp relay` instead of the public n0
# relays (optional; default is the public relays).
# ASP_AUTH_KEY enrollment secret read by `watch` (clap env) — admits a
# not-yet-authorized peer that presents it.
# ASP_AUTHORIZED_KEYS ssh-ed25519 lines merged into the synced
# authorized_keys on every start.
# ASP_RESET=1 wipes the vault history (NOT the node identity in ASP_HOME) BEFORE
# `asp watch` starts — a race-free reseed knob: set the secret, let it reboot to
# a fresh empty vault (new vault_id, same identity), then unset it. Keeping
# ASP_HOME preserves peer TOFU trust so clients reconnect without re-pinning.
CMD ["/bin/sh", "-c", "VAULT_DIR=\"${ASP_DIR:-/mnt/workspace/vault}\" && export ASP_HOME=\"${ASP_HOME:-/mnt/workspace/.asp-home}\" && { [ \"$ASP_RESET\" = \"1\" ] && echo 'ASP_RESET=1: wiping vault history' && rm -rf \"$VAULT_DIR\" || true; } && mkdir -p \"$VAULT_DIR\" \"$ASP_HOME\" && { [ -f \"$VAULT_DIR/.asp/asp.db\" ] || asp init \"$VAULT_DIR\"; } && exec asp watch --dir \"$VAULT_DIR\" --listen"]