Skip to content

feat: add devcontainer for VS Code and GitHub Codespaces#317

Merged
dlevy-msft-sql merged 3 commits into
microsoft:mainfrom
dlevy-msft-sql:devcontainer-clean
Apr 22, 2026
Merged

feat: add devcontainer for VS Code and GitHub Codespaces#317
dlevy-msft-sql merged 3 commits into
microsoft:mainfrom
dlevy-msft-sql:devcontainer-clean

Conversation

@dlevy-msft-sql
Copy link
Copy Markdown

@dlevy-msft-sql dlevy-msft-sql commented Feb 2, 2026

feat: Add devcontainer for VS Code and GitHub Codespaces

Summary

This PR adds a comprehensive development container that makes it easy for anyone to contribute to go-mssqldb. Just open the repo and start coding - SQL Server is ready!

What's Included

Component Details
Go 1.24 with gopls, delve debugger, staticcheck, golangci-lint
SQL Server 2025 Developer Edition with health checks
SQL Tools go-sqlcmd - uses this driver (dogfooding! 🐕)
VS Code Extensions Go, MSSQL, Docker, GitHub Copilot, GitLens
Features Docker-in-Docker, GitHub CLI
Testing Environment variables pre-configured for integration tests

How to Use

🖥️ VS Code

  1. Install the Dev Containers extension
  2. Open this repo and click "Reopen in Container"
  3. Run go test ./... — SQL Server is ready!

☁️ GitHub Codespaces

  1. Click the Code button → CodespacesCreate codespace
  2. Wait for the environment to start
  3. Run go test ./...

Helpful Aliases

Once inside the container, these aliases are available:

gtest        # Run all tests
gtest-unit   # Run unit tests only (no SQL Server required)
gtest-short  # Run short tests
gbuild       # Build all packages
gfmt         # Format code
gvet         # Run go vet
glint        # Run golangci-lint
sql          # Connect to SQL Server (go-sqlcmd)
test-db      # Test database connection

Discoverability

  • ✅ Added "Open in Dev Containers" badge to README
  • ✅ Added Development section to README with quick start guide
  • ✅ GitHub automatically shows Codespaces button when .devcontainer exists

Files Added

.devcontainer/
├── devcontainer.json      # Main VS Code configuration
├── docker-compose.yml     # Go + SQL Server 2025 containers
├── Dockerfile             # Go dev environment with tools
├── post-create.sh         # Setup script with aliases
├── README.md              # Detailed documentation
└── mssql/
    └── setup.sql          # Database initialization (creates GoDriverTest)

.dockerignore              # Build optimization

Screenshots

After opening in Dev Container, developers see:

=== go-mssqldb Development Container Setup ===

📦 Downloading Go dependencies...
🔨 Verifying build...
🔄 Verifying SQL Server connection using go-sqlcmd (uses this driver!)...
✅ SQL Server is ready!
📋 Running setup.sql...

=== Setup Complete! ===

🔧 go-sqlcmd is installed and uses THIS driver (dogfooding!)

🔗 SQL Server Connection:
   Server: localhost,1433
   User: sa
   Database: master

🧪 Environment variables are pre-configured for tests.
   Run 'go test ./...' to execute the full test suite.

Why This Matters

  • Lowers barrier to entry for new contributors
  • Consistent environment across all developers
  • No manual SQL Server setup required
  • Works on any OS with Docker support
  • Instant productivity - clone and code

@dlevy-msft-sql dlevy-msft-sql self-assigned this Feb 2, 2026
@dlevy-msft-sql dlevy-msft-sql added enhancement New feature or request Size: S Small issue (less than one week effort, less than 250 lines of code) in-review labels Feb 2, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive development container support for VS Code and GitHub Codespaces, making it easier for contributors to set up a complete development environment with Go and SQL Server pre-configured.

Changes:

  • Adds devcontainer configuration with Go 1.24, SQL Server, and pre-installed development tools
  • Includes automated setup scripts, helpful aliases, and pre-configured environment variables for integration tests
  • Updates README with a Development section explaining how to use the devcontainer
  • Adds .dockerignore for optimized container builds

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.devcontainer/devcontainer.json Main devcontainer configuration with VS Code extensions, settings, and environment variables
.devcontainer/docker-compose.yml Orchestrates Go development container with SQL Server 2025 sidecar
.devcontainer/Dockerfile Defines Go 1.24 development image with tools (go-sqlcmd, golangci-lint, delve, etc.)
.devcontainer/post-create.sh Post-creation setup script that downloads dependencies, waits for SQL Server, and creates helpful aliases
.devcontainer/mssql/setup.sql SQL initialization script that creates test database and sample tables
.devcontainer/README.md Comprehensive documentation for using and customizing the devcontainer
.dockerignore Excludes unnecessary files from Docker build context
README.md Adds Development section with quick start guide for devcontainers

