chore(config): Binaries laden .env selbst; .env.example korrigiert

`cp .env.example .env && cargo run` — der im README dokumentierte Ablauf —
schlug bisher mit `missing env: PDS_HOST` fehl: nichts im Prozess hat die
Datei je gelesen. Beide Bins rufen jetzt als erstes `dotenvy::dotenv()` auf;
echte Umgebungsvariablen gewinnen weiterhin.

Dazu .env.example am Code verifiziert:

* PDS_JWT_SECRET war weder Hex noch ein gültiger P-256-Skalar. jwt_issuer.rs
  macht hex::decode + p256::SecretKey::from_bytes; ein ungültiger Wert lässt
  den Server starten, aber jeder Pfad über server_p256_public_multibase
  antwortet 500 — also nicht nur create/refreshSession, sondern auch jeder
  Record-Write (repo.rs, feed.rs, blob.rs, profile.rs).
* JETSTREAM_COLLECTIONS fehlten app.twi.post (das eigene 160-Zeichen-Lexicon)
  und app.bsky.actor.profile, obwohl der Indexer beide verarbeitet.
* APP_ENV entfernt — wird nirgends gelesen.
* PDS_INTERNAL_URL, APPVIEW_INTERNAL_URL, APPVIEW_HANDLE_SYNC_INTERVAL_SECS
  und die MAARCADETWEET_*-Overrides des Clients ergänzt.
