-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement docker container manager mvp #25
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 1 commit
fc3a1c4
8aecd50
a49fa31
ec2c9c7
e5bd3b2
e54c3f6
9e72a1b
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,228 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PostgresContainerConfig, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DockerContainer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CreateContainerResult, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContainerActionResult, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RemoveContainerOptions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "../types"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| POSTGRES_IMAGE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| POSTGRES_CONTAINER_PORT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MANAGED_LABEL_KEY, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MANAGED_LABEL_VALUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "../constants"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { validateContainerName, generateVolumeName } from "../utilities/container-naming"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkDockerAvailability, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| listContainers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getContainerDetails, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| startContainer as clientStartContainer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stopContainer as clientStopContainer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| restartContainer as clientRestartContainer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| removeContainer as clientRemoveContainer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pullImage, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| imageExists, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "./docker-client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async function executeDockerCommand(args: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof window !== "undefined" && "Tauri" in window) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { Command } = await import("@tauri-apps/plugin-shell"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const command = Command.create("docker", args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const output = await command.execute(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stdout: output.stdout, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stderr: output.stderr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exitCode: output.code ?? 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error("Docker commands require Tauri shell plugin"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async function executeDockerCommand(args: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> { | |
| if (typeof window !== "undefined" && "Tauri" in window) { | |
| const { Command } = await import("@tauri-apps/plugin-shell"); | |
| const command = Command.create("docker", args); | |
| const output = await command.execute(); | |
| return { | |
| stdout: output.stdout, | |
| stderr: output.stderr, | |
| exitCode: output.code ?? 0, | |
| }; | |
| } | |
| throw new Error("Docker commands require Tauri shell plugin"); | |
| } | |
| async function executeDockerCommand(args: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> { | |
| if (typeof window !== "undefined" && "Tauri" in window) { | |
| const { Command } = await import("@tauri-apps/plugin-shell"); | |
| const command = Command.create("docker", args); | |
| const output = await command.execute(); | |
| return { | |
| stdout: output.stdout, | |
| stderr: output.stderr, | |
| exitCode: output.code ?? -1, // Treat null as failure | |
| }; | |
| } | |
| throw new Error("Docker commands require Tauri shell plugin"); | |
| } |
🤖 Prompt for AI Agents
In `@apps/desktop/src/features/docker-manager/api/container-service.ts` around
lines 27 - 40, The current executeDockerCommand function treats a null
output.code as success by falling back to 0; change this so a null exit code is
treated as failure: inside executeDockerCommand, detect when output.code is null
(output.code === null || output.code === undefined) and either throw a
descriptive Error that includes the command args, output.stdout and
output.stderr, or set exitCode to a non-zero sentinel (e.g., -1) and mark the
call as failed; update the returned object or thrown error accordingly so
callers of executeDockerCommand can reliably detect a non-normal termination.
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.
suggestion: Avoid duplicating
executeDockerCommandimplementation between client modules.This implementation duplicates the version in
docker-client.ts, which risks behavior drift (env, error handling, logging). Prefer reusing that helper directly or extracting it to a shared module so all Docker callers stay aligned.