README cleanup, make compile script more robust
This commit is contained in:
parent
8abf861e18
commit
9e2660e524
2 changed files with 59 additions and 56 deletions
47
README.md
47
README.md
|
|
@ -14,8 +14,6 @@ It gives you a guided, keyboard-first TUI for common Docker operations without m
|
||||||
- Rich container display with state and forwarded ports.
|
- Rich container display with state and forwarded ports.
|
||||||
- Interactive shell handoff with clean terminal clear before/after shell transitions.
|
- Interactive shell handoff with clean terminal clear before/after shell transitions.
|
||||||
- Image operations: pull/list/delete with curated quick picks and custom image support.
|
- Image operations: pull/list/delete with curated quick picks and custom image support.
|
||||||
- Script-to-image workflow: generate Dockerfile from bash script, then optionally build.
|
|
||||||
- MySQL quick start flow with version/password/port prompts.
|
|
||||||
- Docker Engine API access through `/var/run/docker.sock` for structured list and lifecycle operations.
|
- Docker Engine API access through `/var/run/docker.sock` for structured list and lifecycle operations.
|
||||||
- Direct `fork`/`exec` process execution for CLI-backed streaming and interactive commands.
|
- Direct `fork`/`exec` process execution for CLI-backed streaming and interactive commands.
|
||||||
- Persistent container listings that retain exited containers.
|
- Persistent container listings that retain exited containers.
|
||||||
|
|
@ -55,7 +53,7 @@ sudo ./build/tux-dock
|
||||||
./compile.sh --web-test-view 9000
|
./compile.sh --web-test-view 9000
|
||||||
```
|
```
|
||||||
|
|
||||||
The web report is generated under `/tmp` and includes exact CTest output, test summaries, Docker integration output, and a text rendition of the TUI flow. It requires `nc` or `netcat`; press `Ctrl-C` to stop the server. The default port is `8095`; pass a port after `--web-test-view` to override it. `--web-test-view --no-test` is invalid. Normal test runs include a Docker integration test using `debian:forky`, so Docker must be available.
|
The web report is generated under `/tmp` and includes exact CTest output, test summaries, Docker integration output, and a text rendition of the TUI flow. It requires `nc`, `netcat`, or Nmap's `ncat`; press `Ctrl-C` to stop the server. The default port is `8095`; pass a port after `--web-test-view` to override it. `--web-test-view --no-test` is invalid. Normal test runs include a Docker integration test using `debian:forky`, so Docker must be available. On systems with 1 GB or less of available memory, the script automatically uses a smaller build configuration and a single build job.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -83,47 +81,6 @@ Current TUI actions:
|
||||||
|
|
||||||
Tux-Dock is organized around the TUI, Docker manager, Engine API client, and direct process runner:
|
Tux-Dock is organized around the TUI, Docker manager, Engine API client, and direct process runner:
|
||||||
|
|
||||||
```cpp
|
|
||||||
class DockerManager {
|
|
||||||
public:
|
|
||||||
struct ContainerInfo {
|
|
||||||
std::string id;
|
|
||||||
std::string name;
|
|
||||||
std::string status;
|
|
||||||
std::string ports;
|
|
||||||
bool running;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool checkConnection(...);
|
|
||||||
ListResult<ContainerInfo> getContainerList() const;
|
|
||||||
ListResult<ImageInfo> getImageList() const;
|
|
||||||
bool pullImage(...);
|
|
||||||
bool runContainerInteractive(...);
|
|
||||||
bool startInteractive(...);
|
|
||||||
bool startDetached(...);
|
|
||||||
bool stopContainer(...);
|
|
||||||
bool removeContainer(...);
|
|
||||||
bool deleteImage(...);
|
|
||||||
bool execShell(...);
|
|
||||||
bool execDetachedCommand(...);
|
|
||||||
};
|
|
||||||
|
|
||||||
class TuxDockApp {
|
|
||||||
public:
|
|
||||||
void Run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// TUI orchestration layer with modal busy states
|
|
||||||
void OpenInput(...);
|
|
||||||
void OpenSelect(...);
|
|
||||||
void OpenConfirm(...);
|
|
||||||
void BeginBusyOperation(...);
|
|
||||||
void RunWithRestoredIO(...);
|
|
||||||
void ExecuteSelectedAction();
|
|
||||||
// action handlers bridge UI -> DockerManager
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### Responsibilities
|
### Responsibilities
|
||||||
|
|
||||||
- `DockerEngineClient`
|
- `DockerEngineClient`
|
||||||
|
|
@ -153,7 +110,7 @@ This split keeps Docker behavior isolated while making UI behavior easier to ext
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cmake -S . -B build -DBUILD_TESTING=ON
|
cmake -S . -B build -DBUILD_TESTING=ON
|
||||||
cmake --build build -j
|
cmake --build build
|
||||||
ctest --test-dir build --output-on-failure
|
ctest --test-dir build --output-on-failure
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
72
compile.sh
72
compile.sh
|
|
@ -6,6 +6,32 @@ run_tests=1
|
||||||
web_view=0
|
web_view=0
|
||||||
web_port=8095
|
web_port=8095
|
||||||
|
|
||||||
|
memory_limit=$(cat /sys/fs/cgroup/memory.max 2>/dev/null || true)
|
||||||
|
if [ -z "$memory_limit" ] || [ "$memory_limit" = max ]; then
|
||||||
|
memory_limit=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
if [ -z "$memory_limit" ] || [ "$memory_limit" = max ] || [ "$memory_limit" -ge 9223372036854771712 ] 2>/dev/null; then
|
||||||
|
memory_limit=$(awk '/MemTotal:/ { print $2 * 1024; exit }' /proc/meminfo 2>/dev/null || true)
|
||||||
|
fi
|
||||||
|
low_ram=0
|
||||||
|
if [ -n "$memory_limit" ] && [ "$memory_limit" -le 1073741824 ] 2>/dev/null; then
|
||||||
|
low_ram=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_jobs=4
|
||||||
|
cpu_count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || true)
|
||||||
|
case "$cpu_count" in
|
||||||
|
''|*[!0-9]*) ;;
|
||||||
|
*)
|
||||||
|
if [ "$cpu_count" -lt "$build_jobs" ]; then
|
||||||
|
build_jobs=$cpu_count
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [ "$low_ram" -eq 1 ]; then
|
||||||
|
build_jobs=1
|
||||||
|
fi
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
argument=$1
|
argument=$1
|
||||||
shift
|
shift
|
||||||
|
|
@ -35,13 +61,20 @@ if [ "$web_view" -eq 1 ] && [ "$run_tests" -eq 0 ]; then
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$run_tests" -eq 1 ]; then
|
cmake_args=""
|
||||||
cmake -S . -B build -DBUILD_TESTING=ON
|
if [ "$low_ram" -eq 1 ]; then
|
||||||
else
|
cmake_args="-DCMAKE_BUILD_TYPE=MinSizeRel"
|
||||||
cmake -S . -B build -DBUILD_TESTING=OFF
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cmake --build build -j
|
if [ "$run_tests" -eq 1 ]; then
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
cmake -S . -B build -DBUILD_TESTING=ON $cmake_args
|
||||||
|
else
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
cmake -S . -B build -DBUILD_TESTING=OFF $cmake_args
|
||||||
|
fi
|
||||||
|
|
||||||
|
CMAKE_BUILD_PARALLEL_LEVEL="$build_jobs" cmake --build build
|
||||||
|
|
||||||
if [ "$run_tests" -eq 1 ]; then
|
if [ "$run_tests" -eq 1 ]; then
|
||||||
report_dir=$(mktemp -d /tmp/tux-dock-test.XXXXXX)
|
report_dir=$(mktemp -d /tmp/tux-dock-test.XXXXXX)
|
||||||
|
|
@ -146,27 +179,40 @@ if [ "$run_tests" -eq 1 ]; then
|
||||||
cat "$report"
|
cat "$report"
|
||||||
} >"$response"
|
} >"$response"
|
||||||
|
|
||||||
if command -v nc >/dev/null 2>&1; then
|
if command -v ncat >/dev/null 2>&1; then
|
||||||
|
nc_command=ncat
|
||||||
|
nc_args='-l'
|
||||||
|
nc_address='0.0.0.0'
|
||||||
|
nc_port="$web_port"
|
||||||
|
elif command -v nc >/dev/null 2>&1; then
|
||||||
nc_command=nc
|
nc_command=nc
|
||||||
|
if "$nc_command" -h 2>&1 | grep -q -- '-N'; then
|
||||||
|
nc_args='-l -N -s 0.0.0.0 -p'
|
||||||
|
else
|
||||||
|
nc_args='-l -s 0.0.0.0 -p'
|
||||||
|
fi
|
||||||
|
nc_address=''
|
||||||
|
nc_port="$web_port"
|
||||||
elif command -v netcat >/dev/null 2>&1; then
|
elif command -v netcat >/dev/null 2>&1; then
|
||||||
nc_command=netcat
|
nc_command=netcat
|
||||||
|
if "$nc_command" -h 2>&1 | grep -q -- '-N'; then
|
||||||
|
nc_args='-l -N -s 0.0.0.0 -p'
|
||||||
|
else
|
||||||
|
nc_args='-l -s 0.0.0.0 -p'
|
||||||
|
fi
|
||||||
|
nc_address=''
|
||||||
|
nc_port="$web_port"
|
||||||
else
|
else
|
||||||
printf '%s\n' "Web report generated at $report, but nc/netcat is unavailable." >&2
|
printf '%s\n' "Web report generated at $report, but nc/netcat is unavailable." >&2
|
||||||
exit "$test_status"
|
exit "$test_status"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if "$nc_command" -h 2>&1 | grep -q -- '-N'; then
|
|
||||||
nc_args='-l -N -s 0.0.0.0 -p'
|
|
||||||
else
|
|
||||||
nc_args='-l -s 0.0.0.0 -p'
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf '%s\n' "Test report: http://0.0.0.0:$web_port/"
|
printf '%s\n' "Test report: http://0.0.0.0:$web_port/"
|
||||||
printf '%s\n' "Report file: $report"
|
printf '%s\n' "Report file: $report"
|
||||||
printf '%s\n' "Press Ctrl-C to stop the server."
|
printf '%s\n' "Press Ctrl-C to stop the server."
|
||||||
while :; do
|
while :; do
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
"$nc_command" $nc_args "$web_port" <"$response"
|
"$nc_command" $nc_args ${nc_address:+"$nc_address"} "$nc_port" <"$response"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
exit "$test_status"
|
exit "$test_status"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue