Skip to content
Portfolio
← Back to blog

Deploying with Docker on a VPS

A step-by-step guide to self-hosting your Next.js application with Docker Compose on a VPS.

Deploying with Docker on a VPS

Self-hosting gives you full control over your infrastructure and costs.

#Docker Compose Setup

services:
  app:
    build: .
    ports:
      - "3000:3000"
  db:
    image: postgres:16-alpine

#Environment Variables

Never commit secrets. Use .env files locally and inject them at runtime in production.