Skip to content
Draft
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ client/
- Domain DNS properly pointed to VPS

## Emergency Contacts
- **Primary contact**: hello@inciaandarvins.wedding
- **Primary contact**: hello@arvinwedsincia.com
- **Phone**: +880 1234-567890
- **Location**: Dhaka, Bangladesh

Expand Down
140 changes: 140 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Deploy to Hostinger VPS

on:
push:
branches: [ main, production ]
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'production'
type: choice
options:
- production
- staging

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: client/package-lock.json

- name: Install dependencies
run: |
cd client
npm ci

- name: Run tests
run: |
cd client
npm test -- --passWithNoTests

- name: Build application
run: |
cd client
npm run build
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }}
CLOUDINARY_API_KEY: ${{ secrets.CLOUDINARY_API_KEY }}
CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET }}

- name: Deploy to VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
script: |
# Set variables
APP_DIR="/var/www/wedding"
REPO_URL="https://github.com/${{ github.repository }}.git"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)

# Create release directory
mkdir -p "$APP_DIR/releases"
cd "$APP_DIR/releases"

# Clone repository
git clone -b ${{ github.ref_name }} "$REPO_URL" "$TIMESTAMP"
cd "$TIMESTAMP/client"

# Install dependencies
npm ci --production=false

# Create environment file
cat > .env.local << 'EOF'
DATABASE_URL="${{ secrets.DATABASE_URL }}"
NEXTAUTH_SECRET="${{ secrets.NEXTAUTH_SECRET }}"
NEXTAUTH_URL="${{ secrets.NEXTAUTH_URL }}"
RESEND_API_KEY="${{ secrets.RESEND_API_KEY }}"
CLOUDINARY_CLOUD_NAME="${{ secrets.CLOUDINARY_CLOUD_NAME }}"
CLOUDINARY_API_KEY="${{ secrets.CLOUDINARY_API_KEY }}"
CLOUDINARY_API_SECRET="${{ secrets.CLOUDINARY_API_SECRET }}"
NODE_ENV="production"
PORT=3000
EOF

# Generate Prisma client and run migrations
npm run db:generate
npm run db:push

# Build application
npm run build

# Backup current deployment
if [ -d "$APP_DIR/current" ]; then
mv "$APP_DIR/current" "$APP_DIR/backup-$(date +%Y%m%d-%H%M%S)" || true
fi

# Update symbolic link
ln -sfn "$APP_DIR/releases/$TIMESTAMP" "$APP_DIR/current"

# Restart application
pm2 restart wedding-website || pm2 start ecosystem.config.js --env production
pm2 save

# Cleanup old releases (keep last 5)
cd "$APP_DIR/releases"
ls -t | tail -n +6 | xargs -d '\n' rm -rf -- || true

echo "Deployment completed successfully!"

- name: Health Check
run: |
# Wait for application to start
sleep 30

# Check if website is responding
response=$(curl -s -o /dev/null -w "%{http_code}" "${{ secrets.NEXTAUTH_URL }}/api/health" || echo "000")

if [ "$response" = "200" ]; then
echo "βœ… Health check passed - Application is running"
else
echo "❌ Health check failed - HTTP status: $response"
exit 1
fi

- name: Notify deployment status
if: always()
run: |
if [ "${{ job.status }}" = "success" ]; then
echo "πŸŽ‰ Deployment successful!"
echo "Website: ${{ secrets.NEXTAUTH_URL }}"
else
echo "❌ Deployment failed!"
fi
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Production builds
.next/
out/
dist/
build/

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Database
*.db
*.sqlite

# Logs
logs/
*.log

# Runtime data
pids/
*.pid
*.seed
*.pid.lock

# Deployment
deployment/logs/
*.pem
*.key

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# IDE
.vscode/
.idea/
*.swp
*.swo
*~

# Testing
coverage/
.jest/

# Temporary files
tmp/
temp/
131 changes: 131 additions & 0 deletions CREDENTIALS_CHECKLIST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Required Credentials and Setup Information

