Files
unraid-podman/webui/plugins/podman/include/bootstrap.php
T
maggesandClaude Sonnet 5 ca62577a8b Add GPU/macvlan passthrough, container edit/update, image prune/tag
Create Container form:
- GPU passthrough dropdown (AMD/Intel via /dev/dri detection, NVIDIA
  excluded since it needs a different runtime) - device paths strictly
  validated server-side against the host's own detected list.
- Macvlan network support: selecting a macvlan network reveals a static
  IP field and hides port mappings (meaningless once the container has
  its own LAN address), matching Unraid Docker Manager's "Custom: br0"
  behavior. Networks panel gained a matching macvlan network-creation
  flow, with the parent-interface dropdown read from Unraid's own
  network.cfg so it lists exactly what Docker Manager itself offers.

Containers panel:
- Edit: reopens the create form pre-filled from the container's current
  config (image/ports/volumes/env/network/restart policy/GPU/static IP);
  saving stops+removes the old container and recreates it under the same
  settings, since podman/Docker have no in-place "modify" API for most of
  this.
- Update: same stop/remove/recreate flow, but pulls the current image
  first. "Check for Updates" compares each in-use image's local digest
  against its origin registry (Docker Hub/GHCR/self-hosted registries all
  verified live) with no podman-side feature backing it - implemented via
  the registry's own HTTP API. A small log-modal shows progress for both
  actions instead of a silent wait.
- Fixed a real bug hit live: PodmanClient's flat 15s HTTP timeout aborted
  real image pulls/container creates mid-request; bumped to 600s (nginx
  already allows up to 640s for this plugin's requests).

Images panel:
- "Prune unused" (removes every image with zero containers referencing
  it, not just dangling ones - confirmation copy says so explicitly since
  this is more aggressive than it sounds) and per-image "Tag".

Also several real UI bugs found via live screenshots: unused-image prune
having no visible effect until reloaded, table action-button columns
drifting row to row (a bare "display:flex" on a <td> was fighting the
table layout algorithm), Templates category badges dumping raw multi-tag
strings from real Unraid templates, and low-contrast search/filter
controls that were nearly invisible against the card background.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-12 18:34:57 +00:00

39 lines
1.5 KiB
PHP

<?php
/**
* bootstrap.php
*
* Required by every file under webui/plugins/podman/ajax/ as its very
* first line. Centralizes the three things every endpoint would otherwise
* repeat: loading the other include/ modules, turning any PodmanApiException
* into the same JSON error envelope helpers.php's podman_json_error()
* produces (so the frontend never has to special-case "the socket was
* unreachable" vs. "podman returned a 404" vs. "something else threw"),
* and constructing a ready-to-use PodmanClient from the on-disk config.
*
* Usage, at the top of an ajax/*.php file:
* require __DIR__ . '/../include/bootstrap.php';
* // $client (PodmanClient) and $podmanConfig (PodmanConfig) are now set.
*/
declare(strict_types=1);
require_once __DIR__ . '/PodmanClient.php';
require_once __DIR__ . '/Config.php';
require_once __DIR__ . '/helpers.php';
require_once __DIR__ . '/RegistryClient.php';
set_exception_handler(static function (\Throwable $e): void {
if ($e instanceof PodmanApiException) {
// A 0 status means "couldn't even reach the socket" (transport
// failure) rather than an HTTP error podman itself returned —
// surfaced as 503 (Service Unavailable) since that's the more
// accurate signal to the frontend than a generic 500.
$status = $e->httpStatus > 0 ? $e->httpStatus : 503;
podman_json_error($e->getMessage(), $status);
}
podman_json_error('Internal error: ' . $e->getMessage(), 500);
});
$podmanConfig = PodmanConfig::load();
$client = $podmanConfig->newClient();