From a8dc82dc59c0ea897f0073d0d5df1676cf6d9ca9 Mon Sep 17 00:00:00 2001 From: Dorian Date: Fri, 13 Feb 2026 16:27:51 +0000 Subject: [PATCH] Update environment variables and enhance Docker configurations for improved deployment - Modified .env.portainer to include new environment variables for S3 private bucket URL, Nostr JWT secrets, and SendGrid options. - Updated docker-compose.yml to support the new environment variables, enhancing service configurations. - Added a seed content script to the backend package.json for initializing the database with sample data. - Refactored helper functions to construct S3 URLs more robustly, accommodating potential missing configurations. - Enhanced dev.sh script to seed the database if empty, ensuring content availability during development. --- backend/package.json | 3 ++- backend/src/common/helper.ts | 5 ++++- docker-compose.yml | 9 +++++++++ scripts/dev.sh | 8 ++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/backend/package.json b/backend/package.json index 2956ca9..d0e7002 100644 --- a/backend/package.json +++ b/backend/package.json @@ -26,7 +26,8 @@ "typeorm:create-migration": "npm run typeorm -- migration:create src/database/migrations/$npm_config_name", "typeorm:generate-migration": "npm run typeorm -- -d src/database/ormconfig.ts migration:generate src/database/migrations/$npm_config_name", "typeorm:revert-migration": "npm run typeorm -- -d src/database/ormconfig.ts migration:revert", - "typeorm:run-migrations": "npm run typeorm migration:run -- -d src/database/ormconfig.ts" + "typeorm:run-migrations": "npm run typeorm migration:run -- -d src/database/ormconfig.ts", + "seed:content": "ts-node src/scripts/seed-content.ts" }, "config": { "commitizen": { diff --git a/backend/src/common/helper.ts b/backend/src/common/helper.ts index f86bd37..4b92a90 100644 --- a/backend/src/common/helper.ts +++ b/backend/src/common/helper.ts @@ -22,7 +22,10 @@ export function getPublicS3Url(fileKey: string): string { } export function getPrivateS3Url(fileKey: string): string { - return `${process.env.S3_PRIVATE_BUCKET_URL}${encodeS3KeyForUrl(fileKey)}`; + const base = + process.env.S3_PRIVATE_BUCKET_URL || + `${process.env.S3_ENDPOINT || 'http://localhost:9000'}/${process.env.S3_PRIVATE_BUCKET_NAME || 'indeedhub-private'}/`; + return `${base}${encodeS3KeyForUrl(fileKey)}`; } export function getTranscodedFileRoute(fileKey: string): string { diff --git a/docker-compose.yml b/docker-compose.yml index d8cb5eb..3c8bc2c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -73,6 +73,7 @@ services: S3_PRIVATE_BUCKET_NAME: ${S3_PRIVATE_BUCKET:-indeedhub-private} S3_PUBLIC_BUCKET_NAME: ${S3_PUBLIC_BUCKET:-indeedhub-public} S3_PUBLIC_BUCKET_URL: ${S3_PUBLIC_BUCKET_URL} + S3_PRIVATE_BUCKET_URL: ${S3_PRIVATE_BUCKET_URL:-} # ── CloudFront (leave empty for MinIO/self-hosted) ── CLOUDFRONT_PRIVATE_KEY: ${CLOUDFRONT_PRIVATE_KEY:-} @@ -89,6 +90,9 @@ services: # ── Nostr Auth / JWT ───────────────────────────────── NOSTR_JWT_SECRET: ${NOSTR_JWT_SECRET} NOSTR_JWT_EXPIRES_IN: ${NOSTR_JWT_EXPIRES_IN:-7d} + NOSTR_JWT_REFRESH_SECRET: ${NOSTR_JWT_REFRESH_SECRET:-} + NOSTR_JWT_TTL: ${NOSTR_JWT_TTL:-} + NOSTR_JWT_REFRESH_TTL: ${NOSTR_JWT_REFRESH_TTL:-} # ── AES-128 Content Encryption ────────────────────── AES_MASTER_SECRET: ${AES_MASTER_SECRET} @@ -103,6 +107,7 @@ services: # ── SendGrid (optional -- alternative to SMTP) ────── SENDGRID_API_KEY: ${SENDGRID_API_KEY:-} SENDGRID_SENDER: ${SENDGRID_SENDER:-} + SENDGRID_WAITLIST: ${SENDGRID_WAITLIST:-} # ── Cognito (optional -- disabled with Nostr auth) ── COGNITO_USER_POOL_ID: ${COGNITO_USER_POOL_ID:-} @@ -140,6 +145,10 @@ services: # ── Partner Content (optional) ────────────────────── PARTNER_API_BASE_URL: ${PARTNER_API_BASE_URL:-} PARTNER_API_KEY: ${PARTNER_API_KEY:-} + + # ── Strike (optional -- alternative payment provider) ─ + STRIKE_API_KEY: ${STRIKE_API_KEY:-} + STRIKE_WEBHOOK_KEY: ${STRIKE_WEBHOOK_KEY:-} depends_on: postgres: condition: service_healthy diff --git a/scripts/dev.sh b/scripts/dev.sh index 809fb44..7e788c1 100755 --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -284,6 +284,14 @@ for i in $(seq 1 60); do sleep 2 done +# Seed database if empty (so catalog and films appear; user uploads require re-upload after DB reset) +PROJECT_COUNT=$(curl -s "http://localhost:$BACKEND_PORT/projects" 2>/dev/null | grep -o '"id"' | wc -l | tr -d ' ') +if [ "$PROJECT_COUNT" = "0" ] || [ -z "$PROJECT_COUNT" ]; then + echo -e "${CYAN} Database has no projects — seeding content...${NC}" + (cd "$BACKEND_DIR" && set -a && [ -f .env ] && . ./.env && set +a && npm run seed:content 2>&1 | prefix_output "seed-db" "$CYAN") || true + echo -e "${GREEN} Seed done. Reload the app to see the catalog.${NC}" +fi + # ═════════════════════════════════════════════════════════════ # STEP 4 — Frontend dev server # ═════════════════════════════════════════════════════════════