Files
euchre_camp/scripts/setup-casaos.sh
T

95 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# CasaOS Setup Script for EuchreCamp
# Run this script to prepare EuchreCamp for CasaOS deployment
set -e
echo "=========================================="
echo "EuchreCamp CasaOS Setup Script"
echo "=========================================="
echo ""
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed or not in PATH"
echo "Please install Docker before continuing"
exit 1
fi
# Check if docker-compose is available
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo "❌ Docker Compose is not installed"
echo "Please install Docker Compose before continuing"
exit 1
fi
# Generate secrets if they don't exist
echo "Generating secrets..."
BETTER_AUTH_SECRET=$(openssl rand -base64 32 | tr -d '\n')
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
echo "Creating .env file..."
cat > .env << EOF
# EuchreCamp Environment Configuration
# 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}@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}
BETTER_AUTH_URL=http://localhost:3000
# Application Configuration
NODE_ENV=production
# Trusted Origins (update with your CasaOS IP/hostname)
TRUSTED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
EOF
echo "✅ Created .env file"
else
echo "⚠️ .env file already exists, skipping creation"
fi
echo ""
echo "=========================================="
echo "Setup Complete!"
echo "=========================================="
echo ""
echo "Next steps for CasaOS deployment:"
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 "4. Start the application:"
echo " docker-compose -f docker-compose.casaos.yml up -d"
echo ""
echo "5. Access the application at http://your-casaos-ip:3000"
echo ""
echo "6. Create admin user:"
echo " docker exec -it euchre-camp node scripts/create-admin-via-api.js"
echo ""