* S3_BUCKET_APPVIEW als das markiert, was es ist: Pflichtvariable ohne Leser.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013HC9HLrUU1LNwkzp8nkDLX
This commit is contained in:
tomdebone
2026-09-09 21:35:53 +02:00
co-authored by Claude Opus 5
parent baeb87214b
commit 3c6f4dd67c
7 changed files with 49 additions and 5 deletions
+32 -5
View File
@@ -1,26 +1,46 @@
# ===================================================== # =====================================================
# maarcadetweet — environment # maarcadetweet — environment
# ===================================================== # =====================================================
# Copy to .env and adjust. # Copy to .env and adjust. Beide Binaries laden `.env` beim Start
# selbst (dotenvy); echte Umgebungsvariablen haben Vorrang.
# --- General --- # --- General ---
RUST_LOG=info,maarcadetweet=debug,sqlx=warn RUST_LOG=info,maarcadetweet=debug,sqlx=warn
APP_ENV=dev
# --- PDS server --- # --- PDS server ---
PDS_HOST=127.0.0.1 PDS_HOST=127.0.0.1
PDS_PORT=2583 PDS_PORT=2583
PDS_PUBLIC_URL=http://127.0.0.1:2583 PDS_PUBLIC_URL=http://127.0.0.1:2583
PDS_HANDLE_DNS_ZONE=.maarcadetweet.local PDS_HANDLE_DNS_ZONE=.maarcadetweet.local
PDS_JWT_SECRET=change-me-to-a-32-byte-random-string-please # MUSS Hex sein, >= 32 Bytes ergeben und ein gültiger P-256-Skalar
# sein (also nicht lauter Nullen) — `jwt_issuer.rs` macht hex::decode()
# und p256::SecretKey::from_bytes(). Ein ungültiger Wert lässt den
# Server zwar starten, aber alles, was den Serverschlüssel ableitet,
# antwortet mit 500: createAccount/createSession/refreshSession UND
# jeder Record-Write (repo.rs, feed.rs, blob.rs, profile.rs).
# Der Wert hier ist ein Zufallswert fürs Beispiel — für echte
# Instanzen einen eigenen erzeugen:
# openssl rand -hex 32
PDS_JWT_SECRET=522084586f3d3abb835d43b7c4726735d78803dd58490f62a92571cd29033a95
# Wohin die PDS ihre Commits pusht (POST /internal/ingest-commit).
# Default: APPVIEW_PUBLIC_URL.
# APPVIEW_INTERNAL_URL=http://127.0.0.1:2584
# --- AppView service --- # --- AppView service ---
APPVIEW_HOST=127.0.0.1 APPVIEW_HOST=127.0.0.1
APPVIEW_PORT=2584 APPVIEW_PORT=2584
APPVIEW_PUBLIC_URL=http://127.0.0.1:2584 APPVIEW_PUBLIC_URL=http://127.0.0.1:2584
JETSTREAM_URL=wss://jetstream1.us-east.bsky.network/subscribe JETSTREAM_URL=wss://jetstream1.us-east.bsky.network/subscribe
# Collections the AppView will index # Collections, die die AppView indexiert. `app.twi.post` ist das
JETSTREAM_COLLECTIONS=app.bsky.feed.post,app.bsky.feed.like,app.bsky.feed.repost,app.bsky.graph.follow # eigene 160-Zeichen-Lexicon und muss mit rein, sonst tauchen eigene
# Posts nur über den PDS-Push auf; `app.bsky.actor.profile` füttert
# den Profil-Cache.
JETSTREAM_COLLECTIONS=app.twi.post,app.bsky.feed.post,app.bsky.feed.like,app.bsky.feed.repost,app.bsky.graph.follow,app.bsky.actor.profile
# Für den Handle-Sync-Worker: welche PDS nach lokalen Handles gefragt
# wird. Default: PDS_PUBLIC_URL.
# PDS_INTERNAL_URL=http://127.0.0.1:2583
# Intervall des Handle-Sync-Workers in Sekunden (Default: 300).
# APPVIEW_HANDLE_SYNC_INTERVAL_SECS=60
# --- Databases --- # --- Databases ---
DATABASE_URL_PDS=postgres://pds:pds@127.0.0.1:5434/pds DATABASE_URL_PDS=postgres://pds:pds@127.0.0.1:5434/pds
@@ -32,6 +52,9 @@ S3_REGION=us-east-1
S3_ACCESS_KEY=minioadmin S3_ACCESS_KEY=minioadmin
S3_SECRET_KEY=minioadmin S3_SECRET_KEY=minioadmin
S3_BUCKET_PDS=maarcadetweet-pds S3_BUCKET_PDS=maarcadetweet-pds
# Pflichtvariable in AppConfig::from_env(), wird derzeit von keinem
# Code-Pfad gelesen — muss gesetzt sein, damit der Start nicht
# fehlschlägt.
S3_BUCKET_APPVIEW=maarcadetweet-appview S3_BUCKET_APPVIEW=maarcadetweet-appview
# --- PLC Directory (dev: leave default; can mock) --- # --- PLC Directory (dev: leave default; can mock) ---
@@ -40,3 +63,7 @@ PLC_DIRECTORY_URL=https://plc.directory
# --- AppView ingest auth (optional, dev ok if unset) --- # --- AppView ingest auth (optional, dev ok if unset) ---
# APPVIEW_INGEST_SECRET=change-me-to-a-shared-secret-between-pds-and-appview # APPVIEW_INGEST_SECRET=change-me-to-a-shared-secret-between-pds-and-appview
# --- Tauri-Client (Build-/Laufzeit-Overrides des Desktop-Clients) ---
# MAARCADETWEET_PDS_URL=http://127.0.0.1:2583
# MAARCADETWEET_APPVIEW_URL=http://127.0.0.1:2584
Generated
+2
View File
@@ -51,6 +51,7 @@ dependencies = [
"axum", "axum",
"base64", "base64",
"chrono", "chrono",
"dotenvy",
"futures", "futures",
"reqwest", "reqwest",
"rustls", "rustls",
@@ -1882,6 +1883,7 @@ dependencies = [
"chrono", "chrono",
"ciborium", "ciborium",
"cid", "cid",
"dotenvy",
"hex", "hex",
"k256", "k256",
"p256", "p256",
+1
View File
@@ -54,6 +54,7 @@ blake3 = "1"
rand = "0.8" rand = "0.8"
rand_core = "0.6" rand_core = "0.6"
hex = "0.4" hex = "0.4"
dotenvy = "0.15"
base64 = "0.22" base64 = "0.22"
parking_lot = "0.12" parking_lot = "0.12"
async-stream = "0.3" async-stream = "0.3"
+1
View File
@@ -19,6 +19,7 @@ path = "src/main.rs"
[dependencies] [dependencies]
tokio = { workspace = true } tokio = { workspace = true }
dotenvy = { workspace = true }
axum = { workspace = true } axum = { workspace = true }
tower = { workspace = true } tower = { workspace = true }
tower-http = { workspace = true } tower-http = { workspace = true }
+6
View File
@@ -18,6 +18,12 @@ use state::AppState;
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
// Load `.env` from the working directory (and upwards) if present.
// Nothing else in the process reads it, so without this
// `cp .env.example .env && cargo run` fails with `missing env:
// PDS_HOST`. Real environment variables always win over the file.
let _ = dotenvy::dotenv();
// Install a rustls crypto provider before any TLS connection. `ring` // Install a rustls crypto provider before any TLS connection. `ring`
// is the only one we currently support; using `aws_lc_rs` would // is the only one we currently support; using `aws_lc_rs` would
// require a non-default feature on rustls. // require a non-default feature on rustls.
+1
View File
@@ -15,6 +15,7 @@ path = "src/main.rs"
[dependencies] [dependencies]
tokio = { workspace = true } tokio = { workspace = true }
dotenvy = { workspace = true }
axum = { workspace = true } axum = { workspace = true }
tower = { workspace = true } tower = { workspace = true }
tower-http = { workspace = true } tower-http = { workspace = true }
+6
View File
@@ -17,6 +17,12 @@ use tracing_subscriber::EnvFilter;
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
// Load `.env` from the working directory (and upwards) if present.
// Nothing else in the process reads it, so without this
// `cp .env.example .env && cargo run` fails with `missing env:
// PDS_HOST`. Real environment variables always win over the file.
let _ = dotenvy::dotenv();
tracing_subscriber::fmt() tracing_subscriber::fmt()
.with_env_filter(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"))) .with_env_filter(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")))
.init(); .init();