Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+5
-42
@@ -1,50 +1,13 @@
|
||||
#!/bin/sh
|
||||
# =============================================================================
|
||||
# One-time setup of the `garage` container. Run from the repo root, on the
|
||||
# host, once the container is up:
|
||||
#
|
||||
# garage/bootstrap.sh
|
||||
#
|
||||
# Idempotent: every step checks before acting, so re-running it is harmless.
|
||||
# Garage keeps all of this in the garage_meta volume, so it is only needed on
|
||||
# a fresh volume — once on stpvm, and again whenever a dev stack starts from
|
||||
# nothing.
|
||||
#
|
||||
# WHY A HOST SCRIPT
|
||||
# The dxflrs/garage image is FROM scratch: a single binary, no shell. There
|
||||
# is nothing to run an init script with inside it, so this drives the
|
||||
# binary through `docker compose exec`.
|
||||
#
|
||||
# WHAT IT DOES
|
||||
# 1. Gives the single node a role in the cluster layout. Until it has one,
|
||||
# Garage accepts connections but refuses to store anything.
|
||||
# 2. Creates the bucket (S3_BUCKET, default `uploads`).
|
||||
# 3. Imports the backend's access key from .env (S3_ACCESS_KEY_ID /
|
||||
# S3_SECRET_ACCESS_KEY). Importing rather than letting Garage generate
|
||||
# one keeps .env the single source of truth: a wiped volume comes back
|
||||
# with the same credentials and the backend needs no change.
|
||||
# 4. Grants that key read+write on the bucket. garage-webui also browses
|
||||
# with it: it borrows the first key that has access to a bucket.
|
||||
# 5. Opens the bucket on the website endpoint, which is what Caddy serves
|
||||
# /uploads/ from, anonymously.
|
||||
#
|
||||
# ENV / .env
|
||||
# S3_ACCESS_KEY_ID required; "GK" + 24 hex chars
|
||||
# S3_SECRET_ACCESS_KEY required; 64 hex chars
|
||||
# S3_BUCKET optional, default uploads
|
||||
# GARAGE_CAPACITY optional, default 20G. Only weights data placement
|
||||
# between nodes; with one node it is no quota.
|
||||
# COMPOSE optional, default `docker compose`. Set it to add
|
||||
# the dev override, e.g.
|
||||
# COMPOSE="docker compose -f docker-compose.yml -f docker-compose.dev.yml"
|
||||
# =============================================================================
|
||||
# One-time, idempotent setup of a fresh garage_meta volume, run on the host
|
||||
# (the image has no shell): node layout, bucket, the backend's key imported
|
||||
# from .env (so a wiped volume keeps the same credentials), and website access.
|
||||
# Optional: S3_BUCKET, GARAGE_CAPACITY, COMPOSE (to add the dev override).
|
||||
set -eu
|
||||
|
||||
COMPOSE=${COMPOSE:-docker compose}
|
||||
|
||||
# Read one KEY=value from .env without sourcing it: .env is not guaranteed to
|
||||
# be valid shell (unquoted spaces, `$` in secrets). A value already in the
|
||||
# environment wins, so the script also runs without a .env.
|
||||
# .env isn't guaranteed to be valid shell, so it isn't sourced.
|
||||
envval() {
|
||||
eval "current=\${$1:-}"
|
||||
if [ -n "$current" ]; then
|
||||
|
||||
Reference in New Issue
Block a user