-
Notifications
You must be signed in to change notification settings - Fork 21
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
1
commit 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
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
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.
Show resolved
Hide 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": "sed -i 's/\\r$//' .devcontainer/pre-create.sh && /bin/bash .devcontainer/pre-create.sh", | ||
| "postCreateCommand": "sed -i 's/\\r$//' .devcontainer/post-create.sh && /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.
Show resolved
Hide 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.
Show resolved
Hide 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.
Show resolved
Hide 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,137 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script runs on the host machine BEFORE the container is created. | ||
| # It ensures the Intel LMS service is running. | ||
|
|
||
| echo "Checking LMS service status..." | ||
|
|
||
| # Skip LMS checks on non-Linux hosts. | ||
| if [[ "$(uname -s)" != "Linux" ]]; then | ||
| echo "Non-Linux host detected; skipping LMS service check." | ||
| exit 0 | ||
| fi | ||
|
|
||
| check_lms_active() { | ||
| if sudo systemctl is-active --quiet lms; then | ||
| echo "LMS service is active." | ||
| return 0 | ||
| else | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| prompt_timeout() { | ||
| local msg="$1" | ||
| local sec=10 | ||
| USER_INPUT="" | ||
| while [ $sec -gt 0 ]; do | ||
| echo -ne "\r$msg (timeout: ${sec}s) " | ||
| if read -t 1 USER_INPUT; then | ||
| echo "" | ||
| return 0 | ||
| fi | ||
| ((sec--)) | ||
| done | ||
| echo "" | ||
| USER_INPUT="n" | ||
| } | ||
|
|
||
| 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." | ||
|
|
||
| prompt_timeout "Do you want to start it? (y/n) [n]" | ||
| answer="$USER_INPUT" | ||
|
|
||
| if [[ "$answer" =~ ^[Yy]$ ]]; then | ||
| 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 | ||
| else | ||
| echo "Skipping LMS start. Proceeding with devcontainer creation..." | ||
| exit 0 | ||
| fi | ||
| fi | ||
|
|
||
| echo "LMS service not found." | ||
|
|
||
| prompt_timeout "Do you want to install and start it? (y/n) [n]" | ||
| answer="$USER_INPUT" | ||
|
|
||
| if [[ "$answer" =~ ^[Yy]$ ]]; then | ||
| # Proceed with installation | ||
| echo "Proceeding with installation..." | ||
| else | ||
| echo "Skipping LMS installation. Proceeding with devcontainer creation..." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # 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.
Show resolved
Hide 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.
Show resolved
Hide 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.
Show resolved
Hide 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,42 @@ | ||
| // 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, only Lms supported)", | ||
| // 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:}" | ||
| }, | ||
| "postCreateCommand": "sed -i 's/\\r$//' .devcontainer/post-create.sh && /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" | ||
| } | ||
| } | ||
| } | ||
| } |
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.