This project includes a Docker Compose setup for local development with PostgreSQL and Next.js.
-
Start all services (PostgreSQL + Next.js):
docker-compose up -d # or pnpm docker:up -
Set up the database schema:
# Connect to the database container and run Prisma migrations docker-compose exec postgres psql -U postgres -d kopy -c "CREATE TABLE IF NOT EXISTS pastes (id TEXT PRIMARY KEY, encrypted_content TEXT NOT NULL, sender_name TEXT, password_hash TEXT, content_type TEXT DEFAULT 'text', created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), expires_at TIMESTAMP WITH TIME ZONE NOT NULL);" # Or use Prisma to set up the database docker-compose exec nextjs pnpm prisma migrate dev
-
Access the application:
- Next.js app: http://localhost:3000
- PostgreSQL: localhost:5432
docker-compose up -dorpnpm docker:up- Start all servicesdocker-compose downorpnpm docker:down- Stop all servicesdocker-compose logs -f nextjs- View Next.js logsdocker-compose logs -f postgresorpnpm docker:logs- View database logsdocker-compose down -vorpnpm docker:reset- Reset everything (removes all data)
- Development server with hot reload
- Code is mounted as volume for live changes
- Automatically connects to PostgreSQL container
- Host: localhost (from host) or
postgres(from Next.js container) - Port: 5432
- User: postgres
- Password: postgres
- Database: kopy
From your host machine:
psql -h localhost -U postgres -d kopy
# Password: postgresFrom within Docker:
docker-compose exec postgres psql -U postgres -d kopyOr use Prisma Studio (from host):
docker-compose exec nextjs pnpm prisma:studio-
Start services:
docker-compose up -d
-
Make code changes - They'll be reflected immediately (hot reload)
-
View logs:
docker-compose logs -f nextjs
-
Stop services:
docker-compose down
- The database data persists in a Docker volume (
postgres_data) - Code changes are reflected immediately due to volume mounting
- The Next.js container waits for PostgreSQL to be healthy before starting
- Both services are on the same Docker network for easy communication