Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I check in the VS Code dev container files? For example, the .devcontainer folder or .devcontainer.json file?

I created a new Dev Container in VS Code, and VS Code added .devcontainer folder to my workspace. Should I check this file in to git?

like image 693
Matt Bierner Avatar asked May 02 '19 17:05

Matt Bierner


People also ask

What is a devcontainer in Visual Studio Code?

A devcontainer.json file in your project tells VS Code how to access (or create) a development container with a well-defined tool and runtime stack. This container can be used to run an application or to sandbox tools, libraries, or runtimes needed for working with a codebase.

How to setup a Dev container environment in VS Code?

To setup a Dev Container environment, you have two options: Manually write the files required. Get VS Code to take you through the configuration screen and create the boilerplate files for you. For your first attempt, I’d recommend option 2.

Can I run my extension from a Dev container?

The VS Code extension API hides most of the implementation details of running remotely so many extensions will just work inside dev containers without any modification. However, we recommend that you test your extension in a dev container to be sure that all of its functionality works as expected.

Where can I find the config file for a Dev container?

The dev container configuration is either located under .devcontainer/devcontainer.json or stored as a .devcontainer.json file (note the dot-prefix) in the root of your project. You can use an image as a starting point for your devcontainer.json.


1 Answers

Yes, we recommend that you check in the .devcontainer folder (or .devcontainer.json file) as they define the environment and tools used to develop your project.

Checking in a dev container definition to your repo makes it easier for new contributors to get started with your project and can ensure that all developers are using a consistent set of development tools and a consistent environment (for example, the same version of yarn, the same python runtime, etc...)

When a developer clones a repository with a dev container definition and opens that project in VS Code, they will be asked if they want to re-open the project in a dev container:

The Re-open in container command

Once the container builds, VS Code will start up inside an isolated environment that already has all the tools needed to start contributing. Since the environment is isolated from the local machine so developers don't have to worry about messing up their local environment when testing out your project

like image 50
Matt Bierner Avatar answered Oct 17 '22 17:10

Matt Bierner