anchorage v1.0 initial tree
Greenfield Go multi-tenant IPFS Pinning Service wire-compatible with the
IPFS Pinning Services API spec. Paired 1:1 with Kubo over localhost RPC,
clustered via embedded NATS JetStream, Postgres source-of-truth with
RLS-enforced tenancy, Fiber + huma v2 for the HTTP surface, Authentik
OIDC for session login with kid-rotated HS256 JWT API tokens.
Feature-complete against the 22-milestone build plan, including the
ship-it v1.0 gap items:
* admin CLIs: drain/uncordon, maintenance, mint-token, rotate-key,
prune-denylist, rebalance --dry-run, cache-stats, cluster-presences
* TTL leader election via NATS KV, fence tokens, JetStream dedup
* rebalancer (plan/apply split), reconciler, requeue sweeper
* ristretto caches with NATS-backed cross-node invalidation
(placements live-nodes + token denylist)
* maintenance watchdog for stuck cluster-pause flag
* Prometheus /metrics with CIDR ACL, HTTP/pin/scheduler/cache gauges
* rate limiting: session (10/min) + anonymous global (120/min)
* integration tests: rebalance, refcount multi-org, RLS belt
* goreleaser (tar + deb/rpm/apk + Alpine Docker) targeting Gitea
Stack: Cobra/Viper, Fiber v2 + huma v2, embedded NATS JetStream,
pgx/sqlc/golang-migrate, ristretto, TypeID, prometheus/client_golang,
testcontainers-go.
This commit is contained in:
commit
12bf35caf8
112 files changed
+16884
No files matched your search
@@ -0,0 +1,48 @@
|
||||
[Unit]
|
||||
Description=anchorage IPFS Pinning Service
|
||||
Documentation=https://git.anomalous.dev/alphacentri/anchorage
|
||||
Wants=network-online.target
|
||||
After=network.target network-online.target postgresql.service ipfs.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=anchorage
|
||||
Group=anchorage
|
||||
WorkingDirectory=/etc/anchorage
|
||||
LimitNOFILE=65536
|
||||
|
||||
ExecStart=/usr/bin/anchorage serve --config /etc/anchorage/anchorage.yaml
|
||||
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StartLimitInterval=60
|
||||
StartLimitBurst=3
|
||||
|
||||
# Security hardening — anchorage is a pure-Go HTTP/NATS daemon, no
|
||||
# special capabilities required. The writable paths are the state dir
|
||||
# (node.id, NATS JetStream data) and the log dir.
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
PrivateTmp=true
|
||||
PrivateDevices=true
|
||||
ProtectKernelTunables=true
|
||||
ProtectKernelModules=true
|
||||
ProtectControlGroups=true
|
||||
RestrictSUIDSGID=true
|
||||
LockPersonality=true
|
||||
NoNewPrivileges=true
|
||||
RestrictRealtime=true
|
||||
RestrictNamespaces=true
|
||||
MemoryDenyWriteExecute=true
|
||||
SystemCallArchitectures=native
|
||||
SystemCallFilter=@system-service
|
||||
SystemCallFilter=~@privileged @resources @mount @debug
|
||||
|
||||
ReadWritePaths=/var/lib/anchorage /var/log/anchorage
|
||||
|
||||
# Allow binding to ports < 1024 (e.g. :443 behind a reverse proxy terminator).
|
||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
# Enable the service but don't start on a fresh install — the operator
|
||||
# still needs to write /etc/anchorage/anchorage.yaml (start from
|
||||
# /etc/anchorage/anchorage.yaml.example) and provision the JWT signing
|
||||
# key at auth.apiToken.signingKeyPath.
|
||||
systemctl enable anchorage.service >/dev/null 2>&1 || true
|
||||
|
||||
# On upgrade ("2" from rpm, "configure" from deb) restart only if the
|
||||
# service was previously running so an operator who has it intentionally
|
||||
# stopped stays that way.
|
||||
if [ "$1" = "configure" ] || [ "$1" = "2" ]; then
|
||||
if systemctl is-active --quiet anchorage.service; then
|
||||
systemctl restart anchorage.service >/dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/anchorage/anchorage.yaml ]; then
|
||||
echo ""
|
||||
echo "anchorage: configuration not found at /etc/anchorage/anchorage.yaml"
|
||||
echo " cp /etc/anchorage/anchorage.yaml.example /etc/anchorage/anchorage.yaml"
|
||||
echo " edit to point at your Postgres + Authentik + Kubo RPC endpoint"
|
||||
echo " generate a signing key, e.g.: openssl rand -base64 48 > /etc/anchorage/jwt.key"
|
||||
echo " systemctl start anchorage"
|
||||
echo ""
|
||||
fi
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
# On purge (deb) or final erase (rpm) the operator is removing anchorage
|
||||
# for good — clean up the system user. /var/lib/anchorage is left in
|
||||
# place so the operator can archive NATS state and node.id first.
|
||||
if [ "$1" = "purge" ] || [ "$1" = "0" ]; then
|
||||
userdel anchorage 2>/dev/null || true
|
||||
groupdel anchorage 2>/dev/null || true
|
||||
|
||||
echo ""
|
||||
echo "anchorage: state retained at /var/lib/anchorage and /var/log/anchorage"
|
||||
echo " remove manually if not needed:"
|
||||
echo " rm -rf /var/lib/anchorage /var/log/anchorage /etc/anchorage"
|
||||
echo ""
|
||||
fi
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Create the anchorage system user and group if missing.
|
||||
getent group anchorage >/dev/null 2>&1 || groupadd --system anchorage
|
||||
getent passwd anchorage >/dev/null 2>&1 || useradd --system --no-create-home --shell /usr/sbin/nologin -g anchorage anchorage
|
||||
|
||||
# Directories the service needs. nfpm also creates these, but repeating
|
||||
# here covers the case where the operator wiped /var/lib/anchorage
|
||||
# between installs.
|
||||
mkdir -p /etc/anchorage \
|
||||
/var/lib/anchorage \
|
||||
/var/lib/anchorage/nats \
|
||||
/var/log/anchorage
|
||||
chown -R anchorage:anchorage /etc/anchorage /var/lib/anchorage /var/log/anchorage
|
||||
chmod 0750 /var/lib/anchorage /var/lib/anchorage/nats /var/log/anchorage
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
systemctl stop anchorage.service >/dev/null 2>&1 || true
|
||||
systemctl disable anchorage.service >/dev/null 2>&1 || true
|
||||
Reference in new issue
Block a user