-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add devcontainer #1141
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
Open
nbmaiti
wants to merge
2
commits into
main
Choose a base branch
from
devcontainer_enabled
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: add devcontainer #1141
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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", | ||
|
nbmaiti marked this conversation as resolved.
|
||
| "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" | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
nbmaiti marked this conversation as resolved.
|
||
| 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 | ||
|
nbmaiti marked this conversation as resolved.
|
||
| 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 <<EOF | ||
| Acquire::http::Proxy "$apt_http_proxy"; | ||
| Acquire::https::Proxy "$apt_https_proxy"; | ||
| EOF | ||
| fi | ||
|
|
||
| go install github.com/air-verse/air@latest | ||
| go install github.com/go-delve/delve/cmd/dlv@latest | ||
|
nbmaiti marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script runs on the host machine BEFORE the container is created. | ||
| # It ensures the Intel LMS service is running. | ||
|
|
||
| # Opt-in gate for host-side privileged LMS setup. | ||
| # Values: | ||
| # off (default): skip host LMS checks/changes | ||
| # start : start LMS if already installed; never install | ||
| # install : install LMS if missing, then start | ||
| # on : backward-compatible alias for "install" | ||
| LMS_SETUP_MODE="${DEVCONTAINER_LMS_SETUP:-off}" | ||
|
|
||
| # Keep compatibility with previous docs. | ||
| if [ "$LMS_SETUP_MODE" = "on" ]; then | ||
| LMS_SETUP_MODE="install" | ||
| fi | ||
|
|
||
| if [ "$LMS_SETUP_MODE" = "off" ]; then | ||
| echo "Skipping LMS host setup (DEVCONTAINER_LMS_SETUP=$LMS_SETUP_MODE)." | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ "$LMS_SETUP_MODE" != "start" ] && [ "$LMS_SETUP_MODE" != "install" ]; then | ||
| echo "Invalid DEVCONTAINER_LMS_SETUP value: $LMS_SETUP_MODE" | ||
| echo "Supported values: off, start, install" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Checking LMS service status..." | ||
|
|
||
| check_lms_active() { | ||
| if sudo systemctl is-active --quiet lms; then | ||
| echo "LMS service is active." | ||
| return 0 | ||
| else | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| if check_lms_active; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "LMS service is not active." | ||
|
|
||
| # Check if the service unit exists | ||
| if sudo systemctl list-unit-files | grep -q "^lms.service"; then | ||
| echo "LMS service exists but is inactive." | ||
|
|
||
| echo "Attempting to start LMS..." | ||
| sudo systemctl start lms | ||
|
|
||
| # Wait for up to 10 seconds for service to start | ||
| for i in {1..10}; do | ||
| sleep 1 | ||
| if check_lms_active; then | ||
| echo "LMS started successfully." | ||
| exit 0 | ||
| fi | ||
| done | ||
|
|
||
| echo "ERROR: Failed to start LMS service." | ||
| sudo systemctl status lms | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "LMS service not found." | ||
|
|
||
| if [ "$LMS_SETUP_MODE" = "start" ]; then | ||
| echo "LMS is missing and DEVCONTAINER_LMS_SETUP=start. Skipping install." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Proceeding with LMS install because DEVCONTAINER_LMS_SETUP=install..." | ||
|
|
||
| # Install dependencies | ||
| echo "Installing dependencies..." | ||
| # Update apt cache first (optional but recommended before installing) | ||
| # sudo apt-get update | ||
| sudo apt-get install -y cmake libglib2.0-dev libcurl4-openssl-dev libxerces-c-dev \ | ||
|
nbmaiti marked this conversation as resolved.
|
||
| libnl-3-dev libnl-route-3-dev libxml2-dev libidn2-0-dev libace-dev build-essential git | ||
|
|
||
| # Prepare working directory | ||
| WORK_DIR="$HOME/lms_setup" | ||
| mkdir -p "$WORK_DIR" | ||
| echo "Working directory: $WORK_DIR" | ||
|
|
||
| if [ -d "$WORK_DIR/lms" ]; then | ||
| echo "Cleaning up previous LMS source..." | ||
| sudo rm -rf "$WORK_DIR/lms" | ||
| fi | ||
|
|
||
| # Clone LMS | ||
| echo "Cloning LMS repository..." | ||
| git clone https://github.com/intel/lms.git "$WORK_DIR/lms" | ||
|
|
||
| # Build LMS | ||
| echo "Building LMS..." | ||
| cd "$WORK_DIR/lms" | ||
| mkdir -p build | ||
| cd build | ||
|
|
||
| # Using dynamic paths based on where we verified the clone | ||
| sudo cmake -S .. -B . | ||
| sudo cmake --build . | ||
|
nbmaiti marked this conversation as resolved.
|
||
|
|
||
| echo "Installing LMS..." | ||
| sudo make install | ||
|
|
||
| echo "Starting LMS service..." | ||
| sudo systemctl daemon-reload | ||
| sudo systemctl enable lms | ||
| sudo systemctl start lms | ||
|
|
||
| # Verify installation | ||
| for i in {1..10}; do | ||
| sleep 1 | ||
| if check_lms_active; then | ||
| echo "LMS installed and started successfully." | ||
| exit 0 | ||
| fi | ||
| done | ||
|
|
||
| echo "ERROR: Failed to start LMS after installation." | ||
| sudo systemctl status lms | ||
| exit 1 | ||
|
nbmaiti marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
| // README at: https://github.com/devcontainers/templates/tree/main/src/go | ||
| { | ||
| "name": "Go (Standard - no MEI device)", | ||
| // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
| "image": "mcr.microsoft.com/devcontainers/go:1.25-trixie", | ||
| // Features to add to the dev container. More info: https://containers.dev/features. | ||
| "features": { | ||
| "ghcr.io/devcontainers/features/common-utils:2": { | ||
| "installZsh": true, | ||
| "installOhMyZsh": true, | ||
| "installOhMyZshConfig": true, | ||
| "configureZshAsDefaultShell": true | ||
| } | ||
| }, | ||
| // Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
| "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:}" | ||
| }, | ||
| // Use 'initializeCommand' to run commands on the host before the container is created. | ||
| // "initializeCommand": "echo 'This runs on the host before container creation'", | ||
| "initializeCommand": "DEVCONTAINER_LMS_SETUP=${localEnv:DEVCONTAINER_LMS_SETUP:off} /bin/bash .devcontainer/pre-create.sh", | ||
| // Use 'postCreateCommand' to run commands after the container is created. | ||
| "postCreateCommand": "/bin/bash .devcontainer/post-create.sh", | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "waderyan.gitblame", | ||
| "shd101wyy.markdown-preview-enhanced", | ||
| "artisanbytecrafter.poptheme", | ||
| "ryu1kn.text-marker" | ||
| ], | ||
| "settings": { | ||
| "workbench.colorTheme": "Pop Light" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.