Skip to content

CHORE: Create devcontainer for repo #147

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

saurabh500
Copy link

@saurabh500 saurabh500 commented Jul 19, 2025

Summary

This pull request introduces a comprehensive development environment setup for the MSSQL Python Driver project using a devcontainer. The changes include creating a Docker-based development environment, configuring VS Code for Python development, and adding scripts and files to streamline development workflows. Below are the most important changes grouped by theme:

Devcontainer Setup

  • Added a Dockerfile to define the development container, including Python 3.11, essential build tools, Microsoft ODBC Driver for SQL Server, and Python development tools (.devcontainer/Dockerfile).
  • Added a devcontainer.json file to configure the container, including VS Code settings, extensions, and features like GitHub CLI and Docker-in-Docker support (.devcontainer/devcontainer.json).

Post-Creation Script

  • Introduced a post-create.sh script to automate environment setup after container creation. This includes installing system dependencies, setting up a Python virtual environment, and configuring useful aliases (.devcontainer/post-create.sh).

Development Workflow Enhancements

  • Added a .dockerignore file to exclude unnecessary files and directories from the Docker build context, such as Python caches, build artifacts, and IDE-specific files (.dockerignore).

Impact:

With this, any developer can spin up a Github code space and work in a dev container, without needing all the steps for an environment setup.

Docker in docker plugin for dev container even allows SQL in docker to run in the devcontainer, for local testing

Fixes #146

@Copilot Copilot AI review requested due to automatic review settings July 19, 2025 06:41
@saurabh500
Copy link
Author

@microsoft-github-policy-service agree company="Microsoft"

Copy link
Contributor

@Copilot 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 establishes a comprehensive Docker-based development environment for the MSSQL Python Driver project using VS Code devcontainer technology. The setup enables developers to quickly spin up a consistent development environment with all necessary dependencies pre-configured.

  • Creates a complete devcontainer configuration with Python 3.10, Microsoft ODBC drivers, and development tools
  • Implements automated environment setup through post-creation scripts and Docker configuration
  • Adds Docker build optimization through comprehensive file exclusion patterns

Reviewed Changes

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

File Description
.dockerignore Excludes build artifacts, caches, and IDE files from Docker context
.devcontainer/Dockerfile Defines container with Python 3.10, MSSQL drivers, and development tools
.devcontainer/devcontainer.json Configures VS Code settings, extensions, and container features
.devcontainer/post-create.sh Automates post-container setup including dependencies and virtual environment

@saurabh500 saurabh500 changed the title Create devcontainer for repo CHORE: Create devcontainer for repo Jul 19, 2025
saurabh500 and others added 7 commits July 18, 2025 23:44
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@bewithgaurav bewithgaurav left a comment

Choose a reason for hiding this comment

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

some refactoring & optimization comments

pkg-config \
ninja-build \
# Additional tools
curl \
Copy link
Collaborator

Choose a reason for hiding this comment

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

the pre-installations are part of the post-create script as well.. just checking, can we maybe remove things from either here or post-create? there might be any redundancies which can add to build time

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. I will remove the redundant dependencies from Post-create.
The idea is to install the system utils like curl/wget in Dockerfile and keep python / project specific installation in post-create.sh

# Upgrade pip and install common Python development tools
RUN python -m pip install --upgrade pip setuptools wheel \
&& pip install \
black \
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have the minimum requirements available in requirements.txt - as seen in post-create script we're using pip install -r requirements.txt already. we can skip this here/there probably.

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
Copy link
Collaborator

Choose a reason for hiding this comment

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

same for odbc installation

*.cmake

# Build artifacts
*.so
Copy link
Collaborator

Choose a reason for hiding this comment

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

the .so files for linux odbc, .dylib files for macos odbc and .dll files for windows odbc are needed for build and execution. putting this in gitignore will skip them and remove that from build context. we might need to remove these files from dockerignore.

downloads/
eggs/
.eggs/
lib/
Copy link
Collaborator

Choose a reason for hiding this comment

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

safer to remove lib/ from here as well since lib dirs are present inside odbc directory

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.

Dev container spec for the repo
2 participants