Documentation

Deployment

Learn how to deploy your Sushify Next.js application to production

Sushify Next.js can be deployed to various platforms. This guide covers deployment to Vercel (recommended), as well as other popular platforms.

Vercel is the recommended deployment platform for Next.js applications, offering zero-configuration deployment with optimal performance.

Prerequisites

  • A Vercel account
  • Your project pushed to GitHub, GitLab, or Bitbucket
  • Environment variables configured

Deployment Steps

1. Connect Repository

  1. Go to vercel.com/new
  2. Import your Git repository
  3. Select the repository containing your Sushify Next.js project

2. Configure Project

Vercel will automatically detect Next.js. Configure the following:

Framework Preset: Next.js
Root Directory: apps/web
Build Command: turbo run build
Output Directory: .next
Install Command: pnpm install

3. Environment Variables

Add all required environment variables:

# Database
DATABASE_URL="postgresql://..."

# Authentication
BETTER_AUTH_SECRET="..."
GOOGLE_CLIENT_ID="..."
GOOGLE_CLIENT_SECRET="..."
GITHUB_CLIENT_ID="..."
GITHUB_CLIENT_SECRET="..."

# ...others

4. Deploy

Click "Deploy" and wait for the build to complete.

Custom Domain

  1. Go to your project settings
  2. Navigate to "Domains"
  3. Add your custom domain
  4. Configure DNS records as instructed

Automatic Deployments

Vercel automatically deploys:

  • Production: Pushes to main/master branch
  • Preview: Pull requests and other branches

Alternative Deployment Platforms

Netlify

# Install Netlify CLI
npm install -g netlify-cli

# Deploy
netlify deploy --prod

netlify.toml:

[build]
  command = "pnpm build"
  publish = ".next"

[[plugins]]
  package = "@netlify/plugin-nextjs"

Railway

  1. Create project at railway.app
  2. Connect Git repository
  3. Railway auto-detects Next.js
  4. Add environment variables
  5. Deploy

DigitalOcean App Platform

  1. Create app at digitalocean.com
  2. Connect repository
  3. Configure build:
name: sushify-app
services:
  - name: web
    build_command: pnpm build
    run_command: pnpm start
    environment_slug: node-js
    envs:
      - key: DATABASE_URL
        value: ${db.DATABASE_URL}

Self-Hosted (Docker)

Create Dockerfile:

FROM node:20-alpine AS base

# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate

# Copy package files
COPY package.json pnpm-lock.yaml ./
COPY pnpm-workspace.yaml ./
COPY packages ./packages
COPY apps ./apps

RUN pnpm install --frozen-lockfile

# Build the application
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

RUN corepack enable && corepack prepare pnpm@latest --activate
RUN pnpm build

# Production image
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

CMD ["node", "server.js"]

docker-compose.yml:

version: '3.8'

services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgresql://user:pass@db:5432/sushify
      - BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET}
      # Add other env vars
    depends_on:
      - db

  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: sushify
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Deploy:

docker-compose up -d