Hello.

I made a patch for adding vscode&docker environment.
https://code.visualstudio.com/docs/devcontainers/containers

Docker volume mounts the gnunet source directory inside the container so 
development can be done inside the container.
https://docs.docker.com/storage/volumes/

It would be relatively easy for interested developers to begin development 
because it eliminates the need to install packages on the system in my opinion.

Martin Schanzenbach(schan...@gnunet.org) <mailto:schan...@gnunet.org> told me 
that there's Dockerfile for GNUNet in gnunet-source-root/contrib/docker 
already. (thanks.)

But I found that the Dockerfile is for running GNUNet in docker container and 
not for developing GNUNet in docker container.



Here's how to test/confirm.

# 1
Prepare environment(
Follow instructions at: 
https://code.visualstudio.com/docs/devcontainers/containers#_installation
FYI: 
https://code.visualstudio.com/docs/getstarted/telemetry#_disable-telemetry-reporting

# 2 
Open gnunet source directory in vscode.
Press F1 key and choose "Dev Containers: Open Folder in Container...".

Once the gnunet source directory is opened in the reloaded window, choose 
File(top left) ->  Open Workspace from File and select 
"gnunet.code-workspace"(not from local).

And setup is done.
You can press F1 and select "Tasks: Run Task" to run tasks defined in 
.vscode/tasks.json.


Thanks.

>From 23116784b59391516d61e2aaaa147ca265a6d920 Mon Sep 17 00:00:00 2001
From: tim3_gnunet_contrib <si...@keemail.me>
Date: Mon, 31 Jul 2023 18:55:52 +0900
Subject: [PATCH 1/3] Add docker environment for in container gnunet
 developing.

---
 .devcontainer/Dockerfile              | 26 ++++++++++++++++++++++++++
 .devcontainer/devcontainer.json       | 20 ++++++++++++++++++++
 .devcontainer/docker-compose-dev.yaml | 11 +++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 .devcontainer/Dockerfile
 create mode 100644 .devcontainer/devcontainer.json
 create mode 100644 .devcontainer/docker-compose-dev.yaml

diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 000000000..23705e0e6
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,26 @@
+# Dockerfile for GNUNet developing
+
+# Use debian image
+# https://hub.docker.com/_/debian
+FROM debian:bookworm
+
+# Install build tools for compiling GNUnet
+RUN apt-get update && apt-get install -y git gcc autoconf gettext autopoint automake recutils libtool texinfo make \
+    pkgconf python3-sphinx python3-sphinx-rtd-theme uncrustify
+
+# Install GNUNet dependencies (requirements of ./configure)
+RUN apt-get update && apt-get install -y libgcrypt20-dev libjansson-dev libcurl4-openssl-dev libsodium-dev libidn2-dev zlib1g-dev \
+    libunistring-dev libmicrohttpd-dev  libpq-dev libsqlite3-dev default-libmysqlclient-dev
+
+
+# Install optional GNUNet dependencies
+# net-tools is for ifconfig
+# TODO Java
+RUN apt-get update && apt-get install -y iptables libopus-dev libpulse-dev libpng-dev libzbar-dev libextractor-dev miniupnpc \
+    net-tools libbluetooth-dev
+
+# Install gstreamer(required by conversation) https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c
+RUN apt-get update && apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
+
+# Install otional packages
+RUN apt-get update && apt-get install -y doxygen mandoc
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 000000000..430952dd0
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,20 @@
+// How to use: https://code.visualstudio.com/docs/devcontainers/containers#_getting-started
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the
+// README at: https://github.com/devcontainers/templates/tree/main/src/debian
+{
+	"name": "VSCodeGNUNetDev",
+	"dockerComposeFile": "docker-compose-dev.yaml",
+	"service": "gnunet-dev",
+	"workspaceFolder": "/gnunet_source",
+	"customizations": {
+		"vscode": {
+			"extensions": ["ms-vscode.cpptools"]
+		}
+	}
+	// Features to add to the dev container. More info: https://containers.dev/features.
+	// "features": {},
+	// Use 'forwardPorts' to make a list of ports inside the container available locally.
+	// "forwardPorts": [],
+	// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
+	// "remoteUser": "root"
+}
diff --git a/.devcontainer/docker-compose-dev.yaml b/.devcontainer/docker-compose-dev.yaml
new file mode 100644
index 000000000..879f34758
--- /dev/null
+++ b/.devcontainer/docker-compose-dev.yaml
@@ -0,0 +1,11 @@
+# doc: https://docs.docker.com/compose/compose-file/
+version: "3.8"
+
+services:
+  gnunet-dev:
+    build:
+      context: ./
+      dockerfile: ./Dockerfile
+    command: /bin/sh -c "while sleep 1000; do :; done" # Prevent the container from exiting so we can develop in it.
+    volumes:
+      - ../:/gnunet_source:cached # https://stackoverflow.com/questions/43844639/how-do-i-add-cached-or-delegated-into-a-docker-compose-yml-volumes-list
-- 
2.39.2


>From 918c019d8b4de3b761ca0daf03af4251d3a58e8c Mon Sep 17 00:00:00 2001
From: tim3_gnunet_contrib <si...@keemail.me>
Date: Mon, 31 Jul 2023 18:57:04 +0900
Subject: [PATCH 2/3] Add vscode workspace file.

---
 gnunet.code-workspace | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 gnunet.code-workspace

diff --git a/gnunet.code-workspace b/gnunet.code-workspace
new file mode 100644
index 000000000..a005046c5
--- /dev/null
+++ b/gnunet.code-workspace
@@ -0,0 +1,11 @@
+// doc: https://code.visualstudio.com/docs/editor/workspaces#_multiroot-workspace-settings
+{
+    "folders": [
+        {
+            "name": "Root",
+            "path": "."
+        },
+    ],
+    "settings": {
+    }
+}
-- 
2.39.2


>From d9e66006d1ab0e2e997fa0f6e18b036e19bd03dc Mon Sep 17 00:00:00 2001
From: tim3_gnunet_contrib <si...@keemail.me>
Date: Mon, 31 Jul 2023 18:57:36 +0900
Subject: [PATCH 3/3] Add vscode task definitions for common routine works.

---
 .vscode/tasks.json | 69 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 .vscode/tasks.json

diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 000000000..26373e18d
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,69 @@
+// doc: https://code.visualstudio.com/Docs/editor/tasks
+// https://code.visualstudio.com/docs/editor/variables-reference
+{
+    // See https://go.microsoft.com/fwlink/?LinkId=733558
+    // for the documentation about the tasks.json format
+    "version": "2.0.0",
+    "tasks": [
+        {
+            "label": "Build",
+            "type": "shell",
+            "options": {
+                "cwd": "${workspaceFolder}"
+            },
+            "dependsOrder": "sequence",
+            "dependsOn": [
+                "bootstrap",
+                "configure",
+                "make"
+            ]
+        },
+        {
+            "label": "bootstrap",
+            "type": "shell",
+            "command": "./bootstrap",
+            "options": {
+                "cwd": "${workspaceFolder}"
+            }
+        },
+        {
+            "label": "configure",
+            "type": "shell",
+            "command": "./configure",
+            "options": {
+                "cwd": "${workspaceFolder}"
+            }
+        },
+        {
+            "label": "make",
+            "type": "shell",
+            "command": "echo $(nproc) | xargs make -j ",
+            "options": {
+                "cwd": "${workspaceFolder}"
+            },
+            "problemMatcher": []
+        },
+        {
+            "label": "make clean",
+            "type": "process",
+            "command": "make",
+            "args": [
+                "clean"
+            ],
+            "options": {
+                "cwd": "${workspaceFolder}"
+            }
+        },
+        {
+            "label": "make check",
+            "type": "process",
+            "command": "make",
+            "args": [
+                "check"
+            ],
+            "options": {
+                "cwd": "${workspaceFolder}"
+            }
+        }
+    ]
+}
-- 
2.39.2

Reply via email to