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:
@@ -7,12 +7,15 @@ FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install tsx globally (isolated from project deps, avoids lockfile conflicts)
|
||||
RUN npm install -g tsx
|
||||
|
||||
# Install only production deps (no sharp or other heavy native devDeps)
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
# Copy package.json, strip sharp (native dep that needs build tools not on
|
||||
# Alpine), then do a full npm install so tsx/esbuild get their binaries and
|
||||
# all applesauce transitive deps resolve correctly.
|
||||
COPY package.json ./
|
||||
RUN node -e "\
|
||||
const p = JSON.parse(require('fs').readFileSync('package.json','utf8'));\
|
||||
if (p.devDependencies) delete p.devDependencies.sharp;\
|
||||
require('fs').writeFileSync('package.json', JSON.stringify(p, null, 2));\
|
||||
" && npm install --no-package-lock
|
||||
|
||||
# Copy only what the seed scripts need
|
||||
COPY scripts/ ./scripts/
|
||||
@@ -24,4 +27,4 @@ ENV RELAY_URL=ws://relay:8080
|
||||
ENV ORIGIN=http://localhost:7777
|
||||
|
||||
# set -ex: print each command before running, exit on first failure
|
||||
CMD ["sh", "-c", "set -ex && node scripts/wait-for-relay.mjs && tsx scripts/seed-profiles.ts && tsx scripts/seed-activity.ts && echo 'Seeding complete!'"]
|
||||
CMD ["sh", "-c", "set -ex && node scripts/wait-for-relay.mjs && npx tsx scripts/seed-profiles.ts && npx tsx scripts/seed-activity.ts && echo 'Seeding complete!'"]
|
||||
|
||||
Reference in New Issue
Block a user