-
Notifications
You must be signed in to change notification settings - Fork 36
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a93e2ff
Dev Container setup
2383b7b
REFACTOR: Simplify post-create script by removing redundant activatio…
1f50584
Update .dockerignore
saurabh500 6f79cd2
Update .devcontainer/Dockerfile
saurabh500 1e4c8cc
Update .dockerignore
saurabh500 92b1c1f
Update .dockerignore
saurabh500 78d129f
Update .dockerignore
saurabh500 b5e940a
Update .devcontainer/devcontainer.json
saurabh500 306ae47
Update .devcontainer/devcontainer.json
saurabh500 386b81b
Apply suggestions from code review
saurabh500 9dd343b
Merge branch 'main' into devcontainer
bewithgaurav 19f635e
Merge branch 'main' into devcontainer
bewithgaurav 6427ac6
Merge branch 'main' into devcontainer
saurabh500 f534e5c
CHORE: Upgrade to Python 3.14, fix duplicate ODBC, modernize settings
dlevy-msft-sql 4ad071d
Merge branch 'main' into devcontainer
dlevy-msft-sql 651f576
Merge branch 'main' into devcontainer
bewithgaurav 37ecdff
fix(devcontainer): add unixodbc-dev, move Python setup to post-create…
bewithgaurav 33f3611
fix(devcontainer): improve shell aliases and connection string setup
bewithgaurav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Use Python 3.14 with Debian Bookworm as the base image | ||
| FROM mcr.microsoft.com/devcontainers/python:3.14-bookworm | ||
|
|
||
| # Set environment variables | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV PYTHONPATH=/workspaces/mssql-python | ||
| ENV CMAKE_BUILD_TYPE=Debug | ||
|
|
||
| # Install system dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| # Build tools | ||
| build-essential \ | ||
| cmake \ | ||
| pkg-config \ | ||
| ninja-build \ | ||
| # Additional tools | ||
| curl \ | ||
| wget \ | ||
| git \ | ||
| vim \ | ||
| nano \ | ||
| htop \ | ||
| tree \ | ||
| jq \ | ||
| # Clean up | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install Microsoft ODBC Driver for SQL Server | ||
| RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \ | ||
| && curl https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list \ | ||
| && sed -i 's/^deb /deb [signed-by=\/usr\/share\/keyrings\/microsoft-prod.gpg] /' /etc/apt/sources.list.d/mssql-release.list \ | ||
| && apt-get update \ | ||
| && ACCEPT_EULA=Y apt-get install -y msodbcsql18 \ | ||
bewithgaurav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| && ACCEPT_EULA=Y apt-get install -y mssql-tools18 \ | ||
| && apt-get clean \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Add mssql-tools to PATH | ||
| ENV PATH="$PATH:/opt/mssql-tools18/bin" | ||
|
|
||
| # Upgrade pip and install common Python development tools | ||
| RUN python -m pip install --upgrade pip setuptools wheel \ | ||
| && pip install \ | ||
| black \ | ||
bewithgaurav marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| flake8 \ | ||
| mypy \ | ||
| isort \ | ||
| pre-commit \ | ||
| twine \ | ||
| build \ | ||
| wheel \ | ||
| "pybind11[global]" \ | ||
| pytest-xdist \ | ||
| pytest-mock \ | ||
| "coverage[toml]" | ||
|
|
||
| # Set the default user to vscode (created by the base image) | ||
| USER vscode | ||
|
|
||
| # Set the working directory | ||
| WORKDIR /workspaces/mssql-python | ||
|
|
||
| # Add helpful aliases to .bashrc | ||
| RUN echo 'alias ll="ls -alF"' >> ~/.bashrc \ | ||
| && echo 'alias la="ls -A"' >> ~/.bashrc \ | ||
| && echo 'alias l="ls -CF"' >> ~/.bashrc | ||
|
|
||
| # Default command | ||
| CMD ["/bin/bash"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "name": "MSSQL Python Driver", | ||
| "build": { | ||
| "dockerfile": "Dockerfile", | ||
| "context": "." | ||
| }, | ||
| // Configure tool-specific properties. | ||
| "customizations": { | ||
| // Configure properties specific to VS Code. | ||
| "vscode": { | ||
| // Set *default* container specific settings.json values on container create. | ||
| "settings": { | ||
| "python.defaultInterpreterPath": "/workspaces/mssql-python/.venv/bin/python", | ||
| "python.terminal.activateEnvironment": true, | ||
| "editor.formatOnSave": true, | ||
| "[python]": { | ||
| "editor.defaultFormatter": "ms-python.black-formatter" | ||
| }, | ||
| "cmake.configureOnOpen": false | ||
| }, | ||
| // Add the IDs of extensions you want installed when the container is created. | ||
| "extensions": [ | ||
| "ms-python.python", | ||
| "ms-python.vscode-pylance", | ||
| "ms-python.pylint", | ||
| "ms-toolsai.jupyter", | ||
| "ms-vscode.cmake-tools", | ||
| "ms-vscode.cpptools", | ||
| "ms-vscode.cpptools-extension-pack", | ||
| "github.copilot", | ||
| "github.copilot-chat", | ||
| "ms-vscode.test-adapter-converter", | ||
| "littlefoxteam.vscode-python-test-adapter", | ||
| "ms-azuretools.vscode-docker", | ||
| "ms-mssql.mssql" | ||
| ] | ||
| } | ||
| }, | ||
| // Features to add to the dev container. More info: https://containers.dev/features. | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/git:1": {}, | ||
| "ghcr.io/devcontainers/features/github-cli:1": {}, | ||
| "ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
| "ghcr.io/devcontainers/features/common-utils:2": { | ||
| "installZsh": true, | ||
| "configureZshAsDefaultShell": true, | ||
| "installOhMyZsh": true, | ||
| "upgradePackages": true, | ||
| "username": "vscode", | ||
| "userUid": "automatic", | ||
| "userGid": "automatic" | ||
| } | ||
| }, | ||
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
| "forwardPorts": [], | ||
| // Use 'postCreateCommand' to run commands after the container is created. | ||
| "postCreateCommand": "bash .devcontainer/post-create.sh", | ||
| // Use 'postStartCommand' to run commands after the container starts. | ||
| "postStartCommand": "", | ||
| // Configure tool-specific properties. | ||
| "remoteUser": "vscode", | ||
| // Set container environment variables | ||
| "containerEnv": { | ||
| "PYTHONPATH": "/workspaces/mssql-python", | ||
| "CMAKE_BUILD_TYPE": "Debug" | ||
| }, | ||
| // Mount the project directory | ||
| "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/mssql-python,type=bind,consistency=cached", | ||
| "workspaceFolder": "/workspaces/mssql-python" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Post-create script for MSSQL Python Driver devcontainer | ||
| set -e | ||
|
|
||
| echo "🚀 Setting up MSSQL Python Driver development environment..." | ||
|
|
||
| # Update package lists | ||
| echo "📦 Updating package lists..." | ||
| sudo apt-get update | ||
|
|
||
| # Install system dependencies required for the project | ||
| echo "🔧 Installing system dependencies..." | ||
| sudo apt-get install -y \ | ||
| python3 \ | ||
| python3-pip \ | ||
| python3-venv \ | ||
| python3-full \ | ||
| cmake \ | ||
| curl \ | ||
| wget \ | ||
| gnupg \ | ||
| software-properties-common \ | ||
| build-essential \ | ||
| python3-dev \ | ||
| pybind11-dev | ||
|
|
||
| export TZ=UTC | ||
| ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | ||
|
|
||
| # Note: ODBC Driver is already installed in the Dockerfile | ||
|
|
||
| # Create a Python virtual environment | ||
| echo "🐍 Creating Python virtual environment..." | ||
| python3 -m venv /workspaces/mssql-python/.venv | ||
| source /workspaces/mssql-python/.venv/bin/activate | ||
|
|
||
| python -m pip install --upgrade pip | ||
|
|
||
| # Make the virtual environment globally available | ||
| echo 'source /workspaces/mssql-python/.venv/bin/activate' >> ~/.bashrc | ||
|
|
||
| # Install project dependencies | ||
| echo "📚 Installing project dependencies..." | ||
| pip install -r requirements.txt | ||
|
|
||
| # Build the native extension | ||
| echo "🔨 Building native extension..." | ||
| cd /workspaces/mssql-python/mssql_python/pybind | ||
| ./build.sh | ||
| cd /workspaces/mssql-python | ||
|
|
||
| # Create useful aliases | ||
| echo "⚡ Setting up aliases..." | ||
| cat >> ~/.bashrc << 'EOF' | ||
|
|
||
| # MSSQL Python Driver aliases | ||
| alias ll='ls -alF' | ||
| alias la='ls -A' | ||
| alias l='ls -CF' | ||
| alias clean='find . -type f -name "*.pyc" -delete && find . -type d -name "__pycache__" -delete' | ||
|
|
||
| EOF | ||
|
|
||
| # Set up git configuration (if not already configured) | ||
| echo "🔧 Configuring git..." | ||
| if [ -z "$(git config --global user.name)" ]; then | ||
| echo "Git user name not set. You may want to configure it with:" | ||
| echo " git config --global user.name 'Your Name'" | ||
| fi | ||
| if [ -z "$(git config --global user.email)" ]; then | ||
| echo "Git user email not set. You may want to configure it with:" | ||
| echo " git config --global user.email '[email protected]'" | ||
| fi | ||
|
|
||
| # Display information about the environment | ||
| echo "" | ||
| echo "✅ Development environment setup complete!" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # Git | ||
| .git | ||
| .gitignore | ||
| .gitattributes | ||
|
|
||
| # Python | ||
| __pycache__ | ||
| *.pyc | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
| env | ||
| pip-log.txt | ||
| pip-delete-this-directory.txt | ||
| .tox | ||
| .coverage | ||
| .coverage.* | ||
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| *.cover | ||
| *.log | ||
| .mypy_cache | ||
| .pytest_cache | ||
| .hypothesis | ||
|
|
||
| # Distribution / packaging | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
bewithgaurav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
|
|
||
| # PyInstaller | ||
| *.manifest | ||
| *.spec | ||
|
|
||
| # Installer logs | ||
| pip-log.txt | ||
saurabh500 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Unit test / coverage reports | ||
| htmlcov/ | ||
| .coverage | ||
saurabh500 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .coverage.* | ||
saurabh500 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| nosetests.xml | ||
| coverage.xml | ||
| *.cover | ||
| .hypothesis/ | ||
|
|
||
| # Translations | ||
| *.mo | ||
| *.pot | ||
|
|
||
| # Documentation | ||
| docs/_build/ | ||
|
|
||
| # PyBuilder | ||
| target/ | ||
|
|
||
| # IDEs | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| .DS_Store? | ||
| ._* | ||
| .Spotlight-V100 | ||
| .Trashes | ||
| ehthumbs.db | ||
| Thumbs.db | ||
|
|
||
| # Temporary files | ||
| *.tmp | ||
| *.temp | ||
| *.log | ||
saurabh500 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Node.js (if any) | ||
| node_modules/ | ||
| npm-debug.log* | ||
|
|
||
| # CMake | ||
| CMakeCache.txt | ||
| CMakeFiles/ | ||
| cmake_install.cmake | ||
| Makefile | ||
| *.cmake | ||
|
|
||
| # Build artifacts | ||
| *.so | ||
bewithgaurav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| *.dll | ||
| *.dylib | ||
| *.pdb | ||
| *.obj | ||
| *.exe | ||
|
|
||
| # Test results | ||
| test-results/ | ||
| .pytest_cache/ | ||
saurabh500 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Azure DevOps | ||
| .azure/ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.