Fix seeder: origin mismatch + robust Dockerfile

Two root causes for seeding not working on production:

1. Origin mismatch: The seeder writes content IDs as
   http://localhost:7777/content/... but the app was using
   window.location.origin (the user's actual browser URL) to
   query the relay. Introduced VITE_CONTENT_ORIGIN env var
   baked into the Docker build so both sides use the same origin.

2. Dockerfile.seed fragility: Replaced --omit=dev + global tsx
   with a cleaner approach that strips sharp from package.json
   (the only native dep that fails on Alpine) then does a full
   npm install, ensuring tsx/esbuild and all applesauce deps
   resolve correctly.

Also improved wait-for-relay to accept any HTTP response (some
relays return 4xx for plain GET) and increased max attempts.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Dorian
2026-02-12 13:17:49 +00:00
parent 57db25aa94
commit 32e1751df3
6 changed files with 33 additions and 13 deletions

View File

@@ -170,11 +170,10 @@ export function useContentDiscovery() {
if (!effectiveAlgo) return contents
const statsMap = contentStatsMap.value
const origin = window.location.origin
// Build entries array: [Content, stats] for each content item
const withStats: [Content, ContentStats][] = contents.map((c) => {
const externalId = `${origin}/content/${c.id}`
const externalId = getExternalContentId(c.id)
return [c, statsMap.get(externalId) || EMPTY_STATS]
})

View File

@@ -8,12 +8,20 @@ import { eventStore, pool, appRelays, factory, APP_RELAYS } from '../lib/nostr'
import { accountManager } from '../lib/accounts'
import { useObservable } from './useObservable'
/**
* The origin used for Nostr content identifiers.
* In Docker/production the env var is baked in at build time so it matches
* the origin the seeder uses, regardless of how users access the app.
*/
const CONTENT_ORIGIN: string =
import.meta.env.VITE_CONTENT_ORIGIN || window.location.origin
/**
* Build the external content identifier used in Nostr tags.
* Matches indeehub convention: {origin}/content/{contentId}
*/
export function getExternalContentId(contentId: string): string {
return `${window.location.origin}/content/${contentId}`
return `${CONTENT_ORIGIN}/content/${contentId}`
}
// --- Comment Tree Types ---