This directory contains the configuration for a complete, reproducible development environment using VS Code Dev Containers.
- Node.js 20 - Latest LTS version
- PostgreSQL 16 - Database server
- Prisma - Database toolkit
- VS Code Extensions - Pre-configured for optimal DX
- Automatic Setup - Dependencies installed on first run
- VS Code with the Dev Containers extension
- Docker Desktop installed and running
-
Open the project in VS Code
code /home/hayep/code/transparency
-
Reopen in Container
- VS Code will detect the
.devcontainerconfiguration - Click "Reopen in Container" when prompted
- OR: Press
F1→ "Dev Containers: Reopen in Container"
- VS Code will detect the
-
Wait for setup to complete (first time only, ~5-10 minutes)
- Docker images will be downloaded
- Dependencies will be installed
- Database will be initialized
-
Start developing!
npm run dev
# Clone and open in container in one command
code --folder-uri vscode-remote://dev-container+$(echo /home/hayep/code/transparency | xxd -p | tr -d '\n')/workspace/transparencyIf you prefer not to use VS Code Dev Containers:
cd /home/hayep/code/transparency/.devcontainer
docker-compose up -d
docker-compose exec app bash- ✅ Creates Next.js project (if not exists)
- ✅ Installs all npm dependencies
- ✅ Initializes Shadcn/ui
- ✅ Sets up Prisma with database schema
- ✅ Generates Prisma Client
- ✅ Creates
.env.localconfiguration file - ✅ Adds helpful npm scripts
- ✅ Waits for PostgreSQL to be ready
- ✅ Initializes database schema (if empty)
- ✅ Shows helpful commands
The following ports are automatically forwarded:
- 3000 - Next.js development server
- 5432 - PostgreSQL database
- 5555 - Prisma Studio (database GUI)
The container automatically sets:
DATABASE_URL- PostgreSQL connection stringNODE_ENV=development
Additional environment variables (API keys) need to be added manually to .env.local:
- Clerk (Authentication) - Get from clerk.com
- Stripe (Payments) - Get from stripe.com
The following extensions are automatically installed:
- ESLint - Code linting
- Prettier - Code formatting
- Tailwind CSS IntelliSense - Tailwind autocomplete
- TypeScript Next - Enhanced TypeScript support
- ES7+ React Snippets - React code snippets
- Prisma - Prisma schema support
- PostgreSQL - Database management
- GitLens - Enhanced Git integration
- Pretty TypeScript Errors - Readable error messages
- Import Cost - Show package sizes
- Path Intellisense - Path autocomplete
- Auto Rename Tag - Sync HTML tag renaming
- Markdown All in One - Markdown editing
Once inside the container:
# Development
npm run dev # Start Next.js dev server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
# Database
npm run db:push # Push schema to database
npm run db:seed # Seed database with sample data
npm run db:studio # Open Prisma Studio
npm run db:reset # Reset database (WARNING: deletes all data)
# Stripe
npm run stripe:listen # Listen for Stripe webhooks locally
# Prisma Commands
npx prisma generate # Generate Prisma Client
npx prisma studio # Open Prisma Studio
npx prisma migrate dev # Create new migration
npx prisma db pull # Pull schema from database
npx prisma db push # Push schema to database# Connect to PostgreSQL
psql postgresql://transparency:devpassword@localhost:5432/transparency_dev
# Or use Prisma Studio (GUI)
npm run db:studioUse any PostgreSQL client with:
- Host:
localhost - Port:
5432 - User:
transparency - Password:
devpassword - Database:
transparency_dev
-
Check Docker is running
docker ps
-
Rebuild container
- Press
F1→ "Dev Containers: Rebuild Container"
- Press
-
Check Docker logs
docker-compose -f .devcontainer/docker-compose.yml logs
-
Check PostgreSQL is running
docker-compose -f .devcontainer/docker-compose.yml ps
-
Check database logs
docker-compose -f .devcontainer/docker-compose.yml logs db
-
Restart database
docker-compose -f .devcontainer/docker-compose.yml restart db
If ports 3000, 5432, or 5555 are already in use on your host:
- Stop the conflicting service, OR
- Edit
.devcontainer/docker-compose.ymlto use different ports
The first build can take 5-10 minutes depending on:
- Internet connection speed
- Docker image download
- npm package installation
Subsequent starts are much faster (~10-30 seconds).
- Hard reload browser:
Cmd+Shift+R(Mac) orCtrl+Shift+R(Windows/Linux) - Restart Next.js dev server: Stop with
Ctrl+C, thennpm run dev - Rebuild container:
F1→ "Dev Containers: Rebuild Container"
Edit .devcontainer/devcontainer.json:
{
"customizations": {
"vscode": {
"extensions": [
"existing.extensions",
"your.new-extension"
]
}
}
}Then rebuild the container.
Edit .devcontainer/devcontainer.json:
{
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "18" // or "20", "21", etc.
}
}
}Edit .devcontainer/Dockerfile:
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
your-package-here \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*- Database data is persisted in a Docker volume (
postgres-data) - Code changes are automatically synced between container and host
- node_modules are stored in the container for faster performance
To completely reset:
# Remove all containers and volumes
docker-compose -f .devcontainer/docker-compose.yml down -v
# Rebuild from scratch
# In VS Code: F1 → "Dev Containers: Rebuild Container"Each collaborator only needs:
- Clone the repository
- Open in VS Code
- Click "Reopen in Container"
Everything else is automatic! No need to:
- Install Node.js
- Install PostgreSQL
- Configure environment
- Install VS Code extensions
- Set up linting/formatting
The devcontainer ensures everyone has the exact same environment.
Docker on Mac/Windows uses a VM, which can be slower. Tips:
-
Allocate more resources to Docker
- Docker Desktop → Settings → Resources
- Increase CPUs to 4+ and Memory to 8GB+
-
Use cached volumes (already configured)
volumes: - ../..:/workspaces:cached
-
node_modules in container (already configured)
- Significantly faster builds and installs
Docker on Linux runs natively, so performance is excellent by default.
This devcontainer configuration can be used in:
- GitHub Codespaces - Cloud-based development
- GitLab - With GitLab Dev Containers
- CI Pipelines - Consistent test environment
- Default database password is
devpassword - This is for local development only
- Never use these credentials in production
- Add actual secrets to
.env.local(git-ignored)
- Issues with Dev Containers: VS Code Dev Containers Documentation
- Docker Issues: Docker Documentation
- Project Setup: See QUICKSTART.md
- Contributing: See CONTRIBUTING.md
Once your container is running:
- ✅ Add API keys to
.env.local - ✅ Run
npm run db:pushto create database schema - ✅ Run
npm run db:seedto add sample data - ✅ Run
npm run devto start developing - ✅ Visit http://localhost:3000
Happy coding! 🚀