Development Environment as Code
The Visual Studio Code Remote - Containers extension lets you use a Docker container as a full-featured development environment. This fixes the following problems
- Enables developers other than yourself to get quickly up to speed
- Stops issues such as "It works on my machine"
- Allows you to check your development environment into git.
Install the devcontainer extension in VSCode and then setup a Rust environment.
Install Rust on Nails
We have pre-configured a development environment with all the tools needed to create a full stack rust application.
To get started create a folder for your project. Change directory into that folder then run.
mkdir project-name cd project-name
MacOS and Linux
| \ &&
| \ &&
Load the folder into visual studio code. On the bottom left corner of VS Code you should see a green icon. Click on this and select open in container.
After the container is downloaded you will have a preconfigured development environment with the following folder structure.
How you folder structure will look.
Setting up Git
Open up a terminal in VSCode (CTRL + `) and execute
Add a Workspace
We are going to create a workspace for our web application. Create a new
Cargo.toml file in the root folder and add the following.
 = [ "crates/*", ]
Open up the terminal in VSCode again and run the following
$ cargo new --vcs=none crates/axum-server Created binary (application) `crates/axum-server` package
You should now have a folder structure like the following.
Test out you development environment with
$ cargo run Compiling app v0.1.0 (/workspace/app) Finished dev [unoptimized + debuginfo] target(s) in 1.16s Running `target/debug/app` Hello, world!
Commit your code
$ git add . $ git commit -m"Initial Commit"