You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/building/using-dev-container.md
+96-30
Original file line number
Diff line number
Diff line change
@@ -6,53 +6,94 @@ We offer the possibility to use such a Dev Container to build any of the support
6
6
7
7
## Requirements
8
8
9
-
-**Step 0**: Make sure your have cloned [nf-interpreter](https://github.com/nanoframework/nf-interpreter) nanoFramework directory. The working branch is `main`.
10
-
-**Step 1**: Make sure you have [VS Code](https://code.visualstudio.com/Download) installed.
11
-
-**Step 2**: Make sure you have [Docker Desktop](https://www.docker.com/products/docker-desktop) installed.
12
-
-**Step 3**: Optional but strongly recommended for performance reasons: activate [Windows Subsystem for Linux 2](https://docs.microsoft.com/windows/wsl/install-win10) on your Windows host machine.
9
+
-**Step 0**: Install WSL - We strongly recommended for performance reasons: activate [Windows Subsystem for Linux 2](https://learn.microsoft.com/windows/wsl/install) on your Windows host machine.
13
10
14
11
> note: that may require a reboot
15
12
16
-
-**Step 4**: Check Docker configuration and make sure you are signed in. In the bellow picture, the top right corner should have you Docker account. If you are not signed in, you'll get an error. And if you're using WSL2 (recommended), the checkbox for the WSL2 support should be checked.
13
+
-**Step 1**: We **DO NOT** recommend to have any application like Docker Desktop installed but rather use directly a clean installation of Docker or Podman directly on a WSL Ubuntu Linux instance.
14
+
The measure performances between native WSL Docker or Podman and using Docker Desktop are about **50 times faster without** and **with the git project also directly cloned in the WSL instance**.
15
+
1. you can install a new version of WSL like the Ubuntu 22.04: `wsl --install Ubuntu-22.04`
16
+
1. Create your user and password.
17
+
1. Install directly a container engine, let's say the Docker engine, follow the [instructions here](https://docs.docker.com/engine/install/ubuntu/). For an Ubuntu based image:
-**Step 5**: Make sure you have the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension installed.
21
-
-**Step 6**: Copy the two template files (in `nf-interpreter\config` folder) `user-tools-repos.TEMPLATE.json` and `user-prefs.TEMPLATE.json` to (new) files named `user-tools-repos.json` and `user-prefs.json`.
22
-
Change the content of your "new" `user-tools-repos.json` file as follows:
23
-
- Rename the json section `user-tools-repos-container` to `user-tools-repos`.
24
-
-**Step 7**: Open the full `nf-interpreter`directory with VS Code.
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
32
+
sudo apt-get update
33
+
```
26
34
27
-
Go to the file `.devcontainer/devcontainer.json` and choose the container you want. You will find the details in the file itself:
35
+
Then make the install and confirm you want to install:
28
36
29
-
```json
30
-
// Adjust this file to chose the platform you want using the prebuild containers
31
-
// - Dockerfile.All = you can build anything but it's a very large container
32
-
// - Dockerfile.AzureRTOS = for AzureRTOS targets
33
-
// - Dockerfile.ChibiOS = for ChibiOS based targets (ex: STM32, Netduino, Orgpal)
34
-
// - Dockerfile.ESP32 = for ESP32 targets
35
-
// - Dockerfile.TI = for TI targets
36
-
// If you prefer, you can use the source files and adjust them they are located, with the same names in ./sources. This will alow you to customize them and add anything you may need on top.
Add your user to the group who can run docker without elevated priviledges:
42
+
43
+
```shell
44
+
sudo usermod -aG docker $USER
45
+
```
46
+
47
+
Exit WSL with `exit`
48
+
49
+
- **Step 2**: Make sure you have [VS Code](https://code.visualstudio.com/Download) installed.
50
+
- **Step 3**: Make sure you have the `DevContainer` extention installed in VS Code: selectthe extension icon (or File -> Preferences -> Extensions) and search for`DevContainer`. Install the Microsoft one:
51
+
52
+

53
+
54
+
1. Create a profile in VS Code (File -> Preferences -> Profile -> Create profile), call it for example nanoFramework:
1. Adjust DevContainer options: Go to the settings (File -> Preferences -> Settings) and search for container, set the WSL distribution you just prepared (in our example Ubuntu-22.04):
- **Step 4**: From the command line, reconnect to WSL (just type`wsl`), go to your home (just do`cd ~`).
67
+
- **Step 5**: Make sure your have cloned [nf-interpreter](https://github.com/nanoframework/nf-interpreter) nanoFramework directory. The working branch is `main`.
39
68
40
-
> Note: as a beginner, we recommend you to use the pre built containers. If you are familiar with containers and need to adjust resources in them, then use the one which you can build yourself. Use the one in the `./sources` subdirectory. So the file name will be for example `./source/Dockerfile.All` to use the container containing everything and build it from the source.
41
-
> Error: if you get error message like "Bad CMake executable "". Is it installed or settings contain the correct path (cmake.cmakePath)? The solution: uninstall the CMake and CMake tool from Visual Studio Code and restart Visual Studio Code.
- **Step 6**: Open the full `nf-interpreter`directory with VS Code. Form your home, in WSL, you can just type`code ./nf-interpreter`
74
+
- **Step 7**: Copy the two template files (in `nf-interpreter\config` folder) `user-tools-repos.TEMPLATE.json` and `user-prefs.TEMPLATE.json` to (new) files named `user-tools-repos.json` and `user-prefs.json`.
75
+
Change the content of your "new"`user-tools-repos.json` file as follows:
76
+
- Rename the json section `user-tools-repos-container` to `user-tools-repos`.
77
+
- You will have to close VS Code
78
+
- Reopen VS Code from your home `code ./nf-interpreter`
79
+
80
+
- **Step 8**: Choose your container.
42
81
43
82
- **Step 9**: Once prompted, open the dev container.
> note: in our case, the dev container is called `nanoFramework`.
88
+
> note: in our case, we have multiple DevContainers all starting with `nanoFramework`. Select the one you need!
89
+
90
+

50
91
51
92
If VS Code does not show the prompt, you can press F1 to show all commands. In this list, you can selectthe item "Remote-Containers: Open Folder in Container..." to open the dev container manually. This option will require you to selectthe folder through the folder selection dialog.
52
93
53
94
- **Step 10**: At that point, like in the previous illustration, when clicking on the logs, you should see activities. Be patient. Yes, super patient.
54
-
-**Step 11**: We told you to be patient, go for a tea, or a coffee. This part is resource intensive, most of your memory and processor will be used.
55
-
-**Step 12**: More patience, yes, all the needed tools and directory are cloned, all the needed settings are cloned as well. This may take a very long time if you have a low bandwidth Internet. See the advance section to understand how you can skip some of the elements if you are only interested in a very specific board.
95
+
- **Step 11**: The prebuild container will be downloaded, depending on your internet bandwith, this may take a little bit of time.
96
+
- **Step 12**: More patience, yes, all the needed tools and directory are cloned, all the needed settings are cloned as well.
56
97
- **Step 13**: It will be over when your VS Code will give you access to the files and will look like this:
@@ -69,12 +110,15 @@ To select a new image, just click on the name of the target, the menu will pop u
69
110
70
111
- **Step 15**: This will actually prepare all what is needed in the `build`folder.
71
112
72
-
> **Important**: this may take up to 1h or more depending on the target and the performance of your machine. So be patient! While the project will be in preparation, you'll get the small window on the right:
113
+
>**Important**: If you did not follow the path of cloning the repository in the WSL instance but rather use a clone in Windows,
114
+
this may take up to 1h or more depending on the target and the performance of your machine. So be patient! While the project will be in preparation, you'll get the small window on the right:
73
115
74
116

75
117
76
-
-**Step 16**: did we already told you to be patient? :-) If you still have the little windows from the previous image, be patient! once done, go to the next step.
118
+
- **Step 16**: If you are using the recommended configuration and followed the steps, everything should be done in couple of seconds.
77
119
- **Step 17**: Hit `F7` this will trigger the build. The build will take some time as well. If all goes right, it will finish with a code 0 with something like: `[build] Build finished with exit code 0`
120
+
- **Step 18**: When the build succeed, your build file is located on `~/nf-interpreter/build/nanoCLR.bin`. You can copy it into a Windows folder
121
+
(for example `cp ~/nf-interpreter/build/nanoCLR.bin /mnt/c/tmp`). From there, you can use `nanoff` to flash it, see [flashing image section](#flashing-image).
In the `devcontainre.json` files, add the following entries:
250
+
251
+
```json
252
+
"runArgs": ["--userns=keep-id"],
253
+
"containerUser": "vscode",
254
+
```
255
+
256
+
This is needed for the DevContainer to work as a standard user.
257
+
Podman works as a standard user per default compare to Docker which runs as root per default.
258
+
259
+
### Using Docker Desktop
260
+
261
+
We **DO NOT** recommand to use Docker Destop as the performances are not good with it. It does create an overlayer that makes all the commands and traffic to go through Windows.
262
+
263
+
If you still want to use it and are happy to pay a performance price, you need to make sure you uncheck the option "Execute in WSL".
0 commit comments