How to Deploy a Next.js App

Multi-stage Docker build. No Vercel required.

What you're building

A Next.js app deployed on PromptShip using a multi-stage Docker build that keeps the final image small.

Add a Dockerfile

Place this Dockerfile in your repo root:

FROM node:22-slim AS builder

WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22-slim
WORKDIR /app
COPY --from=builder /app/.next .next
COPY --from=builder /app/node_modules node_modules
COPY --from=builder /app/package.json .
COPY --from=builder /app/public public

EXPOSE $PORT
ENV PORT=8080
CMD ["npm", "start"]

PORT: The ENV PORT=8080 line sets a default. PromptShip overrides it at deploy time via the PORT environment variable. Next.js reads PORT automatically.

How do I deploy it?

Step 1: Create the app

create_app(
  name: "my-nextjs-app",
  github_repo: "github.com/me/my-nextjs-app"
)

Step 2: Deploy

deploy_app(app_name: "my-nextjs-app", branch: "main")

Your app is live at https://my-nextjs-app-dev.promptship.dev

How do I add API routes with a database?

If your Next.js app has API routes that need a database:

attach_postgres(app_name: "my-nextjs-app", environment: "dev", tier: "pg-1")
deploy_app(app_name: "my-nextjs-app", branch: "main")

Access via process.env.DATABASE_URL in your API routes.

Next steps