diff --git a/.devcontainer/mei/devcontainer.json b/.devcontainer/mei/devcontainer.json new file mode 100644 index 00000000..7fdbfce4 --- /dev/null +++ b/.devcontainer/mei/devcontainer.json @@ -0,0 +1,47 @@ +{ + "name": "Go (MEI Device - Linux host)", + "image": "mcr.microsoft.com/devcontainers/go:1.25-trixie", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": true, + "installOhMyZsh": true, + "installOhMyZshConfig": true, + "configureZshAsDefaultShell": true + } + }, + "runArgs": [ + "--device", + "/dev/mei0", + "--privileged", + "--net=host" + ], + "remoteUser": "root", + "forwardPorts": [ + 8181 + ], + "containerEnv": { + "HTTP_PROXY": "${localEnv:HTTP_PROXY:}", + "HTTPS_PROXY": "${localEnv:HTTPS_PROXY:}", + "NO_PROXY": "${localEnv:NO_PROXY:}", + "http_proxy": "${localEnv:http_proxy:}", + "https_proxy": "${localEnv:https_proxy:}", + "no_proxy": "${localEnv:no_proxy:}" + }, + "initializeCommand": "DEVCONTAINER_LMS_SETUP=${localEnv:DEVCONTAINER_LMS_SETUP:off} /bin/bash .devcontainer/pre-create.sh", + "postCreateCommand": "/bin/bash .devcontainer/post-create.sh", + "customizations": { + "vscode": { + "extensions": [ + "waderyan.gitblame", + "shd101wyy.markdown-preview-enhanced", + "artisanbytecrafter.poptheme", + "ryu1kn.text-marker", + "anoff.theme-monokai-light" + ], + "settings": { + "workbench.colorTheme": "Monokai Light", + "workbench.preferredLightColorTheme": "Monokai Light" + } + } + } +} \ No newline at end of file diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100755 index 00000000..de8b3610 --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e + +# Unset empty proxy variables +for var in HTTP_PROXY HTTPS_PROXY NO_PROXY http_proxy https_proxy no_proxy; do + eval v="\${$var}" + if [ -z "$v" ]; then unset $var; fi +done + +# Strip all trailing '/' or '\\' from proxy URLs for apt config +strip_trailing_slash() { + local url="$1" + # Remove all trailing / or \ + url="${url%%*(/|\\)}" + # Fallback for Bash < 4.0 (no extglob): use sed + echo "$url" | sed 's%[\\/]*$%%' +} + +if [ -n "$HTTP_PROXY" ] || [ -n "$http_proxy" ] || [ -n "$HTTPS_PROXY" ] || [ -n "$https_proxy" ]; then + echo "Configuring apt to use proxy..." + sudo mkdir -p /etc/apt/apt.conf.d + # Remove all trailing / or \\ from proxy URLs + apt_http_proxy="$(strip_trailing_slash "${HTTP_PROXY:-${http_proxy:-}}")" + apt_https_proxy="$(strip_trailing_slash "${HTTPS_PROXY:-${https_proxy:-}}")" + sudo tee /etc/apt/apt.conf.d/99proxy > /dev/null <