Deployment Guide
This guide covers deploying Sightline to various hosting platforms.
Prerequisites
Before deploying, you'll need:
- Mapbox Access Token - Get one here
- Your incident data - Either a JSON file or API endpoint
- Git repository - Fork or clone the project
Environment Variables
All deployments require these environment variables:
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_MAPBOX_TOKEN | Yes | Mapbox GL access token |
NEXT_PUBLIC_SITE_NAME | No | Site name (fallback in config) |
NEXT_PUBLIC_SITE_DESCRIPTION | No | Site description |
NEXT_PUBLIC_SUPABASE_URL | If using Supabase | Supabase project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY | If using Supabase | Supabase anonymous key |
Vercel (Recommended)
Vercel provides the smoothest deployment experience for Next.js applications.
One-Click Deploy
Manual Deployment
-
Fork the repository on GitHub
-
Connect to Vercel
- Go to vercel.com/new
- Import your forked repository
- Configure environment variables
-
Configure environment variables
NEXT_PUBLIC_MAPBOX_TOKEN=pk.your_token_here- Deploy
- Vercel will automatically build and deploy
- Updates deploy automatically when you push to main
Custom Domain
- Go to Project Settings → Domains
- Add your custom domain
- Configure DNS as instructed
Netlify
Netlify also works well with Next.js projects.
Deployment Steps
-
Fork the repository on GitHub
-
Connect to Netlify
- Go to app.netlify.com
- Click "Add new site" → "Import an existing project"
- Connect your GitHub account and select the repository
-
Configure build settings
Build command: pnpm build
Publish directory: .next-
Add environment variables
- Go to Site Settings → Environment Variables
- Add
NEXT_PUBLIC_MAPBOX_TOKEN
-
Install Next.js plugin
Create
netlify.tomlin your project root:
[build]
command = "pnpm build"
publish = ".next"
[[plugins]]
package = "@netlify/plugin-nextjs"- Deploy
- Commit and push changes
- Netlify will build and deploy automatically
Docker
Self-host Sightline using Docker.
Dockerfile
Create a Dockerfile in your project root:
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Install dependencies
RUN pnpm install --frozen-lockfile
# Copy source
COPY . .
# Build arguments for environment variables
ARG NEXT_PUBLIC_MAPBOX_TOKEN
ENV NEXT_PUBLIC_MAPBOX_TOKEN=$NEXT_PUBLIC_MAPBOX_TOKEN
# Build
RUN pnpm build
# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
# Copy built assets
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]Docker Compose
Create docker-compose.yml:
version: '3.8'
services:
sightline:
build:
context: .
args:
NEXT_PUBLIC_MAPBOX_TOKEN: ${NEXT_PUBLIC_MAPBOX_TOKEN}
ports:
- '3000:3000'
environment:
- NODE_ENV=production
restart: unless-stoppedBuilding and Running
# Build the image
docker build \
--build-arg NEXT_PUBLIC_MAPBOX_TOKEN=your_token \
-t sightline .
# Run the container
docker run -p 3000:3000 sightline
# Or use docker-compose
NEXT_PUBLIC_MAPBOX_TOKEN=your_token docker-compose up -dNext.js Standalone Output
For Docker deployments, enable standalone output in next.config.ts:
const nextConfig: NextConfig = {
output: 'standalone',
// ... other config
};Static Export (Advanced)
For static hosting without server-side features:
- Update next.config.ts
const nextConfig: NextConfig = {
output: 'export',
images: { unoptimized: true },
};- Build
pnpm buildnpm run buildyarn buildbun run build- Deploy the
outdirectory to any static host (S3, GitHub Pages, etc.)
Note: Static export doesn't support server actions, API routes, or ISR.
Post-Deployment
After deploying:
- Verify the map loads - Check that Mapbox tiles render correctly
- Test data loading - Ensure your incidents appear on the map
- Check mobile responsiveness - Test on various devices
- Set up monitoring - Consider adding error tracking (Sentry, etc.)
Troubleshooting
Map doesn't render
- Verify
NEXT_PUBLIC_MAPBOX_TOKENis set correctly - Check browser console for Mapbox errors
- Ensure token has correct scopes for the styles you're using
Data doesn't load
- Check network tab for failed requests
- Verify data file path or API endpoint is correct
- Check CORS settings if using external API
Build fails
- Run
npm run buildlocally first - Check for TypeScript errors with
npm run type-check - Ensure all dependencies are installed
Performance Optimization
For production deployments:
- Enable caching - Configure CDN caching for static assets
- Compress images - Use WebP format for media
- Monitor performance - Use Vercel Analytics or similar tools
- Set up ISR - For frequently updated data, use Incremental Static Regeneration