Deployment

Guide for deploying ShipKit to production

Deployment Guide

This guide covers the deployment process for ShipKit using Vercel.

Quick Start

Deploy ShipKit to Vercel with one click:

Deploy with Vercel

Runtime Support

ShipKit supports:

  • Node.js (16.x, 18.x, 20.x)
  • Bun
  • Deno (via Node compatibility mode)

Package Manager Support

Use your preferred package manager:

# Install dependencies
npm install   # npm (default)
# or
pnpm install  # pnpm (recommended)
# or
yarn install  # yarn
# or
bun install   # bun

Prerequisites

Before deploying, ensure you have:

  1. A Vercel account
  2. Access to all required services:
    • PostgreSQL database (recommended: Neon or Supabase)
    • Resend (email service)
    • OAuth providers (GitHub, Discord, Google)
    • LemonSqueezy (payments)

Environment Variables

Set up the following environment variables in your Vercel project:

# Core Auth
AUTH_URL="https://your-domain.com"
AUTH_SECRET="your_secure_secret"

# OAuth Providers
AUTH_GITHUB_ID="your_github_id"
AUTH_GITHUB_SECRET="your_github_secret"
AUTH_DISCORD_ID="your_discord_id"
AUTH_DISCORD_SECRET="your_discord_secret"
AUTH_GOOGLE_ID="your_google_id"
AUTH_GOOGLE_SECRET="your_google_secret"

# Database
DATABASE_URL="your_production_database_url"

# Email
RESEND_API_KEY="your_resend_api_key"

# Payments
LEMONSQUEEZY_API_KEY="your_lemonsqueezy_api_key"
LEMONSQUEEZY_STORE_ID="your_store_id"
LEMONSQUEEZY_WEBHOOK_SECRET="your_webhook_secret"

# CMS
PAYLOAD_SECRET="your_secure_payload_secret"

# Node Environment
NODE_ENV="production"

Vercel Configuration

The project includes a vercel.json configuration file with the following settings:

  • Build Command: pnpm run build
  • Development Command: pnpm run dev
  • Install Command: pnpm install
  • Framework: Next.js
  • Region: iad1 (US East)
  • Git Deployment: Enabled for main branch only
  • Cron Jobs: Daily cleanup at midnight
  • Function Configuration: 1GB memory, 10s timeout
  • Security Headers: XSS protection, content type options, frame options

Deployment Process

1. Automated Deployment

  1. Click the "Deploy to Vercel" button above
  2. Choose your repository name
  3. Deploy without any environment variables initially
  4. Follow the post-deployment setup wizard

2. Manual Deployment

If you prefer to deploy manually:

# Clone the repository
git clone https://github.com/shipkit-io/shipkit.git
cd shipkit

# Install dependencies
pnpm install

# Build the application
pnpm build

# Start in production mode
pnpm start

3. Post-Deployment Setup

The setup wizard will guide you through configuring:

  1. Database

    • Set up PostgreSQL on Neon or Supabase
    • Configure connection string
    • Run initial migrations
  2. Authentication

    • Set up OAuth providers
    • Configure callback URLs
    • Set authentication secrets
  3. Payment & Licensing

    • Connect LemonSqueezy
    • Configure webhooks
    • Set up API access
  4. Content Management

    • Configure Payload CMS
    • Set up Builder.io (optional)
  5. Email

    • Set up Resend
    • Configure email templates
    • Test email delivery

Production Optimizations

The project includes several production optimizations:

  1. Next.js Configuration:

    • Remote image patterns configured for various services
    • MDX support enabled
    • Server actions size limit set
    • Next Script Workers enabled
  2. Security:

    • Strict CSP headers
    • XSS protection
    • Frame options set to DENY
    • Content type options set to nosniff
  3. Performance:

    • Automatic image optimization
    • Edge functions in US East region
    • Memory limits set for API routes

Monitoring and Maintenance

  1. Logs: Monitor application logs in Vercel's dashboard

  2. Cron Jobs: The /api/cron/cleanup endpoint runs daily at midnight

  3. Database: Ensure regular backups of your production database

  4. Error Tracking: Set up error tracking through Vercel's integration with your preferred service

Troubleshooting

Common deployment issues and solutions:

  1. Build Failures:

    • Check build logs in Vercel
    • Verify all environment variables are set
    • Ensure dependencies are correctly installed
  2. Runtime Errors:

    • Monitor server logs
    • Check database connectivity
    • Verify third-party service credentials
  3. Performance Issues:

    • Monitor Edge Function execution times
    • Check database query performance
    • Review API route response times
  4. Runtime-Specific Issues:

    • Node.js: Ensure you're using version 16.x or later
    • Bun: Check Bun version is 1.0 or later
    • Deno: Enable Node.js compatibility mode

Best Practices

  1. Testing:

    • Always test in a staging environment first
    • Use environment variables for staging configuration
    • Run full test suite before deploying
  2. Security:

    • Regularly rotate secrets and API keys
    • Monitor for suspicious activity
    • Keep dependencies updated
  3. Maintenance:

    • Schedule regular database maintenance
    • Monitor disk usage and performance
    • Keep Next.js and dependencies updated

Need Help?