Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuxel committed Apr 19, 2019
2 parents 2dd2fb2 + 0d92d39 commit a31934c
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 60 deletions.
59 changes: 34 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
# Visual Studio Code Remote Development Container Definitions
# VS Code Remote Development Container Definitions

A **development container** is a running container that comes with a basic tool stack (Python, node, Go, etc.) and its prerequisites (e.g. `pylint` for Python). This container may be used to actually run an application or be focused exclusively on sandboxing tools, libraries, runtimes, or other utilities that need to be run against a codebase.
<table style="width: 100%; border-style: none;"><tr>
<td style="width: 140px; text-align: center;"><a href="https://aka.ms/vscode-remote/download/extension"><img width="128px" src="https://microsoft.github.io/vscode-remote-release/images/remote-extensionpack.png" alt="Visual Studio Code logo"/></a></td>
<td>
<strong>Visual Studio Code Remote Development</strong><br />
<i>Open any folder in a container, on a remote machine, or in WSL and take advantage of VS Code's full feature set. <strong><a href="https://aka.ms/vscode-remote">Learn more!</a></strong><br />
<strong><a href="https://aka.ms/vscode-remote/download/extension"><img src="https://microsoft.github.io/vscode-remote-release//images/download.png" alt="Download now!"/></a></strong></i>
</td>
</tr></table>

