Skip to content

Commit 4cb4617

Browse files
Merge pull request #21 from rwilliamspbg-ops/fix/devcontainer-gui-fullstack-launch
Fix devcontainer reliability and enable one-click full-stack desktop GUI launch
2 parents 0c743d7 + 17c1080 commit 4cb4617

14 files changed

Lines changed: 568 additions & 84 deletions

.devcontainer/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ ENV DEBIAN_FRONTEND=noninteractive
44

55
RUN apt-get update && apt-get install -y --no-install-recommends \
66
build-essential cmake git ca-certificates wget curl pkg-config \
7-
python3 python3-pip python3-venv python3-dev ca-certificates \
8-
libssl-dev libffi-dev && \
7+
python3 python3-pip python3-venv python3-dev python-is-python3 \
8+
sudo lsof net-tools \
9+
libssl-dev libffi-dev \
10+
libgl1 libegl1 libxkbcommon-x11-0 libdbus-1-3 xauth && \
911
rm -rf /var/lib/apt/lists/*
1012

1113
# Install liboqs from source
1214
WORKDIR /opt
1315
RUN git clone --depth 1 https://github.com/open-quantum-safe/liboqs.git && \
1416
mkdir -p liboqs/build && cd liboqs/build && \
1517
cmake -DCMAKE_BUILD_TYPE=Release .. && \
16-
make -j"$(nproc)" && make install
18+
make -j"$(nproc)" && make install && ldconfig
1719

1820
# Ensure pip is upgraded and install Python oqs wrapper
1921
RUN python3 -m pip install --upgrade pip setuptools wheel && \

.devcontainer/devcontainer.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
"build": {
44
"dockerfile": "Dockerfile"
55
},
6-
"workspaceFolder": "/workspace",
6+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
7+
"features": {
8+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
9+
},
710
"settings": {},
8-
"extensions": [],
11+
"extensions": [
12+
"ms-python.python",
13+
"ms-python.vscode-pylance",
14+
"ms-azuretools.vscode-docker"
15+
],
916
"forwardPorts": [8003],
10-
"postCreateCommand": "./.devcontainer/post_create.sh"
17+
"postCreateCommand": "bash .devcontainer/post_create.sh"
1118
}

.devcontainer/post_create.sh

Lines changed: 93 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,96 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
echo "Running devcontainer post-create: install build deps and liboqs"
5-
# install system deps (attempt apt, then apk)
6-
if command -v apt-get >/dev/null 2>&1; then
7-
sudo apt-get update
8-
sudo apt-get install -y build-essential cmake git python3-dev python3-pip pkg-config
9-
elif command -v apk >/dev/null 2>&1; then
10-
sudo apk add --no-cache build-base cmake git python3 python3-dev py3-pip pkgconfig
11-
else
12-
echo "Unknown package manager; please install build tools (cmake, make, git, python3-dev) manually"
13-
fi
14-
15-
CACHE_DIR="$HOME/.cache/liboqs"
16-
mkdir -p "$CACHE_DIR"
17-
if [ ! -d "$CACHE_DIR/liboqs" ]; then
18-
git clone --depth 1 https://github.com/open-quantum-safe/liboqs.git "$CACHE_DIR/liboqs"
19-
fi
20-
21-
pushd "$CACHE_DIR/liboqs"
22-
mkdir -p build && cd build
23-
cmake -DCMAKE_BUILD_TYPE=Release ..
24-
make -j"$(nproc)"
25-
if command -v sudo >/dev/null 2>&1; then
26-
sudo make install
27-
else
28-
make install
29-
fi
30-
popd
31-
32-
# ensure pip and install oqs python package
33-
python3 -m pip install --upgrade pip || true
34-
python3 -m pip install oqs || true
35-
36-
echo "post-create complete"
4+
echo "[devcontainer] Running post-create setup"
5+
6+
run_as_root() {
7+
if [ "$(id -u)" -eq 0 ]; then
8+
"$@"
9+
elif command -v sudo >/dev/null 2>&1; then
10+
sudo "$@"
11+
else
12+
echo "[WARN] Need root privileges for: $*"
13+
return 1
14+
fi
15+
}
16+
17+
install_system_deps() {
18+
if command -v apt-get >/dev/null 2>&1; then
19+
run_as_root apt-get update
20+
run_as_root apt-get install -y \
21+
build-essential cmake git python3-dev python3-pip python3-venv pkg-config \
22+
libgl1 libegl1 libxkbcommon-x11-0 libdbus-1-3 lsof net-tools
23+
elif command -v apk >/dev/null 2>&1; then
24+
run_as_root apk add --no-cache \
25+
build-base cmake git python3 python3-dev py3-pip py3-virtualenv pkgconfig \
26+
mesa-gl libxkbcommon dbus-libs lsof net-tools
27+
else
28+
echo "[WARN] Unsupported package manager; skipping system package install"
29+
fi
30+
}
31+
32+
ensure_liboqs() {
33+
if [ "${MOHAWK_SKIP_LIBOQS_BUILD:-0}" = "1" ]; then
34+
echo "[devcontainer] Skipping liboqs build (MOHAWK_SKIP_LIBOQS_BUILD=1)"
35+
return
36+
fi
37+
38+
if pkg-config --exists liboqs 2>/dev/null || [ -f /usr/local/lib/liboqs.so ] || [ -f /usr/local/lib64/liboqs.so ]; then
39+
echo "[devcontainer] liboqs already installed"
40+
return
41+
fi
42+
43+
echo "[devcontainer] liboqs not found; building from source"
44+
local cache_dir="$HOME/.cache/liboqs"
45+
mkdir -p "$cache_dir"
46+
47+
if [ ! -d "$cache_dir/liboqs/.git" ]; then
48+
rm -rf "$cache_dir/liboqs"
49+
git clone --depth 1 https://github.com/open-quantum-safe/liboqs.git "$cache_dir/liboqs"
50+
fi
51+
52+
pushd "$cache_dir/liboqs" >/dev/null
53+
mkdir -p build
54+
cd build
55+
cmake -DCMAKE_BUILD_TYPE=Release ..
56+
make -j"$(nproc)"
57+
run_as_root make install
58+
run_as_root ldconfig || true
59+
popd >/dev/null
60+
}
61+
62+
install_python_deps() {
63+
if [ "${MOHAWK_SKIP_PY_DEPS:-0}" = "1" ]; then
64+
echo "[devcontainer] Skipping Python dependency install (MOHAWK_SKIP_PY_DEPS=1)"
65+
return
66+
fi
67+
68+
cd "${WORKSPACE_FOLDER:-$PWD}"
69+
if [ ! -f requirements.txt ]; then
70+
echo "[WARN] requirements.txt not found; skipping Python dependency install"
71+
return
72+
fi
73+
74+
if [ ! -d .venv ]; then
75+
python3 -m venv .venv
76+
fi
77+
78+
# shellcheck disable=SC1091
79+
source .venv/bin/activate
80+
python -m pip install --upgrade pip setuptools wheel
81+
python -m pip install -r requirements.txt
82+
83+
# Optional OQS wrapper used by secure flows.
84+
python -m pip install oqs || echo "[WARN] oqs Python wrapper installation failed; continuing"
85+
86+
python - <<'PY'
87+
import fastapi, uvicorn, requests, psutil # noqa: F401
88+
print("[devcontainer] Core Python dependencies imported successfully")
89+
PY
90+
}
91+
92+
install_system_deps
93+
ensure_liboqs
94+
install_python_deps
95+
96+
echo "[devcontainer] post-create complete"

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,43 @@
22

33
All notable changes to the project will be documented in this file.
44

5+
## [2.1.1] - 2026-07-11
6+
7+
### 🔧 Devcontainer and Setup Reliability
8+
9+
- Updated `.devcontainer/devcontainer.json`:
10+
- workspace path compatibility for Codespaces
11+
- docker-outside-of-docker feature enablement
12+
- Python and Docker VS Code extension recommendations
13+
- explicit bash post-create invocation
14+
- Updated `.devcontainer/Dockerfile` with missing runtime and diagnostics packages.
15+
- Reworked `.devcontainer/post_create.sh` to be idempotent, root-safe, and configurable with:
16+
- `MOHAWK_SKIP_LIBOQS_BUILD=1`
17+
- `MOHAWK_SKIP_PY_DEPS=1`
18+
19+
### 🖥️ Full-Stack Desktop GUI Launch Improvements
20+
21+
- Fixed startup ordering in `mohawk_gui/main_window.py`:
22+
- initialize status bar before tab refresh paths
23+
- start background health thread only after UI widget initialization
24+
- Added environment-based backend URL overrides for desktop GUI runtime.
25+
- Added reusable desktop GUI launcher flow in `launch.py` for both native and Docker orchestration.
26+
- Updated `launch.sh` dependency probe to include `PyQt6`.
27+
- Added `mohawk-desktop-gui` service to `docker-compose.yml`.
28+
- Added full-stack parity services to `docker-compose.dev.yml` and adjusted conflicting host port mapping.
29+
30+
### 📚 Documentation Updates
31+
32+
- Updated `README.md` quick-start and documentation index.
33+
- Updated `QUICKSTART.md` with launcher/devcontainer paths and focused model/chat smoke checks.
34+
- Updated `DOCKER_SETUP.md` desktop GUI behavior notes and skip flag usage.
35+
- Added `INSTALL.md` and `SETUP.md` for clear install/runtime guidance.
36+
37+
### ✅ Validation
38+
39+
- End-to-end functional test executed: `python test_user_functions.py`.
40+
- Result: `33/33 passed (100.0%)` including model list/load and chat inference paths.
41+
542
## [2.1.0] - 2024-01-15
643

744
### 🎉 Major Release: Professional Dashboard with LM Studio Features

DOCKER_SETUP.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,21 @@ The GUI window will open and connect to the Docker-based backend services.
7171
|---------|------|----------|---------|
7272
| mohawk-gui | 8003 | Docker Container | Backend API & health endpoints |
7373
| mohawk-worker | 8004 | Docker Container | Inference worker service |
74+
| mohawk-desktop-gui | n/a | Docker Container | Desktop GUI launcher (display-dependent) |
7475
| PyQt6 GUI | (Local) | Your Machine | Desktop application interface |
7576

77+
## Desktop GUI Launch Behavior
78+
79+
- `docker compose up -d --build` includes `mohawk-desktop-gui` for one-click full-stack startup.
80+
- If `DISPLAY` is not set, the desktop GUI service exits cleanly and backend APIs continue running.
81+
- `launch.py` sets `MOHAWK_SKIP_DESKTOP_GUI=1` when orchestrating compose to avoid duplicate GUI instances, then launches host desktop GUI directly when supported.
82+
83+
Skip container desktop GUI explicitly:
84+
85+
```bash
86+
MOHAWK_SKIP_DESKTOP_GUI=1 docker compose up -d --build
87+
```
88+
7689
## Container Management
7790

7891
### View Container Logs

INSTALL.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Mohawk Inference Engine - Install Guide
2+
3+
## Prerequisites
4+
5+
- Python 3.10+
6+
- Git
7+
- Docker + Docker Compose (recommended for full stack)
8+
- Linux/macOS shell or PowerShell on Windows
9+
10+
For desktop GUI launch on Linux, ensure display libraries and `DISPLAY` are available.
11+
12+
## Clone
13+
14+
```bash
15+
git clone https://github.com/rwilliamspbg-ops/Mohawk-Inference-Engine.git
16+
cd Mohawk-Inference-Engine
17+
```
18+
19+
## Python Environment
20+
21+
```bash
22+
python3 -m venv .venv
23+
source .venv/bin/activate
24+
pip install --upgrade pip
25+
pip install -r requirements.txt
26+
```
27+
28+
Windows PowerShell:
29+
30+
```powershell
31+
python -m venv .venv
32+
.\.venv\Scripts\Activate.ps1
33+
pip install --upgrade pip
34+
pip install -r requirements.txt
35+
```
36+
37+
## Optional: Devcontainer
38+
39+
In VS Code:
40+
- Dev Containers: Rebuild and Reopen in Container
41+
42+
Then run:
43+
44+
```bash
45+
bash .devcontainer/post_create.sh
46+
```
47+
48+
Fast smoke mode:
49+
50+
```bash
51+
MOHAWK_SKIP_LIBOQS_BUILD=1 MOHAWK_SKIP_PY_DEPS=1 bash .devcontainer/post_create.sh
52+
```
53+
54+
## Verify Install
55+
56+
```bash
57+
python - <<'PY'
58+
import fastapi, uvicorn, requests, psutil
59+
print('Core dependencies OK')
60+
PY
61+
```
62+
63+
## Next
64+
65+
- Go to `SETUP.md` for runtime startup options.
66+
- Go to `QUICKSTART.md` for API smoke tests.

QUICKSTART.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ Mohawk is a production-grade AI inference engine with:
1515

1616
---
1717

18-
## Quick Start (Docker)
18+
## Quick Start Paths
19+
20+
### A) One-Click Launcher
21+
22+
```bash
23+
./launch.sh
24+
```
25+
26+
Use menu option 1 (Docker stack) or option 2 (Native host processes). The launcher now attempts to auto-open the desktop GUI when the runtime supports display output.
27+
28+
### B) Docker Full Stack
1929

2030
### 1. Start All Services
2131

@@ -27,6 +37,12 @@ docker compose up -d
2737
docker ps
2838
```
2939

40+
Optional: skip container desktop GUI service when running from raw compose.
41+
42+
```bash
43+
MOHAWK_SKIP_DESKTOP_GUI=1 docker compose up -d --build
44+
```
45+
3046
**Expected Output:**
3147
```
3248
CONTAINER ID IMAGE STATUS PORTS
@@ -47,6 +63,21 @@ curl http://localhost:8004/health
4763
# {"status":"healthy","service":"...","timestamp":"2026-06-24T..."}
4864
```
4965

66+
### C) Devcontainer
67+
68+
```bash
69+
# In VS Code:
70+
# Dev Containers: Rebuild and Reopen in Container
71+
72+
bash .devcontainer/post_create.sh
73+
```
74+
75+
Fast smoke setup without expensive rebuild steps:
76+
77+
```bash
78+
MOHAWK_SKIP_LIBOQS_BUILD=1 MOHAWK_SKIP_PY_DEPS=1 bash .devcontainer/post_create.sh
79+
```
80+
5081
### 3. List Available Models
5182

5283
```bash
@@ -179,6 +210,23 @@ python test_user_functions.py
179210
# SUMMARY: 33/33 passed (100.0%)
180211
```
181212

213+
### Validate Model Select + Chat Inference Only
214+
215+
```bash
216+
# List models
217+
curl http://localhost:8003/api/models
218+
219+
# Load model
220+
curl -X POST http://localhost:8003/api/models/load \
221+
-H "Content-Type: application/json" \
222+
-d '{"model": "Llama-3-8B-Instruct-Q4_K_M"}'
223+
224+
# Run chat inference
225+
curl -X POST http://localhost:8003/api/inference/chat \
226+
-H "Content-Type: application/json" \
227+
-d '{"message":"Hello from smoke test","temperature":0.7,"top_p":0.9,"max_tokens":128}'
228+
```
229+
182230
### View Logs
183231

184232
```bash

0 commit comments

Comments
 (0)