From 350fcbb32d58f1d0beb884edb076e1457ffefd74 Mon Sep 17 00:00:00 2001
From: Neil-Jocelyn Schark <neil-jocelyn.schark@stud.h-da.de>
Date: Thu, 12 Oct 2023 12:07:00 +0000
Subject: [PATCH] Add basic devcontainer setup

---
 .devcontainer/Dockerfile        | 22 +++++++++++++++++++++
 .devcontainer/devcontainer.json | 34 +++++++++++++++++++++++++++++++++
 .gitignore                      |  1 -
 README.md                       |  9 +++++++++
 4 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 .devcontainer/Dockerfile
 create mode 100644 .devcontainer/devcontainer.json

diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 0000000..8d3b0c9
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,22 @@
+# The devcontainer will be based on Python
+# The base container already has entrypoint, vscode user account, etc. out of the box
+FROM mcr.microsoft.com/devcontainers/python:3-bookworm
+
+# containelab version will be set in devcontainer.json
+ARG _CLAB_VERSION
+
+# install some basic tools inside the container
+# adjust this list based on your demands
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends \
+    sshpass \
+    curl \
+    iputils-ping \
+    htop \
+    && rm -rf /var/lib/apt/lists/* \
+    && rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
+    && apt-get clean
+
+# install preferred version of the containerlab
+RUN bash -c "$(curl -sL https://get.containerlab.dev)" -- -v ${_CLAB_VERSION} \
+    && pip3 install --user yamllint
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000..2c1f522
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,34 @@
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the
+    // README at: https://github.com/devcontainers/templates/tree/main/src/python
+    {
+        "name": "clab-for-arm",
+        "build": {
+            "dockerfile": "Dockerfile",
+            "args": {
+                "_CLAB_VERSION": "0.46.1"
+            }
+        },
+        "features": {
+            // Containerlab will run in a docker-in-docker container
+            // it is also possible to use docker-outside-docker feature
+            "ghcr.io/devcontainers/features/docker-in-docker:2.7.0": {
+                "version": "latest"
+            },
+            "ghcr.io/devcontainers/features/go:1": {
+                    "version": "1.21.1"
+                }
+        },
+        // add any required extensions that must be pre-installed in the devcontainer
+        "customizations": {
+            "vscode": {
+                "extensions": [
+					"ms-azuretools.vscode-docker",
+					"golang.go",
+					"EditorConfig.EditorConfig",
+					"eamodio.gitlens",
+					"ms-vscode.makefile-tools",
+					"redhat.vscode-yaml"
+				]
+            }
+        }
+    }
diff --git a/.gitignore b/.gitignore
index d315529..a43df50 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,6 @@ artifacts/
 gostructs.go
 
 # non vimmers
-.devcontainer/
 .vscode/
 .idea/
 
diff --git a/README.md b/README.md
index 70803cf..35a105e 100644
--- a/README.md
+++ b/README.md
@@ -86,3 +86,12 @@ Our aim is to someday support the following YANG modules (dependencies not liste
 These modules were selected based on their probable usefulness in the context of a basic endpoint client (PC running a general purpose OS) with additional modules for future extension on specialized network equipment (switches etc.), and converted into Go structs using ygot and are available for implementation.\
 Currently none are fully supported.\
 In future versions it will be possible to request the current state of supported modules via the gNMI Capabilities command.
+
+### Devcontainer - local
+
+For this method you only need `docker` and `vscode` with the plugin `Dev Containers` from Microsoft installed.
+After you installed the required tools, you can simply open the folder in the dev container.
+Either you click on `Open in Container` if a pop-up appears on the bottom right, or by selecting `Open in Container` after clicking on `Remote Explorer` in the left bar in VSCode. Please note: depending on your internet connection and the performance of the device, the initial creation of the container can take several minuts or longer! Furthermore the initial git discovery of every submodule in this repo (if installed) can also take some minutes.
+
+The devcontainer has everything you need in it (even relevant VSCode plugins), so you should not need anything more.
+Please keep in mind that this setup is not tested thoroughly!
-- 
GitLab