Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
document how to run this codespace in a docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
mattetti committed Jun 9, 2020
1 parent 9c90b22 commit ff9d113
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Besides Rust and Cargo, the image comes with the following Rust related tooling:

### VS Code Extensions

- [Rust](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust): Rust default extension.
- [Rust Analyzer](https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer): an alternative rust language server to the RLS.
- [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb): native debugger based on LLDB.
- [Crates](https://marketplace.visualstudio.com/items?itemName=serayuzgur.crates): helps Rust developers managing dependencies with Cargo.toml.
Expand All @@ -40,15 +41,15 @@ Besides Rust and Cargo, the image comes with the following Rust related tooling:

## Usage

### In VS Codespaces
### Online VS Codespaces

#### Inital Creation

For usage in VS Codespaces, you're going to want to head over to [online.visualstudio.com](https://online.visualstudio.com) and sign up for VS Codespaces (that process is outside the scope of these instructions). Once you've got an account and are signed in to [online.visualstudio.com](https://online.visualstudio.com), you're going to take the following steps:

- Ensure you're on the `/environments` page at [online.visualstudio.com/environments](https://online.visualstudio.com/environments)
- In the top right corner, there'll be a "Create environment" button. Click this button, which will open up a panel from the right side of the screen. Fill in the details of this panel:
- **Codespace Name:** This will be the visible name of your environment within Codespaces. The value here doesn't particularly matter.
- **Codespace Name:** This will be the visible name of your environment within Codespaces. The value here doesn't particularly matter.
- **Git Repository:** This is going to be either the URL you'd `git clone` the repo from or the GitHub `<org OR user>/<repo>` shorthand. For this repo, the easier value would be `codespaces-examples/base`.
- **Instance Type:** For this, you're going to choose your plan - in my case, I'm just going to go with the `Standard (Linux)` plan. For most use cases of this starter, `Basic (Linux)` should suffice. You can also change your plan at any time, as your workload demands.
- **Suspend idle environment after:** This is the period of time you want your environment to automatically suspend after you've stopped actively using it. I generally chose 5 minutes and have not had any problems to date.
Expand All @@ -74,6 +75,34 @@ Additionally, if you've installedthe [Visual Studio Codespaces](https://marketpl

Now that you're set up and connected, you should be able to work within your Codespaces environment.

### VS Codespaces inside a Docker container

Using [Visual Studio Code](https://code.visualstudio.com/) and a [specific extension](https://aka.ms/vscode-remote/download/extension), we can load this codespace in a brand new local [Docker](https://docker.com/) container and use it as a full-featured development environment. Note that this approach requires a few more steps than using the online setup mentioned above. The advantages being that this works offline and there are no costs associated with this approach. It is a great way to play with a setup without having to install everything globally on one's machine!


#### Requirements

There are 3 main requirements: **VSCode**, **the Remote - Containers VSCode extension** and **Docker**.

Follow the instruction [guide here](https://code.visualstudio.com/docs/remote/containers#_installation) and come back here once those 3 components are installed locally.

### Setup

To load the codespace in a container, we need to point to it. We have many options here, the main ones being to connect to a repository and the other one to open a local folder with the codespace repo checked out. We are going to take the easiest approach and setup the code space directly from this repository.

1. In VSCode, click on the green icon in the lower left corner.

![](https://code.visualstudio.com/assets/docs/remote/common/remote-dev-status-bar.png)

2. Choose `Remote-Containers: Open Repository in container`
3. Type `codespaces-examples/rust` in the prompt.
4. Chose to create a unique volume.
5. Wait until the container is setup and you are connected to it, at this point, it should ask you to install some missing Rust components, go ahead and say yes.
![](https://user-images.githubusercontent.com/113/84210352-468ca100-aa6d-11ea-88c4-fdffa1b9e92a.png)

That's it, you are all setup, you can modify and run the code in your local VSCode instance but the code and extensions will run in your container.


## Contributing

Contributions are welcome. Please refrain from opinionated additions like linters. However, adding package managers and other DX improvements that are additive like `yarn` are welcome. Contributors must follow the [Code of Conduct](./CODE_OF_CONDUCT.md).

0 comments on commit ff9d113

Please sign in to comment.