README > NextJS Deploy > Quick Deploy
Deploy a new NextjsDeploy stack on an existing Dokploy infrastructure. Assumes VPS, Docker, Dokploy, Traefik and Tailscale are already set up โ see Quick Install if not.
- Dokploy instance running on VPS
- Domain name with wildcard DNS configured
- Traefik with DNS challenge enabled
- Repository on GitHub (public or with SSH key)
- Dokploy > Projects > Create Project (e.g.,
NextjsDeploy) - Inside the project, click the environment dropdown (next to the project name) > Create Environment (e.g.,
production,preview)
In the environment:
- Click Create Service (top right) > Database > select PostgreSQL
- Fill in the modal:
| Field | Value |
|---|---|
| Name | production-db (or preview-db) |
| Database Name | your database name (e.g., nextjsdeploy-db) |
| Database User | postgres (default) |
| Database Password | generate a strong password |
| Docker image | postgres:16 |
- Click Create
- In the service General tab, note the Internal Host (e.g.,
production-db-xxxxx) โ needed for env vars
Note
The database is standalone (not in the compose file). This allows independent backups via Dokploy/Cloudflare R2.
In the same environment:
- Create Service > Compose
- Name:
production(orpreview) - Provider tab:
- Select
GitorGithub - Repository URL: your repo
- Branch:
main(production) ortest(preview) - Compose file path:
./compose.dokploy.yml - Click Save
- Select
- Locally, generate env files:
make setup-env-
Copy the content of
env/.env.production(orenv/.env.preview) -
Paste in Dokploy > your compose service > Environment tab
-
Adjust these values:
| Variable | Action |
|---|---|
POSTGRES_HOST |
Set to database Internal Host from step 2 |
POSTGRES_PASSWORD |
Set to database password from step 2 |
POSTGRES_DB |
Set to database name from step 2 |
VPS_NEXTJS_DOMAIN |
Your production domain (e.g., your-domain.com) |
VPS_PRISMA_STUDIO_DOMAIN |
Prisma Studio domain (e.g., prisma-studio.your-domain.com) |
BETTER_AUTH_SECRET |
Generate with openssl rand -base64 32 |
PRISMA_STUDIO_AUTH |
Generate with htpasswd -nbB admin your-password (double the $) |
TURNSTILE_SECRET_KEY |
From Cloudflare Turnstile dashboard |
- Click Save
See Environment Variables and Dokploy Env Setup for details.
Add domain records pointing to your VPS IP:
| Type | Name | Value |
|---|---|---|
| A | your-domain.com |
VPS public IP |
| A | prisma-studio.your-domain.com |
Tailscale IP |
- Click Deploy in Dokploy, or push to the configured branch
- The compose starts: Prisma migrations run automatically, then fixtures, then the server
7. Configure Backups โ detailed guide
- Go to your database service > Backups tab > Create Backup
- Fill in:
| Field | Value |
|---|---|
| Destination | Your S3/R2 destination |
| Database | Database name from step 2 |
| Schedule | 0 0 * * 0 (Sundays at midnight) |
| Keep latest | 3 |
| Enabled | Yes |
8. Scheduled Tasks โ detailed guide
- Go to your compose service > Schedules tab > Add Schedule
- Fill in:
| Field | Value |
|---|---|
| Service Name | nextjs |
| Task Name | Cleanup Activity History |
| Schedule | 0 3 * * 0 (Sundays at 3:00 AM) |
| Shell Type | Bash |
| Command | bun run cron:cleanup-activities |
| Enabled | On |
- App accessible at
https://your-domain.com - Prisma Studio accessible at
https://prisma-studio.your-domain.com(via VPN) - Database backup runs successfully (manual test)
- Scheduled task appears in Schedules tab
Create Project โ Create DB โ Create Compose โ Env Vars โ DNS โ Deploy โ Backups โ CRON
README > NextJS Deploy > Quick Deploy