From 1e5f9008212dd56a43d6cf19165a22daf9341661 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Tue, 31 Mar 2026 04:17:16 -0700 Subject: [PATCH] fix: add dynamic config to pages and update Dockerfile for PostgreSQL --- docker-compose.casaos.yml | 40 +++---------------- scripts/setup-casaos.sh | 31 +++++++++----- src/app/admin/page.tsx | 2 + src/app/admin/tournaments/[id]/edit/page.tsx | 1 + src/app/admin/tournaments/[id]/page.tsx | 1 + .../admin/tournaments/[id]/results/page.tsx | 1 + src/app/admin/tournaments/page.tsx | 1 + src/app/matches/[id]/page.tsx | 1 + src/app/players/[id]/profile/page.tsx | 1 + src/app/players/[id]/schedule/page.tsx | 1 + src/app/rankings/page.tsx | 1 + 11 files changed, 38 insertions(+), 43 deletions(-) diff --git a/docker-compose.casaos.yml b/docker-compose.casaos.yml index 4a96a6c..6788517 100644 --- a/docker-compose.casaos.yml +++ b/docker-compose.casaos.yml @@ -1,6 +1,9 @@ # CasaOS Optimized Docker Compose Configuration # This file is optimized for deployment on CasaOS # Usage: docker-compose -f docker-compose.casaos.yml up -d +# +# IMPORTANT: This configuration requires an external PostgreSQL database. +# Set DATABASE_URL environment variable to your PostgreSQL connection string. services: app: @@ -11,13 +14,12 @@ services: ports: - "3000:3000" environment: - # Database Configuration + # Database Configuration (REQUIRED: Set via CasaOS environment variables) - DATABASE_PROVIDER=postgresql - - DATABASE_URL=postgresql://euchre_camp:euchrepassword@postgresql:5432/euchre_camp - - DATABASE_SHADOW_URL=postgresql://euchre_camp:euchrepassword@postgresql:5432/euchre_camp_shadow + - DATABASE_URL=${DATABASE_URL:-postgresql://euchre_camp:password@your-postgres-host:5432/euchre_camp} + - DATABASE_SHADOW_URL=${DATABASE_SHADOW_URL:-postgresql://euchre_camp:password@your-postgres-host:5432/euchre_camp_shadow} # Better Auth Configuration - # IMPORTANT: Set these via CasaOS environment variables! - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-change-this-secret-in-production} - BETTER_AUTH_URL=${BETTER_AUTH_URL:-http://localhost:3000} @@ -25,13 +27,8 @@ services: - NODE_ENV=production # Trusted Origins for Better Auth - # IMPORTANT: Update this with your CasaOS IP/hostname - TRUSTED_ORIGINS=${TRUSTED_ORIGINS:-http://localhost:3000,http://127.0.0.1:3000} - depends_on: - postgresql: - condition: service_healthy - volumes: # Persist uploaded files and static content - euchre_camp_app_data:/app/public/uploads @@ -41,32 +38,7 @@ services: networks: - euchre-network - postgresql: - image: postgres:15-alpine - container_name: euchre-camp-postgres - environment: - - POSTGRES_DB=euchre_camp - - POSTGRES_USER=euchre_camp - # IMPORTANT: Change this password in production! - - POSTGRES_PASSWORD=euchrepassword - ports: - - "5432:5432" - volumes: - - euchre_camp_postgres_data:/var/lib/postgresql/data - - ./scripts/init-postgres.sh:/docker-entrypoint-initdb.d/init-postgres.sh - healthcheck: - test: ["CMD-SHELL", "pg_isready -U euchre_camp -d euchre_camp"] - interval: 10s - timeout: 5s - retries: 5 - start_period: 30s - restart: unless-stopped - networks: - - euchre-network - volumes: - euchre_camp_postgres_data: - driver: local euchre_camp_app_data: driver: local diff --git a/scripts/setup-casaos.sh b/scripts/setup-casaos.sh index 22c2444..c692a75 100755 --- a/scripts/setup-casaos.sh +++ b/scripts/setup-casaos.sh @@ -31,6 +31,9 @@ POSTGRES_PASSWORD=$(openssl rand -base64 16 | tr -d '\n') echo "✅ Generated BETTER_AUTH_SECRET: $BETTER_AUTH_SECRET" echo "✅ Generated POSTGRES_PASSWORD: $POSTGRES_PASSWORD" echo "" +echo "⚠️ NOTE: The POSTGRES_PASSWORD is for reference only." +echo " You must provide your own PostgreSQL connection string via DATABASE_URL." +echo "" # Create .env file if it doesn't exist if [ ! -f .env ]; then @@ -40,9 +43,10 @@ if [ ! -f .env ]; then # Generated by setup-casaos.sh # Database Configuration +# IMPORTANT: Update these with your actual PostgreSQL connection details! DATABASE_PROVIDER=postgresql -DATABASE_URL=postgresql://euchre_camp:${POSTGRES_PASSWORD}@postgresql:5432/euchre_camp -DATABASE_SHADOW_URL=postgresql://euchre_camp:${POSTGRES_PASSWORD}@postgresql:5432/euchre_camp_shadow +DATABASE_URL=postgresql://euchre_camp:${POSTGRES_PASSWORD}@your-postgres-host:5432/euchre_camp +DATABASE_SHADOW_URL=postgresql://euchre_camp:${POSTGRES_PASSWORD}@your-postgres-host:5432/euchre_camp_shadow # Better Auth Configuration BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET} @@ -65,17 +69,26 @@ echo "Setup Complete!" echo "==========================================" echo "" echo "Next steps for CasaOS deployment:" -echo "1. Build the Docker image:" +echo "" +echo "1. Set up your PostgreSQL database (external)" +echo " - Create database 'euchre_camp'" +echo " - Create user 'euchre_camp' with password" +echo " - Grant all privileges on euchre_camp database" +echo "" +echo "2. Configure CasaOS environment variables:" +echo " - DATABASE_URL: postgresql://user:pass@host:5432/euchre_camp" +echo " - BETTER_AUTH_SECRET: (generated above)" +echo " - BETTER_AUTH_URL: http://your-casaos-ip:3000" +echo " - TRUSTED_ORIGINS: http://your-casaos-ip:3000" +echo "" +echo "3. Build the Docker image:" echo " docker-compose -f docker-compose.casaos.yml build" echo "" -echo "2. Start the application:" +echo "4. Start the application:" echo " docker-compose -f docker-compose.casaos.yml up -d" echo "" -echo "3. Access the application at http://localhost:3000" +echo "5. Access the application at http://your-casaos-ip:3000" echo "" -echo "4. Create admin user:" +echo "6. Create admin user:" echo " docker exec -it euchre-camp node scripts/create-admin-via-api.js" echo "" -echo "Important: Update BETTER_AUTH_URL and TRUSTED_ORIGINS in .env" -echo "with your CasaOS server's IP address or hostname!" -echo "" diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index c0987cf..ce4679e 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -6,6 +6,8 @@ import { getSession } from "@/lib/auth-simple" import type { Event as EventModel } from "@prisma/client" import { RecalculateEloButton } from "../../components/RecalculateEloButton" +export const dynamic = "force-dynamic"; + export default async function AdminDashboard() { console.log('AdminDashboard rendering...') const session = await getSession() diff --git a/src/app/admin/tournaments/[id]/edit/page.tsx b/src/app/admin/tournaments/[id]/edit/page.tsx index d1f6d63..3cbe34a 100644 --- a/src/app/admin/tournaments/[id]/edit/page.tsx +++ b/src/app/admin/tournaments/[id]/edit/page.tsx @@ -1,4 +1,5 @@ import { prisma } from "@/lib/prisma" +export const dynamic = "force-dynamic"; import Navigation from "@/components/Navigation" import Link from "next/link" import { notFound, redirect } from "next/navigation" diff --git a/src/app/admin/tournaments/[id]/page.tsx b/src/app/admin/tournaments/[id]/page.tsx index d4a153d..616d2fc 100644 --- a/src/app/admin/tournaments/[id]/page.tsx +++ b/src/app/admin/tournaments/[id]/page.tsx @@ -1,4 +1,5 @@ import { prisma } from "@/lib/prisma" +export const dynamic = "force-dynamic"; import Navigation from "@/components/Navigation" import Link from "next/link" import { notFound, redirect } from "next/navigation" diff --git a/src/app/admin/tournaments/[id]/results/page.tsx b/src/app/admin/tournaments/[id]/results/page.tsx index 91135fe..6ba41e5 100644 --- a/src/app/admin/tournaments/[id]/results/page.tsx +++ b/src/app/admin/tournaments/[id]/results/page.tsx @@ -1,4 +1,5 @@ import { prisma } from "@/lib/prisma" +export const dynamic = "force-dynamic"; import Navigation from "@/components/Navigation" import Link from "next/link" import { notFound, redirect } from "next/navigation" diff --git a/src/app/admin/tournaments/page.tsx b/src/app/admin/tournaments/page.tsx index c47efdf..5f3783b 100644 --- a/src/app/admin/tournaments/page.tsx +++ b/src/app/admin/tournaments/page.tsx @@ -1,4 +1,5 @@ import { prisma } from "@/lib/prisma" +export const dynamic = "force-dynamic"; import Navigation from "@/components/Navigation" import Link from "next/link" import { getSession } from "@/lib/auth-simple" diff --git a/src/app/matches/[id]/page.tsx b/src/app/matches/[id]/page.tsx index 8c02967..de8468c 100644 --- a/src/app/matches/[id]/page.tsx +++ b/src/app/matches/[id]/page.tsx @@ -1,4 +1,5 @@ import { prisma } from "@/lib/prisma"; +export const dynamic = "force-dynamic"; import { notFound } from "next/navigation"; import Link from "next/link"; import Navigation from "@/components/Navigation"; diff --git a/src/app/players/[id]/profile/page.tsx b/src/app/players/[id]/profile/page.tsx index cda36da..837b0f2 100644 --- a/src/app/players/[id]/profile/page.tsx +++ b/src/app/players/[id]/profile/page.tsx @@ -1,4 +1,5 @@ import { prisma } from "@/lib/prisma" +export const dynamic = "force-dynamic"; import Navigation from "@/components/Navigation" import Link from "next/link" import { notFound } from "next/navigation" diff --git a/src/app/players/[id]/schedule/page.tsx b/src/app/players/[id]/schedule/page.tsx index 5ce4c19..46f2932 100644 --- a/src/app/players/[id]/schedule/page.tsx +++ b/src/app/players/[id]/schedule/page.tsx @@ -1,4 +1,5 @@ import { prisma } from "@/lib/prisma" +export const dynamic = "force-dynamic"; import Navigation from "@/components/Navigation" import Link from "next/link" import { notFound } from "next/navigation" diff --git a/src/app/rankings/page.tsx b/src/app/rankings/page.tsx index 8288561..998ce23 100644 --- a/src/app/rankings/page.tsx +++ b/src/app/rankings/page.tsx @@ -1,4 +1,5 @@ import { prisma } from "@/lib/prisma" +export const dynamic = "force-dynamic"; import Navigation from "@/components/Navigation" import RankingsClient from "./RankingsClient"