-
Notifications
You must be signed in to change notification settings - Fork 82
feat: add devcontainer for VS Code and GitHub Codespaces #692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add comprehensive development container setup for easier onboarding: - Go 1.24 with gopls, delve, staticcheck, golangci-lint - SQL Server 2025 (Developer Edition) as sidecar container - Docker-in-Docker for container operations - GitHub CLI for PR management - Pre-configured VS Code extensions (Go, MSSQL, Docker, Copilot, GitLens) - Environment variables pre-set for tests (SQLCMDSERVER, etc.) - Helpful aliases (gtest, gbuild, sql, etc.) - Locally built sqlcmd added to PATH automatically - Detailed documentation in .devcontainer/README.md Files added: - .devcontainer/Dockerfile - .devcontainer/docker-compose.yml - .devcontainer/devcontainer.json - .devcontainer/post-create.sh - .devcontainer/mssql/setup.sql - .devcontainer/README.md - .dockerignore Also updates main README.md with: - 'Open in Dev Containers' badge - Development section with quick start instructions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a VS Code / GitHub Codespaces devcontainer setup to make onboarding and running integration tests against a local SQL Server container easier and more consistent.
Changes:
- Introduces a full
.devcontainer/configuration (Dockerfile, docker-compose, devcontainer.json, post-create provisioning, and SQL bootstrap script). - Documents devcontainer usage in both the root README and a dedicated
.devcontainer/README.md. - Adds a root
.dockerignoreto reduce Docker build context noise.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds “Open in Dev Containers” badge and a Development section with quickstart/manual setup. |
| .dockerignore | Defines ignore rules for Docker builds from the repo root. |
| .devcontainer/Dockerfile | Dev image with Go toolchain + common Go dev tools and dependencies. |
| .devcontainer/docker-compose.yml | Orchestrates devcontainer + SQL Server sidecar with healthcheck. |
| .devcontainer/devcontainer.json | VS Code devcontainer configuration, extensions, forwarded ports, env vars, post-create command. |
| .devcontainer/post-create.sh | Post-create setup: downloads deps, builds sqlcmd, validates build, waits for DB, runs setup.sql, adds aliases. |
| .devcontainer/mssql/setup.sql | Creates a SqlCmdTest database and sample objects for quick testing. |
| .devcontainer/README.md | Detailed documentation for devcontainer usage, troubleshooting, and customization. |
- Fix grammar: 'is using' -> 'is to use' in README.md - Remove unused WORKSPACE_FOLDER variable from post-create.sh - Make bashrc alias updates idempotent (remove existing block first) - Only run setup.sql if SQL Server connection succeeded - Don't print SA password to terminal (reference env var instead) - Use SA_PASSWORD in addition to MSSQL_SA_PASSWORD for CI consistency - Use environment variable reference in healthcheck - Pin Go tools to specific versions for reproducibility: - gopls@v0.18.1, dlv@v1.24.1, staticcheck@v0.6.1, gotext@v0.22.0 - Improve golangci-lint install security by using versioned tag URL - Fix docs to match actual behavior (only setup.sql is executed) - Install legacy ODBC sqlcmd (mssql-tools18) for compatibility testing - Add sql-legacy alias to easily compare behavior between versions - Document connecting from host tools (Azure Data Studio, SSMS)
There was a problem hiding this 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 3 comments.
Download pre-built binary directly from GitHub releases instead of piping install script to sh. This addresses supply chain security concerns about executing remote scripts. The image tag 1-1.24-bookworm is valid - the first '1' is the devcontainer definition version, second '1.24' is the Go version. The markdown tables render correctly (Copilot false positive).
There was a problem hiding this 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 8 comments.
Security improvements: - Add SHA256 checksum verification for golangci-lint v1.64.8 (b6270687afb143d019f387c791cd2a6f1cb383be9b3124d241ca11bd3ce2e54e) Password handling: - Consolidate to single env var (MSSQL_SA_PASSWORD only) - Use MSSQL_SA_PASSWORD in healthcheck for consistency - Set savePassword: false in mssql.connections (prompts on first use) Tool management: - Disable go.toolsManagement.autoUpdate to preserve pinned versions Documentation: - Clarify CI comparison (same env var names, not identical config) - Update password change instructions to be clearer
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
There was a problem hiding this 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 5 comments.
Addresses review #3737525469: 1. README badge: Changed from hardcoded repo URL to link to devcontainer docs, so forks don't redirect to upstream repo 2. Aliases: Use dedicated ~/.bash_aliases file instead of modifying ~/.bashrc with sed, avoiding potential accidental content deletion 3. Volume mount: Fixed from ../.. to ../workspaces/go-sqlcmd to only mount the repo root, not parent directories that could expose secrets 4. MSSQL connection: Removed hardcoded password from mssql.connections config. Users will be prompted to enter password on first connect. 5. Password handling: Added environment variable substitution support: - docker-compose.yml: Uses SQLCMDPASSWORD env var with default - devcontainer.json: Uses localEnv with fallback to default - Added comments explaining this is dev-only, not production secrets - Updated README to clarify password is available via env var
Update README to mention that both SA_PASSWORD and MSSQL_SA_PASSWORD must be updated in docker-compose.yml when changing the password, matching the fix applied to go-mssqldb PR microsoft#317.
There was a problem hiding this 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 8 comments.
Addresses review #3737557661: 1. Password note wording: Fixed misleading claim that password is not stored in committed files. Now clarifies it's a dev-only default checked into repo for convenience. 2. MSSQL profile name: Updated docs to match devcontainer.json profile name 'sqlcmd-container (use SQLCMDPASSWORD env var)' 3. workspaceFolder mismatch: Changed from variable-based path to fixed '/workspaces/go-sqlcmd' to match docker-compose.yml mount 4. go.testEnvVars password: Now uses env:SQLCMDPASSWORD instead of hardcoded value, so VS Code tests use same password as container 5. ARM64 architecture support: Added architecture detection for golangci-lint with separate SHA256 checksums for amd64/arm64 6. Alias management: Now uses ~/.bash_aliases.d/ directory instead of overwriting ~/.bash_aliases, preserving user's custom aliases
There was a problem hiding this 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 3 comments.
There was a problem hiding this 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 3 comments.
Summary
This PR adds a comprehensive development container setup for easier onboarding and consistent development environments.
What's Included
Development Environment
SQL Server 2025
SqlCmdTest) created on startupVS Code Extensions (pre-installed)
Features
sqlcmd create mssql, etc.)Environment Variables
Pre-configured so tests run immediately:
SQLCMDSERVER=localhostSQLCMDUSER=saSQLCMDPASSWORD=SqlCmd@2025!SQLCMDDATABASE=masterHelpful Aliases
gtestgbuildginstallglintsqltest-dbFiles Added
.devcontainer/Dockerfile- Go development container.devcontainer/docker-compose.yml- Container orchestration.devcontainer/devcontainer.json- VS Code configuration.devcontainer/post-create.sh- Setup script with aliases.devcontainer/mssql/setup.sql- Test database setup.devcontainer/README.md- Detailed documentation.dockerignore- Exclude unnecessary files from buildREADME Updates
Usage
VS Code
GitHub Codespaces
gtestto verify everything worksRelation to go-mssqldb
This follows the same pattern as go-mssqldb PR #317, making it easy for contributors to work on both projects with consistent environments.