Comment thread .devcontainer/Dockerfile Outdated
Comment thread .devcontainer/post-create.sh Outdated
Comment thread .devcontainer/post-create.sh Outdated
Comment thread .devcontainer/Dockerfile Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 13 comments.

Comment thread .devcontainer/docker-compose.yml Outdated
Comment thread .devcontainer/README.md Outdated
Comment thread .devcontainer/post-create.sh Outdated
Comment thread .devcontainer/docker-compose.yml Outdated
Comment thread .devcontainer/post-create.sh Outdated
Comment thread .devcontainer/post-create.sh Outdated
Comment thread .dockerignore Outdated
Comment thread .devcontainer/devcontainer.json
Comment thread README.md Outdated
Comment thread .devcontainer/devcontainer.json Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread .devcontainer/Dockerfile Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.

Comment thread .devcontainer/mssql/setup.sql Outdated
Comment thread README.md
Comment thread .devcontainer/docker-compose.yml Outdated
Comment thread .devcontainer/post-create.sh
Comment thread .devcontainer/post-create.sh
Comment thread .dockerignore
Comment thread README.md Outdated
Comment thread .devcontainer/devcontainer.json
Comment thread .devcontainer/docker-compose.yml
Comment thread .github/workflows/pr-validation.yml Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread .devcontainer/README.md
Comment thread .devcontainer/README.md
Comment thread .devcontainer/README.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

dlevy-msft-sql added a commit to dlevy-msft-sql/go-sqlcmd that referenced this pull request Feb 2, 2026
Dockerfile:
- Fix image tag format: 1.24-bookworm (not 1-1.24-bookworm)

docker-compose.yml:
- Add both SA_PASSWORD and MSSQL_SA_PASSWORD for CI compatibility
  (different SQL Server images use different env vars)

post-create.sh:
- Add dynamic workspace detection with robust fallback
- Handles different clone names (go-sqlcmd, fork names, etc.)

setup.sql:
- Add TRY/CATCH error handling for contained database operations
- Prevents script failure on unsupported SQL Server configurations

.dockerignore:
- Add .devcontainer/ to reduce build context size

Reference: microsoft/go-mssqldb#317
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread .devcontainer/README.md Outdated
@dlevy-msft-sql dlevy-msft-sql force-pushed the devcontainer-clean branch 2 times, most recently from 71be9dc to 72cdb74 Compare February 5, 2026 21:19
@dlevy-msft-sql dlevy-msft-sql added this to the v1.10.0 milestone Apr 17, 2026
@dlevy-msft-sql dlevy-msft-sql force-pushed the devcontainer-clean branch 2 times, most recently from 334536f to c3aa7fe Compare April 20, 2026 14:57
@dlevy-msft-sql dlevy-msft-sql removed enhancement New feature or request Priority: 1 High priority/impact Size: M Medium issue (two-three weeks effort, less than 1000 lines of code) labels Apr 20, 2026
@dlevy-msft-sql dlevy-msft-sql force-pushed the devcontainer-clean branch 3 times, most recently from 74d9f03 to fcec691 Compare April 21, 2026 15:59
- Add .devcontainer with Go 1.25, SQL Server 2025 sidecar, and pre-configured
  VS Code extensions (Go, MSSQL, Docker, Copilot, GitLens)
  legacy ODBC sqlcmd available via sql-odbc alias or full path
- Add .dockerignore, post-create setup script, and mssql/setup.sql
- Add helpful shell aliases: gtest, gtest-unit, sql, sql-odbc, etc.
- Pre-configure environment variables for integration tests (HOST, SQLUSER,
  SQLPASSWORD, DATABASE, SQLSERVER_DSN)
- Add devcontainer README with quick start, troubleshooting, and customization
- Update main README with devcontainer quick start section
- Fix namedpipe build for non-Windows platforms; add ARM64 npipe support
- Fix minor test and type issues for broader compatibility
- Replace bash aliases (sql, sql-odbc, test-db) with executable scripts
  in ~/bin/ so they work in any terminal type, not just interactive bash
- Set up a go-sqlcmd context (devcontainer) during post-create so sqlcmd
  auto-connects to the local SQL Server without -S/-U/-P flags
- Make sql a plain pass-through to go-sqlcmd so all subcommands work
  (sql query, sql create, sql --version, etc.)
- Update devcontainer README to reflect scripts vs aliases and
  context-based connection
@dlevy-msft-sql dlevy-msft-sql force-pushed the devcontainer-clean branch 10 times, most recently from 1ce367d to 7ea9a79 Compare April 22, 2026 03:29
Hardcode the development SA password in mssql.connections and
go.testEnvVars. The MSSQL extension strips passwords set via
variable substitution (${env:}, ${containerEnv:}), so the
password must be a literal value in settings.
@dlevy-msft-sql dlevy-msft-sql merged commit b55beeb into microsoft:main Apr 22, 2026
7 checks passed
@dlevy-msft-sql dlevy-msft-sql deleted the devcontainer-clean branch April 22, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants