Step 4
Step 4 — Deploy (Fly.io)
Step 4 — Deploy (Fly.io)
Two paths. Vercel is easiest, but Fly.io gives you free PostgreSQL in one place — better for fullstack practice.
Standalone build
next.config.ts:
import type { NextConfig } from "next";
const config: NextConfig = {
output: "standalone",
};
export default config;
Dockerfile
FROM node:20-slim AS base
RUN corepack enable && corepack prepare pnpm@10.33.0 --activate
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN pnpm build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]
Fly.io deploy
brew install flyctl # or winget install flyctl
fly auth signup
fly launch # generates fly.toml
fly postgres create # create DB
fly postgres attach # attach to app
fly deploy
Where next
After deploy, attach a custom domain (CNAME), or add GitHub Actions to auto-deploy on push.
You did it — a full cycle, end to end. 🎉