diff --git a/.gitignore b/.gitignore index 8777267..7683f5a 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,9 @@ yarn-error.log* # local env files .env*.local +# Firebase service account keys +firebase-service-account.json + # vercel .vercel diff --git a/README.md b/README.md index 96b2644..3133a09 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,62 @@ npm run build Deploy to Vercel or any platform supporting Next.js PWAs. +## Docker Deployment + +The app includes Docker support for containerized deployment with automated email scheduling. + +### Build and Push Docker Image + +1. **Using the automated script (Windows):** + ```powershell + .\build-and-push-docker.ps1 + ``` + This script will: + - Build the Docker image + - Prompt for your GitHub Personal Access Token + - Login to GitHub Container Registry + - Push the image + +2. **Manual build and push:** + ```bash + # Build the image + docker build -t ghcr.io/nmemmert/prayer-app:latest . + + # Login to GitHub Container Registry + echo $GITHUB_TOKEN | docker login ghcr.io -u nmemmert --password-stdin + + # Push the image + docker push ghcr.io/nmemmert/prayer-app:latest + ``` + +### Run with Docker Compose + +```bash +docker-compose up -d +``` + +The container includes: +- Automated email scheduling (runs every 5 minutes) +- Health checks +- Production-optimized Next.js build +- Cron jobs for scheduled tasks + +### Environment Variables + +Set these environment variables for the container: + +```bash +# Firebase Admin SDK (required for server-side operations) +FIREBASE_PROJECT_ID=your_project_id +FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n..." +FIREBASE_CLIENT_EMAIL=your_service_account_email + +# EmailJS (for client-side emails) +NEXT_PUBLIC_EMAILJS_SERVICE_ID=your_service_id +NEXT_PUBLIC_EMAILJS_TEMPLATE_ID=your_template_id +NEXT_PUBLIC_EMAILJS_PUBLIC_KEY=your_public_key +``` + ## Learn More To learn more about Next.js, take a look at the following resources: diff --git a/build-and-push-docker.ps1 b/build-and-push-docker.ps1 new file mode 100644 index 0000000..43cee29 --- /dev/null +++ b/build-and-push-docker.ps1 @@ -0,0 +1,32 @@ +# Docker Build and Push Script for Prayer App +# Run this script to build and push the Docker container to GitHub Container Registry + +Write-Host "🔨 Building Docker image..." -ForegroundColor Green +docker build -t ghcr.io/nmemmert/prayer-app:latest . + +if ($LASTEXITCODE -eq 0) { + Write-Host "✅ Docker image built successfully!" -ForegroundColor Green + + Write-Host "🔐 Logging into GitHub Container Registry..." -ForegroundColor Yellow + Write-Host "Please enter your GitHub Personal Access Token (with package write permissions):" -ForegroundColor Yellow + $token = Read-Host -AsSecureString + $tokenPlain = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($token)) + + echo $tokenPlain | docker login ghcr.io -u nmemmert --password-stdin + + if ($LASTEXITCODE -eq 0) { + Write-Host "🚀 Pushing Docker image to GitHub Container Registry..." -ForegroundColor Green + docker push ghcr.io/nmemmert/prayer-app:latest + + if ($LASTEXITCODE -eq 0) { + Write-Host "✅ Docker image pushed successfully!" -ForegroundColor Green + Write-Host "🌐 Your container is now available at: ghcr.io/nmemmert/prayer-app:latest" -ForegroundColor Cyan + } else { + Write-Host "❌ Failed to push Docker image" -ForegroundColor Red + } + } else { + Write-Host "❌ Failed to login to GitHub Container Registry" -ForegroundColor Red + } +} else { + Write-Host "❌ Failed to build Docker image" -ForegroundColor Red +} \ No newline at end of file