## πŸ”‘ Hostinger VPS Credentials Needed

### VPS Server Access
```
VPS IP Address: ________________
SSH Username: root (or custom)
SSH Password: ________________
OR SSH Private Key: [paste key content]
SSH Port: 22 (or custom)
```

### Domain Information
```
Domain Name: ________________
DNS Status: βœ… Already configured to point to VPS
```

### MySQL Database (if using Hostinger's service)
```
MySQL Host: ________________
MySQL Username: ________________
MySQL Password: ________________
Database Name: wedding_db (recommended)
```

## 🌐 External Service Accounts Required

### 1. Cloudinary (Media Storage)
**Sign up at: https://cloudinary.com**
```
Cloud Name: ________________
API Key: ________________
API Secret: ________________
```

**How to get Cloudinary credentials:**
1. Create free account at cloudinary.com
2. Go to Dashboard
3. Copy Cloud Name, API Key, and API Secret

### 2. Resend (Email Service)
**Sign up at: https://resend.com**
```
API Key: ________________
```

**How to get Resend API key:**
1. Create free account at resend.com
2. Go to API Keys section
3. Create new API key
4. Copy the key (starts with "re_")

### 3. NextAuth Secret
**Generate secure random string:**
```bash
# Run this command to generate:
openssl rand -base64 32
```
```
Generated Secret: ________________
```

## πŸ“‹ GitHub Repository Secrets Setup

**Go to: GitHub Repository β†’ Settings β†’ Secrets and variables β†’ Actions**

Add these secrets:

| Secret Name | Value | Description |
|-------------|-------|-------------|
| `VPS_HOST` | [Your VPS IP] | Server IP address |
| `VPS_USERNAME` | `deploy` | SSH username (created by setup script) |
| `VPS_SSH_KEY` | [SSH Private Key] | Private key for server access |
| `VPS_PORT` | `22` | SSH port number |
| `DATABASE_URL` | `mysql://wedding_user:password@localhost:3306/wedding_db` | Database connection string |
| `NEXTAUTH_SECRET` | [Generated secret] | JWT signing key |
| `NEXTAUTH_URL` | `https://arvinwedsincia.com` | Your website URL |
| `RESEND_API_KEY` | [Resend API key] | Email service key |
| `CLOUDINARY_CLOUD_NAME` | [Cloudinary cloud name] | Media storage cloud name |
| `CLOUDINARY_API_KEY` | [Cloudinary API key] | Media storage API key |
| `CLOUDINARY_API_SECRET` | [Cloudinary API secret] | Media storage API secret |

## βœ… Pre-deployment Checklist

- [ ] VPS is accessible via SSH
- [ ] Domain is pointing to VPS IP address
- [ ] Cloudinary account created and credentials obtained
- [ ] Resend account created and API key obtained
- [ ] NextAuth secret generated
- [ ] All GitHub secrets configured
- [ ] MySQL database service is available

## πŸš€ Quick Deployment Commands

### Step 1: Server Setup (run as root)
```bash
curl -sSL https://raw.githubusercontent.com/syed-reza98/Sharothee-Wedding/main/deployment/01-server-setup.sh | bash
```

### Step 2: Update domain name
```bash
nano /etc/nginx/sites-available/wedding
# Replace 'arvinwedsincia.com' with actual domain
```

### Step 3: SSL Certificate
```bash
./deployment/03-setup-ssl.sh arvinwedsincia.com
```

### Step 4: Deploy Application
Push to main branch or run manually:
```bash
su - deploy
./deployment/02-deploy-app.sh
```

## πŸ“ž Support Information

If you encounter issues during deployment:

1. **Check the deployment logs**: `/var/www/wedding/logs/`
2. **Review the README**: `deployment/README.md`
3. **Common issues**: See troubleshooting section in README
4. **Contact**: Create an issue in the GitHub repository

---

**πŸŽ‰ Ready to deploy? Follow the step-by-step guide in `deployment/README.md`**
Loading