From 2c940b3422dc32b977aa86154a7eef1fb2e64900 Mon Sep 17 00:00:00 2001 From: Adam Outler Date: Sun, 21 Sep 2025 21:17:14 +0000 Subject: [PATCH] Speed up devcontainer with ramdisk --- .devcontainer/devcontainer.json | 16 ++++++++++------ .devcontainer/scripts/setup.sh | 8 ++++++++ api/.git-placeholder | 0 api/.gitignore | 2 -- log/.gitignore | 3 --- log/plugins/.git-placeholder | 0 log/plugins/.gitignore | 3 --- 7 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 api/.git-placeholder delete mode 100755 api/.gitignore delete mode 100755 log/.gitignore create mode 100644 log/plugins/.git-placeholder delete mode 100755 log/plugins/.gitignore diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f9f6440e..bb6cfa72 100755 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,14 +7,18 @@ "target": "devcontainer" }, "workspaceFolder": "/workspaces/NetAlertX", - "runArgs": [ - "--privileged", - "--cap-add=NET_ADMIN", - "--cap-add=NET_RAW", - // Ensure containers can resolve host.docker.internal to the host (required on Linux) - "--add-host=host.docker.internal:host-gateway" + "--add-host=host.docker.internal:host-gateway", + "--security-opt", "apparmor=unconfined" // for alowing ramdisk mounts ], + + "capAdd": [ + "SYS_ADMIN", // For mounting ramdisks + "NET_ADMIN", // For network interface configuration + "NET_RAW" // For raw packet manipulation + ], + + "postStartCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/setup.sh", diff --git a/.devcontainer/scripts/setup.sh b/.devcontainer/scripts/setup.sh index f0705669..c0685047 100755 --- a/.devcontainer/scripts/setup.sh +++ b/.devcontainer/scripts/setup.sh @@ -67,6 +67,10 @@ configure_source() { echo "[1/3] Configuring Source..." echo " -> Linking source to ${INSTALL_DIR}" echo "Dev">${INSTALL_DIR}/.VERSION + + echo " -> Mounting ramdisks for /log and /api" + sudo mount -t tmpfs -o size=256M tmpfs "${SOURCE_DIR}/log" + sudo mount -t tmpfs -o size=512M tmpfs "${SOURCE_DIR}/api" safe_link ${SOURCE_DIR}/api ${INSTALL_DIR}/api safe_link ${SOURCE_DIR}/back ${INSTALL_DIR}/back safe_link "${SOURCE_DIR}/config" "${INSTALL_DIR}/config" @@ -94,6 +98,8 @@ configure_source() { echo " -> Removing existing user_notifications.json" sudo rm "${INSTALL_DIR}"/api/user_notifications.json fi + + echo " -> Setting ownership and permissions" sudo find ${INSTALL_DIR}/ -type d -exec chmod 775 {} \; @@ -101,6 +107,8 @@ configure_source() { sudo date +%s > "${INSTALL_DIR}/front/buildtimestamp.txt" sudo chmod 640 "${INSTALL_DIR}/config/${CONF_FILE}" || true + + echo " -> Setting up log directory" install -d -o netalertx -g www-data -m 777 ${INSTALL_DIR}/log/plugins diff --git a/api/.git-placeholder b/api/.git-placeholder new file mode 100644 index 00000000..e69de29b diff --git a/api/.gitignore b/api/.gitignore deleted file mode 100755 index d6b7ef32..00000000 --- a/api/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/log/.gitignore b/log/.gitignore deleted file mode 100755 index b6e069c5..00000000 --- a/log/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!*/ -!.gitignore \ No newline at end of file diff --git a/log/plugins/.git-placeholder b/log/plugins/.git-placeholder new file mode 100644 index 00000000..e69de29b diff --git a/log/plugins/.gitignore b/log/plugins/.gitignore deleted file mode 100755 index 34211e27..00000000 --- a/log/plugins/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!*/ -!.gitignore