Skip to content

VS Code DevContainer

The DevContainer gives you a fully isolated, reproducible development environment. Every team member gets the same OS, .NET version, extensions, and tooling — no "works on my machine" problems.

Requires: Docker Desktop + VS Code with the Dev Containers extension (ms-vscode-remote.remote-containers).


Start

  1. Open the project folder in VS Code
  2. When prompted: click "Reopen in Container" (or Command Palette → Dev Containers: Reopen in Container)
  3. First build takes ~2–3 minutes (cached on subsequent opens)
  4. The post-create.sh script runs automatically on first open

What post-create.sh does automatically

# Installs dotnet-ef 6.0 tool
dotnet tool install --global dotnet-ef --version "6.0.*"

# Restores all NuGet packages
dotnet restore

# Runs both EF Core migrations
dotnet ef database update --context CoreDbContext ...
dotnet ef database update --context MeeshoDbContext ...

# Seeds API_Base_URL → mock-api:5000
psql -c "INSERT INTO meesho.customer_sorter_profile ..."

# Verifies mock-api is healthy
curl -sf http://mock-api:5000/health

After this completes, the workspace is fully ready.


Run the backend

Press F5 (uses .vscode/launch.json) — builds and starts the backend at http://localhost:5269.

Or in the terminal:

make backend    # foreground
make backend-bg # background


Ports forwarded to your host

Container port Host port Service
5269 5269 ASP.NET Core backend
5000 5000 Mock Partner API
5432 5432 PostgreSQL

Access all services from your local browser exactly as in local setup.


Sidecar services

The DevContainer starts two sidecars alongside your dev container:

  • postgres (postgres:16-alpine) — same image as Docker Compose
  • mock-api (Python Flask) — reachable as http://mock-api:5000 from inside the container

Inside the container, the backend uses Server=postgres (service name) in the connection string, injected via .devcontainer/docker-compose.devcontainer.yml.


Pre-installed VS Code extensions

The DevContainer installs these automatically:

Extension Purpose
ms-dotnettools.csharp C# language support, IntelliSense, debugging
ms-dotnettools.csdevkit C# Dev Kit — solution explorer, test runner
mtxr.sqltools + PostgreSQL driver SQL editor connected to the local DB
humao.rest-client Test API endpoints from .http files

Named volumes (persist across container rebuilds)

Volume Contents
nuget-cache NuGet package cache — restore is fast after first run
dotnet-tools dotnet-ef and other global tools

These volumes survive docker compose down — you won't re-download packages on every rebuild.


Stopping the DevContainer

Command Palette → "Dev Containers: Reopen Folder Locally" returns you to native VS Code. The container and its volumes continue running in the background until you run docker compose down.