Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devcontainer #493

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM mcr.microsoft.com/devcontainers/base:bookworm

USER root

ENV NODE_ENV=development

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
build-essential \
ca-certificates \
curl \
file \
git \
gnupg2 \
gpg \
libappindicator3-dev \
libayatana-appindicator3-dev \
libgtk-3-dev \
librsvg2-dev \
libssl-dev \
libsoup2.4-dev \
libwebkit2gtk-4.0-dev \
patchelf \
python3-pip \
usbutils \
wget \
zip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

USER vscode

RUN echo 'export DISPLAY="${DISPLAY:-:1}"' | tee -a ~/.bashrc >> ~/.zshrc

HEALTHCHECK NONE
47 changes: 47 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## :whale: Using the Devcontainer

This project includes a [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) configuration for Visual Studio Code, which allows you to develop inside a containerized environment. This ensures that all developers have a consistent development environment, regardless of their local machine setup.

> **Note:** The devcontainer is tested on:\
Windows 11 with Docker Desktop and WSL2 Ubuntu.\
Ubuntu, use command `xhost +` let the display through.\
Fedora/Nobara 41.

### Prerequisites

To use the devcontainer, you need to have the following installed:

- [Visual Studio Code](https://code.visualstudio.com/)
- [Docker](https://www.docker.com/get-started)
- [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for Visual Studio Code.

### Setup

1. Open up a new blank workspace in Visual Studio Code.
2. Navigate to the Remote Explorer extension.
3. Clone this repository in container volume. (Dev Volumes)
4. Launch the Dev Container.

By using the devcontainer, you ensure that your development environment is consistent with the rest of the team, reducing the likelihood of environment-specific issues.

## Application

Once the devcontainer is set up, you can use the same development commands as described in the [Development Commands](/README.md#development-commands) section. The devcontainer includes all necessary dependencies and tools for developing and testing the project.

Start the application by running command `pnpm run rust:dev`.

> **Note:** If you encounter any issues you can always refresh the devcontainer by rebuilding it. `F1` > `Dev Containers: Rebuild Container`.

## Meshtasticd and CLI

The container has [meshtasticd](https://meshtastic.org/docs/hardware/devices/linux-native-hardware/) installed and can be started by running `meshtasticd -c .devcontainer/config.yaml` in the terminal. \
This allows connecting to a meshtastic device on `localhost:4403`.

The container also has [meshtastic CLI](https://meshtastic.org/docs/software/python/cli/) installed, once `meshtasticd` is running you can configure it using `meshtastic --host localhost COMMANDS`.

```
meshtastic --host localhost --set-owner Devcontainer --set-owner-short VSCD
meshtastic --host localhost --setlat 51.5007324 --setlon -0.1294963
```

> **Note:** If you encounter any issues connection to `localhost:4403` you might need to run the `meshtasticd -c .devcontainer/config.yaml` command again.
5 changes: 5 additions & 0 deletions .devcontainer/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
General:
MACAddress: AA:BB:CC:DD:EE:FF
Webserver:
Port: 443
RootPath: /usr/share/doc/meshtasticd/web
74 changes: 74 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "Meshtastic Network-Management-Client Dev",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/rust:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "lts",
"pnpmVersion": "latest"
},
"ghcr.io/devcontainers/features/python:1": {
"installTools": "false"
}
},
"customizations": {
"vscode": {
"extensions": [
// "Trunk.io",
"biomejs.biome",
"rust-lang.rust-analyzer",
"tauri-apps.tauri-vscode"
],
"unwantedRecommendations": [
"ms-azuretools.vscode-docker"
],
"settings": {
"extensions.ignoreRecommendations": true,
"files.eol": "\n",
"editor.tabSize": 2,
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"typescript.preferences.importModuleSpecifier": "non-relative",
"rust-analyzer.showUnlinkedFileNotification": false
}
}
},
"forwardPorts": [
5173,
443,
4403
],
"portsAttributes": {
"443": {
"label": "Meshtasticd Web Client",
"onAutoForward": "silent",
"protocol": "https"
},
"4403": {
"label": "Meshtasticd",
"onAutoForward": "silent"
},
"5173": {
"label": "Meshtastic Network Management Client",
"onAutoForward": "silent"
}
},
"runArgs": [
// Use "--device=" to make a local device available inside the container.
// "--device=/dev/ttyACM0",
],
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh",
"postStartCommand": "bash .devcontainer/postStartCommand.sh"
}
10 changes: 10 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

sudo chown -R vscode /workspaces

# Install meshtasticd
echo 'deb http://download.opensuse.org/repositories/network:/Meshtastic:/beta/Debian_12/ /' | sudo tee /etc/apt/sources.list.d/network:Meshtastic:beta.list
curl -fsSL https://download.opensuse.org/repositories/network:Meshtastic:beta/Debian_12/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/network_Meshtastic_beta.gpg > /dev/null
sudo apt update && sudo apt install meshtasticd -y

sudo cp /etc/meshtasticd/available.d/lora-waveshare-sxxx.yaml /etc/meshtasticd/config.d/
10 changes: 10 additions & 0 deletions .devcontainer/postStartCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

git submodule update --init || echo "no submodules to update"

pip3 install --upgrade "meshtastic[cli]" --break-system-packages -q

nohup meshtasticd -c .devcontainer/config.yaml > nohup-meshtasticd.out &

pnpm i
pnpm run rust:dev
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ dist-ssr
*.sln
*.sw?
node_modules

# nohup output
nohup*.out