The Containers extension in the [Visual Studio Code Remote Development](https://aka.ms/vscode-remote/download/extension) extension pack allows you to open any folder inside (or mounted into) a dev container and take advantage of VS Code's full feature set. When using the capability, VS Code selectively runs certain extensions in the container to optimize your experience. The result is that VS Code can provide a local-quality development experience including full IntelliSense, debugging, and more regardless of where your code is hosted.
A **development container** is a running container that comes with a basic tool stack (Python, node, Go, etc.) and its prerequisites. The Remote - Containers extension in the [Remote Development](https://aka.ms/vscode-remote/download/extension) extension pack allows you to open any folder inside (or mounted into) a dev container and take advantage of VS Code's full feature set.

**[Learn more about the Visual Studio Code Remote - Containers extension](https://aka.ms/vscode-remote/containers)**.
This repository contains a set of **dev container definitions** to help get you up and running in a containerized environment. They describe the needed container image, any runtime arguments for starting the container, and any VS Code extensions that should be installed into it. They're can help you get started or be used as examples for adapting your own configuration to different situations.

This repository contains a set of **dev container definitions** made up of files like `devcontainer.json` to help get you up and running in a containerized environment. These definitions describe the needed container image, any runtime arguments for starting the container, and any VS Code extensions that should be installed into it. They're can be useful to help you get started or as samples for how to adapt your own configuration to different situations.
## Using a definition

## Trying a definition
To add a dev container definition in your project, you can either:

1. Click on one of the `containers` sub-folders to open it in your browser
2. Check out the README to see if there are any manual steps
3. Clone this repository or copy the contents of the folder to your machine
4. Run the **Remote-Containers: Open Folder in Container...** command in VS Code
5. Select the root of the definition folder in the "open" dialog (**not** the `test-project` folder if present)
- Add them using VS Code:

1. If this is your first time creating a dev container, follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to configure your machine.
2. Start VS Code and open your project folder.
3. Press <kbd>F1</kbd>
and select either the **Remote-Containers: Create Container Configuration File...** or **Remote-Containers: Reopen Folder in Container** commands.
4. Follow the directions and pick a development container definition when the list appears.

Many definitions include a `test-project` with a sample and/or launch settings in the `.vscode` folder that you can use to see the dev container in action.
- Or manually copy the contents of one of folders in the `containers` directory into your project. Typically you can just copy the `.devcontainer` folder ignore everything else. See the definition's `README` for details.

## Using a definition
## Trying a definition

You can either:
If you want to try out a definition before choosing one:

- Open a folder in VS Code without a `devcontainer.json` file and run the **Remote-Containers: Create Container Configuration File...** or **Remote-Containers: Reopen Folder in Container** commands. You be prompted to pick a definition and any options and the appropriate files will then be added to your project.
1. If this is your first time creating a dev container, follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to configure your machine.
2. Browse the contents of the `containers` folder in this repository and pick one. Check out the `README` to see if there are any manual setup steps you should be aware of before continuing.
3. Clone this repository locally.
4. Start VS Code, press <kbd>F1</kbd>, and run the **Remote-Containers: Open Folder in Container...** command.
5. Select the root of the definition folder from the cloned repository when prompted (**not** the `test-project` folder if present).

- Manually copy the contents of one of the `containers` sub-folders into your project. Typically you can just copy the `.devcontainer` folder into your project but the folder's README may mention additional files.
Many definitions include a `test-project` with a sample and/or launch settings in the `.vscode` folder that you can use to see the dev container in action. See the definition's `README` for details.

## Adding a definition to an existing public or private repo

Expand All @@ -38,19 +51,15 @@ Beyond the advantages of having your team use a consistent environment and tool-
- `container-templates` - Contains templates for creating your own container definitions for your project or to [contribute back](CONTRIBUTING.md#contributing-dev-container-definitions).
- `repository-containers` - Dev container definitions for working on a cloned copy of specific, public source code repository (rather than general purpose).

## Common Questions

### Can I just reuse an existing container image or Docker configuration?

Absolutely! If you want to use an existing Dockerfile as a starting point, run **Remote-Containers: Create Container Configuration File...** from the command pallette (Cmd/Ctrl+Shift+P). You'll be prompted to select a Dockerfile or you can opt to use a base image instead and customize from there.
### Common Questions

You can also check out the [existing Dockerfile](containers/docker-existing-dockerfile) and [existing Docker Compose](containers/docker-existing-docker-compose) definitions for an example `devcontainer.json` . If none of these options meet your needs, you can start up the container any way you see fit and [attach to it](https://aka.ms/vscode-remote/containers/attach) instead.
#### Can I just reuse an existing container image or Docker / Docker Compose configuration?

### What is the goal of `devcontainer.json`?
Yes! If you want to use an existing Dockerfile as a starting point, run **Remote-Containers: Create Container Configuration File...** from the command pallette (Cmd/Ctrl+Shift+P). You'll be prompted to select a Dockerfile or Docker Compose file and customize from there. If you prefer, you can also you can start up the container any way you see fit and [attach to it](https://aka.ms/vscode-remote/containers/attach) instead.

The intent of `devcontainer.json` is conceptually similar to VS Code's `launch.json` for debugging, but designed to launch (or attach to) your development container instead. At its simplest, all you need to do is add a `.devcontainer/devcontainer.json` file to your project and reference an image, `Dockerfile`, or `docker-compose.yml` and a few properties.
#### What is the goal of `devcontainer.json`?

Check out the `container-templates` folder for simple starter templates. The definitions in the `containers` folder can be used as-is or as samples for how to modify your existing config to support different scenarios. From there, you can [alter your configuration](https://aka.ms/vscode-remote/containers/folder-setup) to install additional tools like Git in the container, automatically install other extensions, expose additional ports, set runtime arguments, and more.
The intent of `devcontainer.json` is similar to `launch.json` for debugging, but designed to launch (or attach to) a development container instead. At its simplest, all you need to do is add a `.devcontainer/devcontainer.json` file to your project that references an image, `Dockerfile`, or `docker-compose.yml`, and a few properties. You can [adapt it for use](https://aka.ms/vscode-remote/containers/folder-setup) in a wide variety of situations.

## Contributing & Feedback

Expand Down
36 changes: 36 additions & 0 deletions containers/dotnetcore-2.1/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/test-project/aspnetapp.csproj"
],
"problemMatcher": "$tsc"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/test-project/aspnetapp.csproj"
],
"problemMatcher": "$tsc"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/test-project/aspnetapp.csproj"
],
"problemMatcher": "$tsc"
}
]
}
36 changes: 36 additions & 0 deletions containers/dotnetcore-latest/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/test-project/aspnetapp.csproj"
],
"problemMatcher": "$tsc"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/test-project/aspnetapp.csproj"
],
"problemMatcher": "$tsc"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/test-project/aspnetapp.csproj"
],
"problemMatcher": "$tsc"
}
]
}
2 changes: 1 addition & 1 deletion containers/dotnetcore-latest/test-project/aspnetapp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<UserSecretsId>31051026529000467138</UserSecretsId>
</PropertyGroup>

