2025-08-20 00:43:09 +01:00
# 🚀 ScriptShare - Platform Deployment Guide
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
## Overview
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
ScriptShare is a modern React application with a Node.js API backend, designed to work seamlessly with any deployment platform including **Vercel** , **Coolify** , **DigitalOcean App Platform** , **Railway** , **Render** , and others.
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
## 📦 Application Structure
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Frontend (React + Vite)
- **Dockerfile**: `Dockerfile`
- **Build**: Vite-based React application
- **Output**: Static files served by Nginx
- **Port**: 80
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Backend API (Node.js + Express)
- **Dockerfile**: `Dockerfile.api`
- **Runtime**: Node.js 18 with TypeScript
- **Port**: 3000
- **Health Check**: `/api/health`
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
## 🔧 Deployment Options
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Option 1: Vercel (Recommended for Frontend)
**Frontend Deployment:**
1. Connect your repository to Vercel
2. Set build command: `npm run build`
3. Set output directory: `dist`
4. Configure environment variables:
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
VITE_APP_NAME=ScriptShare
VITE_APP_URL=https://your-domain.vercel.app
VITE_ANALYTICS_ENABLED=true
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
**API Deployment:**
- Deploy API separately to platforms like Railway, Render, or DigitalOcean
- Or use Vercel Functions (requires code modification)
### Option 2: Coolify (Full Stack)
**Deploy both frontend and API:**
1. Create application from Git repository
2. **Frontend** :
- Use `Dockerfile`
- Port: 80
3. **API** :
- Use `Dockerfile.api`
- Port: 3000
4. Configure environment variables
### Option 3: DigitalOcean App Platform
Create `app.yaml` :
```yaml
name: scriptshare
services:
- name: frontend
source_dir: /
dockerfile_path: Dockerfile
github:
repo: your-username/scriptshare-cursor
branch: main
http_port: 80
routes:
- path: /
- name: api
source_dir: /
dockerfile_path: Dockerfile.api
github:
repo: your-username/scriptshare-cursor
branch: main
http_port: 3000
routes:
- path: /api
envs:
- key: NODE_ENV
value: production
- key: DATABASE_URL
value: ${DATABASE_URL}
databases:
- name: scriptshare-db
engine: MYSQL
version: "8"
```
### Option 4: Railway
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
1. **Frontend** : Connect repo, Railway auto-detects Dockerfile
2. **API** : Deploy from same repo using `Dockerfile.api`
3. **Database** : Add MySQL service
4. Configure environment variables
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Option 5: Render
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
1. **Frontend** :
- Static Site
- Build Command: `npm run build`
- Publish Directory: `dist`
2. **API** :
- Web Service
- Docker build using `Dockerfile.api`
3. **Database** : Add MySQL database
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
## 🏗️ Build Commands
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Frontend
2025-08-19 23:21:11 +01:00
```bash
2025-08-20 00:43:09 +01:00
# Install dependencies
npm install
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
# Build for production
npm run build
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
# Preview build
npm run preview
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
### API
```bash
# Install dependencies
npm install
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
# Build TypeScript
npm run build:api
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
# Start API server
npm run start:api
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
## 🔐 Environment Variables
### Frontend (Build-time)
- `VITE_APP_NAME` - Application name
- `VITE_APP_URL` - Frontend URL
- `VITE_ANALYTICS_ENABLED` - Enable analytics (true/false)
### API (Runtime)
- `NODE_ENV` - Environment (production/development)
- `PORT` - Server port (default: 3000)
- `DATABASE_URL` - MySQL connection string
- `JWT_SECRET` - JWT secret key
- `CORS_ORIGIN` - Allowed CORS origins
## 🗄️ Database Setup
### MySQL Connection String Format:
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
DATABASE_URL=mysql://username:password@host:port/database
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
### Required Tables:
The application uses Drizzle ORM. Run migrations after deployment:
2025-08-19 23:21:11 +01:00
```bash
2025-08-20 00:43:09 +01:00
npm run db:migrate
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
## 🔍 Health Checks
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Frontend Health Check:
```
GET /health
```
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### API Health Check:
```
GET /api/health
```
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
## 📝 Platform-Specific Notes
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Vercel
- Frontend deploys automatically
- Use Vercel Functions for API (requires modification)
- Environment variables in Vercel dashboard
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Coolify
- Supports full Docker deployment
- Easy environment variable management
- Built-in SSL and domain management
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### DigitalOcean App Platform
- Use `app.yaml` for configuration
- Automatic HTTPS
- Managed database available
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Railway
- Auto-deployment from Git
- Environment variables in dashboard
- Add-on database services
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Render
- Separate frontend (static) and backend (web service)
- Auto-deployment from Git
- Environment variables in dashboard
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
## 🐳 Docker Commands
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Build Frontend:
2025-08-19 23:21:11 +01:00
```bash
2025-08-20 00:43:09 +01:00
docker build -t scriptshare-frontend .
docker run -p 3000:80 scriptshare-frontend
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
### Build API:
2025-08-19 23:21:11 +01:00
```bash
2025-08-20 00:43:09 +01:00
docker build -f Dockerfile.api -t scriptshare-api .
docker run -p 3001:3000 scriptshare-api
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
### Local Development:
2025-08-19 23:21:11 +01:00
```bash
2025-08-20 00:43:09 +01:00
docker-compose up
2025-08-19 23:21:11 +01:00
```
2025-08-20 00:43:09 +01:00
## 🔧 Local Development
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Frontend:
```bash
npm run dev
```
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### API:
```bash
npm run build:api
npm run start:api
```
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Database:
```bash
npm run db:studio # Drizzle Studio
npm run db:migrate # Run migrations
```
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
## 🚀 Quick Deploy Examples
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Deploy to Vercel (Frontend):
```bash
vercel --prod
```
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Deploy to Railway:
```bash
railway deploy
```
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
### Deploy to Render:
Connect GitHub repository in Render dashboard
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
## 📞 Support
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
- **Documentation**: Check platform-specific documentation
- **Environment**: Ensure all required environment variables are set
- **Health Checks**: Monitor `/health` and `/api/health` endpoints
- **Logs**: Check platform logs for deployment issues
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
---
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
**Your ScriptShare application is ready for deployment on any modern platform! 🎉**
2025-08-19 23:21:11 +01:00
2025-08-20 00:43:09 +01:00
Choose the platform that best fits your needs - from simple static hosting to full-stack container deployments.