-
Notifications
You must be signed in to change notification settings - Fork 2
Add container runtime pre-flight check #28
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,113 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| # SPDX-License-Identifier: GPL-3.0-only | ||||||
| # Copyright (c) 2026 Marcus Krueger | ||||||
| # Pre-flight check: validates a container runtime is available on the host. | ||||||
| # Runs via initializeCommand BEFORE any container build/pull/start. | ||||||
|
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if CLAUDE.md exists and whether preflight.sh is already documented
if [ -f ".devcontainer/CLAUDE.md" ]; then
echo "=== Checking if preflight.sh is mentioned in CLAUDE.md ==="
rg -n "preflight" .devcontainer/CLAUDE.md || echo "preflight.sh not mentioned in CLAUDE.md"
echo ""
echo "=== Looking for setup scripts section in CLAUDE.md ==="
rg -n -B2 -A5 "setup.*\.sh|scripts/" .devcontainer/CLAUDE.md | head -40
else
echo "CLAUDE.md not found"
fiRepository: AnExiledDev/CodeForge Length of output: 1309 🏁 Script executed: #!/bin/bash
# List all scripts in the devcontainer scripts directory
echo "=== Scripts in .devcontainer/scripts/ ==="
ls -la .devcontainer/scripts/ 2>/dev/null || echo "scripts directory not found"
echo ""
echo "=== Check git status for preflight.sh ==="
git status .devcontainer/scripts/preflight.sh 2>/dev/null || echo "preflight.sh not in git"
echo ""
echo "=== Check devcontainer.json for initializeCommand ==="
rg -A2 "initializeCommand" .devcontainer/devcontainer.jsonRepository: AnExiledDev/CodeForge Length of output: 1184 🏁 Script executed: #!/bin/bash
# Get CLAUDE.md to understand what's documented about initialization and scripts
wc -l .devcontainer/CLAUDE.md
echo ""
echo "=== Full CLAUDE.md content ==="
cat -n .devcontainer/CLAUDE.mdRepository: AnExiledDev/CodeForge Length of output: 11604 Update CLAUDE.md to document the initialization flow, including The scripts/ directory comment (line 23) states "Setup scripts (run via postStartCommand)" but this is incomplete—
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| set -euo pipefail | ||||||
|
|
||||||
| # --- OS detection --- | ||||||
|
|
||||||
| detect_os() { | ||||||
| if [[ -f /proc/version ]] && grep -qi 'microsoft\|wsl' /proc/version 2>/dev/null; then | ||||||
| echo "wsl" | ||||||
| elif [[ "$(uname -s)" == "Darwin" ]]; then | ||||||
| echo "macos" | ||||||
| else | ||||||
| echo "linux" | ||||||
| fi | ||||||
| } | ||||||
|
|
||||||
| # --- Timeout wrapper (macOS lacks coreutils timeout) --- | ||||||
|
|
||||||
| run_with_timeout() { | ||||||
| local seconds="$1" | ||||||
| shift | ||||||
| if command -v timeout &>/dev/null; then | ||||||
| timeout "$seconds" "$@" &>/dev/null 2>&1 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant redirection.
🧹 Proposed fix- timeout "$seconds" "$@" &>/dev/null 2>&1
+ timeout "$seconds" "$@" &>/dev/null📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| else | ||||||
| # Fallback for macOS: background + kill | ||||||
| "$@" &>/dev/null 2>&1 & | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same redundant redirection issue. 🧹 Proposed fix- "$@" &>/dev/null 2>&1 &
+ "$@" &>/dev/null &📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| local pid=$! | ||||||
| (sleep "$seconds" && kill "$pid" 2>/dev/null) & | ||||||
| local watchdog=$! | ||||||
| if wait "$pid" 2>/dev/null; then | ||||||
| kill "$watchdog" 2>/dev/null | ||||||
| wait "$watchdog" 2>/dev/null | ||||||
| return 0 | ||||||
| else | ||||||
| kill "$watchdog" 2>/dev/null | ||||||
| wait "$watchdog" 2>/dev/null | ||||||
| return 1 | ||||||
| fi | ||||||
| fi | ||||||
| } | ||||||
|
|
||||||
| # --- Runtime detection --- | ||||||
|
|
||||||
| check_runtime() { | ||||||
| local runtime="$1" | ||||||
| if ! command -v "$runtime" &>/dev/null; then | ||||||
| return 1 | ||||||
| fi | ||||||
| if run_with_timeout 5 "$runtime" info; then | ||||||
| return 0 | ||||||
| fi | ||||||
| return 1 | ||||||
| } | ||||||
|
|
||||||
| # --- Main --- | ||||||
|
|
||||||
| for runtime in docker podman; do | ||||||
| if check_runtime "$runtime"; then | ||||||
| exit 0 | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| # No working runtime found — determine why and advise | ||||||
|
|
||||||
| found_binary="" | ||||||
| for runtime in docker podman; do | ||||||
| if command -v "$runtime" &>/dev/null; then | ||||||
| found_binary="$runtime" | ||||||
| break | ||||||
| fi | ||||||
| done | ||||||
|
|
||||||
| HOST_OS="$(detect_os)" | ||||||
|
|
||||||
| echo "" | ||||||
| echo "╔══════════════════════════════════════════════════════════════╗" | ||||||
| echo "║ CodeForge: Container runtime not available ║" | ||||||
| echo "╚══════════════════════════════════════════════════════════════╝" | ||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| echo "" | ||||||
|
|
||||||
| if [[ -n "$found_binary" ]]; then | ||||||
| echo " Found '$found_binary' but the daemon is not responding." | ||||||
| echo "" | ||||||
| case "$HOST_OS" in | ||||||
| wsl) | ||||||
| echo " Fix: Start Docker Desktop and enable WSL 2 integration:" | ||||||
| echo " Settings → Resources → WSL Integration" | ||||||
| ;; | ||||||
| macos) | ||||||
| echo " Fix: Start Docker Desktop:" | ||||||
| echo " open -a Docker" | ||||||
| ;; | ||||||
| linux) | ||||||
| echo " Fix: Start the Docker daemon:" | ||||||
| echo " sudo systemctl start docker" | ||||||
| ;; | ||||||
| esac | ||||||
| else | ||||||
| echo " No container runtime (docker or podman) found in PATH." | ||||||
| echo "" | ||||||
| echo " Install Docker Desktop:" | ||||||
| echo " https://www.docker.com/products/docker-desktop/" | ||||||
| echo "" | ||||||
| echo " Or install Podman:" | ||||||
| echo " https://podman.io/getting-started/installation" | ||||||
| fi | ||||||
|
|
||||||
| echo "" | ||||||
| exit 1 | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: AnExiledDev/CodeForge
Length of output: 6737
🏁 Script executed:
Repository: AnExiledDev/CodeForge
Length of output: 282
CHANGELOG.md entry confirmed; add
initializeCommanddocumentation to CLAUDE.md.The CHANGELOG.md entry for the container runtime pre-flight check exists and is well-formatted under "### Added → #### Startup" (lines 17–18). However, per project learnings, config system changes must be reflected in
.devcontainer/CLAUDE.md. TheinitializeCommandconfiguration change is not currently documented there.🤖 Prompt for AI Agents