Recommended Codespace Configuration for Polyglot Notebooks
devcontainer.json and Dockerfile recommendations for Polyglot Notebooks & .NET Interactive
In order to get Polyglot Notebooks to work with GitHub Codespaces, you’ll need to match the current requirements of the Polyglot Notebooks extension and its underlying .NET Interactive kernels.
This relies on two files in your .devcontainer
directory:
Dockerfile
which describes the Docker container the Codespace will run indevcontainer.json
which describes how the dev container is configured in terms of extensions and ports
Current Requirements
As of September of 2024, Polyglot Notebooks requires the .NET 8 SDK.
Therefore, I recommend the following settings as basic starter templates:
Dockerfile
In the dockerfile, it’s important to use the .NET image that Polyglot Notebooks currently requires. At the moment, this is .NET 8.
ARG VARIANT="8.0"
FROM mcr.microsoft.com/devcontainers/dotnet:${VARIANT}
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
devcontainer.json
The devcontainer.json
file is a bit more flexible, but the critical thing we need to do is specify that the VS Code extension ms-dotnettools.dotnet-interactive-vscode
should be installed. This is the Polyglot Notebooks extension.
{
"name": "ASPNET",
// Configure tool-specific properties.
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "8.0",
"NODE_VERSION": "16"
}
},
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"extensions": [
"GitHub.github-vscode-theme", // Optional. Codespace IDE theming.
"ms-dotnettools.csharp", // Optional. Helpful for C# development
"ms-dotnettools.dotnet-interactive-vscode" // Polyglot Notebooks. Required
]
}
},
// 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": "gcc -v",
"onCreateCommand": "echo PS1='\"$ \"' >> ~/.bashrc && dotnet dev-certs https", //Set Terminal Prompt to $
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"powershell": "latest"
}
}
While these settings are initially picked based on those in my book, Data Science in .NET with Polyglot Notebooks, this is intended to be a living document that can be updated as Polyglot Notebooks moves to future versions of .NET or the recommended configuration settings change.
Learn data science using ML.NET, OpenAI, and Semantic Kernel
Data Science in .NET with Polyglot Notebooks teaches experienced .NET devs the fundamentals of data science, machine learning, and AI orchestration. It covers topics like ML.NET, OpenAI, Semantic Kernel, career development, and more.
Buy Data Science in .NET with Polyglot Notebooks on Amazon or through Packt in print and digital formats.
If you have any suggestions or corrections to make to either the Dockerfile
or the devcontainer.json
file, please get in touch with me.