Expand Down
9 changes: 8 additions & 1 deletion containers/go/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ RUN go get -u -v \
github.com/mgechev/revive \
github.com/derekparker/delve/cmd/dlv

# gocode-gomod
RUN go get -x -d github.com/stamblerre/gocode \
&& go build -o gocode-gomod github.com/stamblerre/gocode \
&& mv gocode-gomod $GOPATH/bin/

# Copy default endpoint specific user settings overrides into container to specify Python path
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json

# Install git, process tools
RUN apt-get update && apt-get -y install git procps

# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

3 changes: 3 additions & 0 deletions containers/go/.devcontainer/settings.vscode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"go.gopath": "/go"
}
2 changes: 1 addition & 1 deletion containers/plantuml/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See LICENSE in the project root for license information.
#-----------------------------------------------------------------------------------------

FROM java:11
FROM openjdk:8

# Install git, process tools
RUN apt-get update && apt-get -y install git procps
Expand Down
26 changes: 6 additions & 20 deletions containers/plantuml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Summary

*Use PlantUML without installing all the dependencies locally. Includes Java, GraphViz, and the PlantUML extension.*
*Demonstrates using PlantUML local rendering without installing dependencies. Includes Java, GraphViz, and the PlantUML extension.*

| Metadata | Value |
|----------|-------|
Expand All @@ -12,27 +12,13 @@

## Usage

First, install the **[Visual Studio Code Remote Development](https://aka.ms/vscode-remote/download/extension)** extension pack if you have not already.
[See here for information on using this and other definitions in your project](../../README.md#using-a-definition). There are no addtional steps required.

To use the definition with your own project:
### Try it

1. Copy the `.devcontainer` folder into your project root.
2. Reopen the folder in the container (e.g. using the **Remote-Container: Reopen Folder in Container** command in VS Code) to use it unmodified.

If you prefer, you can look through the contents of the `.devcontainer` folder to understand how to make changes to your own project.

If you want to try out the test project instead, run **Remote-Container: Open Folder in Container...** in VS Code and select a cloned copy of the entire folder.

Check out the samples folder or just do a markdown preview on this file once you've opened this folder in the container!

```plantuml
@startuml
Brain -> Brain: Wait, VS Code can do that?
Brain -> Mouth: Say "Cool!"
Mouth -> Ear: Cool!
Ear -> Brain: Heard myself say Cool!
@enduml
````
1. Run **Remote-Container: Open Folder in Container...** in VS Code and select a cloned copy of this entire folder.
2. The container will build and VS Code will connect.
3. Open `sample.plantuml` in the `test-project` folder and hit Alt-D.

## License

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Markdown Sample

Open the markdown preview to check it out!
Expand Down
4 changes: 0 additions & 4 deletions containers/rust/Cargo.lock

This file was deleted.

11 changes: 8 additions & 3 deletions containers/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@

## Usage

[See here for information on using this definition with an existing project](../../README.md#using-a-definition).
[See here for information on adding it to your project.](../../README.md#using-a-definition). There is no extra steps to using this dev container.

If you prefer, you can also just look through the contents of the `.devcontainer` folder to understand how to make changes to your own project.
### Try it!

If you want to try out the test project instead, run **Remote-Container: Open Folder in Container...** in VS Code and select a cloned copy of the entire folder. You can then start the test program from Debug panel in VS Code.
Just follow these steps to try out the test project:

1. Clone the vscode-dev-containers repository
2. Start VS Code and run **Remote-Container: Open Folder in Container...** and select this folder
3. Hit F5 or click on the Debug panel and start select "Debug executable 'hello world'"
4. The project will run and output "Hello, VS Code Remote!"

## License

Expand Down
6 changes: 6 additions & 0 deletions containers/rust/test-project/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions containers/swift-4/test-project/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import PackageDescription
let package = Package(
name: "helloworld",
targets: [
.target(
name: "helloworld",
path: "Sources")
Target(name:"helloworld")
]
)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-dev-containers",
"version": "0.8.0",
"version": "0.9.0",
"description": "VS Code Dev Containers: Definitions and Templates",
"repository": {
"type": "git",
Expand Down

0 comments on commit a31934c

Please sign in to comment.