Next.js + PostgreSQL + Prisma
Next.js is the React framework for production: server-side rendering, static generation, API routes, and image optimization, without needing to configure anything.
This Stack integrates it with PostgreSQL via Prisma, an ORM that generates a typed client from your schema, so queries are validated at compile time rather than in production.
Included services
In addition to your application, the Stack runs PostgreSQL, an nginx that receives traffic on port 80, an automatic backups service and the web file manager.
Project structure
.
βββ app
β βββ prisma
β β βββ schema.prisma
β βββ src
β β βββ ...
β βββ next-env.d.ts
β βββ next.config.js
β βββ package.json
β βββ tsconfig.json
βββ backup
β βββ backup-runner.sh
βββ nginx
β βββ default.conf
βββ .env.example
βββ app.Dockerfile
βββ compose.yaml
Getting started
Install the Stack and bring it up:
docker-deploy-stack --stack javascript/nextjs-postgres-prisma
cd /root/stack/javascript/nextjs-postgres-prisma
docker compose up -d
Then replace the example application with yours, from Git, via SFTP, or using the web file manager, following how-do-i-deploy-an-application-on-a-stack.md. Your code goes in the app/ folder.
Whenever you update the code, apply the changes:
docker compose up -d --build
Configuration
Editable values are in the Stackβs .env file:
| Variable | Default | Purpose |
|---|---|---|
APP_PORT |
80 |
Public port of the Stack. |
APP_ENV |
development |
Application environment. |
DB_NAME |
nextjs |
Database name. |
DB_USER |
nextjs |
Database user. |
BACKUP_ENABLED |
1 |
Automatic backups: 1 enabled, 0 disabled. |
BACKUP_INTERVAL_SECONDS |
86400 |
How many seconds between backups. |
BACKUP_RETENTION_DAYS |
7 |
Number of days backups are kept. |
POSTGRES_VERSION |
16-alpine |
Version of the corresponding image. |
After changing it, apply the changes with docker compose up -d.
Useful commands
docker compose ps # view running containers
docker compose logs -f # view live logs
docker compose restart # restart the services
docker compose down # stop and remove the containers