Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: use new image detail type
Kyle Mendell63f821186d10
diff --git a/backend/internal/api/image_handler.go b/backend/internal/api/image_handler.goindex 3d7894487..93ec08a32 100644--- a/backend/internal/api/image_handler.go+++ b/backend/internal/api/image_handler.go@@ -61,18 +61,15 @@ func (h *ImageHandler) List(c *gin.Context) {func (h *ImageHandler) GetByID(c *gin.Context) {id := c.Param("imageId")- image, err := h.imageService.GetImageByID(c.Request.Context(), id)+ img, err := h.imageService.GetImageByID(c.Request.Context(), id)if err != nil {- c.JSON(http.StatusNotFound, gin.H{- "success": false,- "error": err.Error(),- })+ c.JSON(http.StatusNotFound, gin.H{"success": false, "error": err.Error()})return}c.JSON(http.StatusOK, gin.H{"success": true,- "data": image,+ "data": dto.NewImageDetailSummaryDto(img),})}diff --git a/backend/internal/dto/image_dto.go b/backend/internal/dto/image_dto.goindex 734772fcc..c0512aaba 100644--- a/backend/internal/dto/image_dto.go+++ b/backend/internal/dto/image_dto.go@@ -1,8 +1,10 @@package dtoimport (+ "strings""time"+ "github.com/docker/docker/api/types/image""github.com/ofkm/arcane-backend/internal/models")@@ -78,3 +80,106 @@ func NewImageSummaryDto(m *models.Image) ImageSummaryDto {UpdateInfo: update,}}++type ImageDetailSummaryDto struct {+ Id string `json:"id"`+ RepoTags []string `json:"repoTags"`+ RepoDigests []string `json:"repoDigests"`+ Parent string `json:"parent"`+ Comment string `json:"comment"`+ Created string `json:"created"`+ DockerVersion string `json:"dockerVersion"`+ Author string `json:"author"`+ Config struct {+ ExposedPorts map[string]struct{} `json:"exposedPorts,omitempty"`+ Env []string `json:"env,omitempty"`+ Cmd []string `json:"cmd,omitempty"`+ Volumes map[string]struct{} `json:"volumes,omitempty"`+ WorkingDir string `json:"workingDir,omitempty"`+ ArgsEscaped bool `json:"argsEscaped,omitempty"`+ } `json:"config"`+ Architecture string `json:"architecture"`+ Os string `json:"os"`+ Size int64 `json:"size"`+ GraphDriver struct {+ Data any `json:"data"`+ Name string `json:"name"`+ } `json:"graphDriver"`+ RootFs struct {+ Type string `json:"type"`+ Layers []string `json:"layers"`+ } `json:"rootFs"`+ Metadata struct {+ LastTagTime string `json:"lastTagTime"`+ } `json:"metadata"`+ Descriptor struct {+ MediaType string `json:"mediaType"`+ Digest string `json:"digest"`+ Size int64 `json:"size"`+ } `json:"descriptor"`+}++func NewImageDetailSummaryDto(src *image.InspectResponse) ImageDetailSummaryDto {+ var out ImageDetailSummaryDto++ out.Id = src.ID+ out.RepoTags = append(out.RepoTags, src.RepoTags...)+ out.RepoDigests = append(out.RepoDigests, src.RepoDigests...)+ out.Parent = src.Parent+ out.Comment = src.Comment+ out.Created = src.Created+ out.DockerVersion = src.DockerVersion+ out.Author = src.Author++ if src.Config != nil {+ if len(src.Config.ExposedPorts) > 0 {+ out.Config.ExposedPorts = make(map[string]struct{}, len(src.Config.ExposedPorts))+ for p := range src.Config.ExposedPorts {+ out.Config.ExposedPorts[string(p)] = struct{}{}+ }+ }+ if len(src.Config.Env) > 0 {+ out.Config.Env = append(out.Config.Env, src.Config.Env...)+ }+ if len(src.Config.Cmd) > 0 {+ out.Config.Cmd = append(out.Config.Cmd, src.Config.Cmd...)+ }+ if len(src.Config.Volumes) > 0 {+ out.Config.Volumes = make(map[string]struct{}, len(src.Config.Volumes))+ for v := range src.Config.Volumes {+ out.Config.Volumes[v] = struct{}{}+ }+ }+ out.Config.WorkingDir = src.Config.WorkingDir+ out.Config.ArgsEscaped = src.Config.ArgsEscaped+ }++ out.Architecture = src.Architecture+ out.Os = src.Os+ out.Size = src.Size++ out.GraphDriver.Name = src.GraphDriver.Name+ if src.GraphDriver.Data != nil {+ out.GraphDriver.Data = src.GraphDriver.Data+ }++ out.RootFs.Type = src.RootFS.Type+ if len(src.RootFS.Layers) > 0 {+ out.RootFs.Layers = append(out.RootFs.Layers, src.RootFS.Layers...)+ }++ if !src.Metadata.LastTagTime.IsZero() {+ out.Metadata.LastTagTime = src.Metadata.LastTagTime.Format(time.RFC3339Nano)+ }++ // Best-effort descriptor from first digest+ out.Descriptor.MediaType = "application/vnd.oci.image.index.v1+json"+ if len(src.RepoDigests) > 0 {+ parts := strings.SplitN(src.RepoDigests[0], "@", 2)+ if len(parts) == 2 {+ out.Descriptor.Digest = parts[1]+ }+ }++ return out+}diff --git a/backend/internal/services/image_service.go b/backend/internal/services/image_service.goindex 002fc64aa..8fd575d70 100644--- a/backend/internal/services/image_service.go+++ b/backend/internal/services/image_service.go@@ -489,34 +489,6 @@ func (s *ImageService) DeleteImageByDockerID(ctx context.Context, dockerImageIDreturn nil}-// func (s *ImageService) ListImagesWithUpdatesPaginated(ctx context.Context, req utils.SortedPaginationRequest) ([]dto.ImageSummaryDto, utils.PaginationResponse, error) {-// _, err := s.ListImages(ctx)-// if err != nil {-// return nil, utils.PaginationResponse{}, fmt.Errorf("failed to list and sync Docker images: %w", err)-// }--// var images []models.Image-// query := s.db.WithContext(ctx).Model(&models.Image{}).Preload("UpdateRecord")--// if req.Sort.Column != "" {-// dir := utils.NormalizeSortDirection(req.Sort.Direction)-// col := utils.CamelCaseToSnakeCase(req.Sort.Column)-// query = query.Order(col + " " + dir)-// }--// pagination, err := utils.PaginateAndSort(req, query, &images)-// if err != nil {-// return nil, utils.PaginationResponse{}, fmt.Errorf("failed to paginate images: %w", err)-// }--// result := make([]dto.ImageSummaryDto, 0, len(images))-// for _, img := range images {-// result = append(result, dto.NewImageSummaryDto(&img))-// }--// return result, pagination, nil-// }-func (s *ImageService) ListImagesWithUpdatesPaginated(ctx context.Context, req utils.SortedPaginationRequest) ([]dto.ImageSummaryDto, utils.PaginationResponse, error) {_, err := s.ListImages(ctx)if err != nil {diff --git a/frontend/src/lib/types/image.type.ts b/frontend/src/lib/types/image.type.tsindex 383e37b26..9004075df 100644--- a/frontend/src/lib/types/image.type.ts+++ b/frontend/src/lib/types/image.type.ts@@ -23,3 +23,41 @@ export interface ImageSummaryDto {tag: string;updateInfo?: ImageUpdateInfoDto;}++export interface ImageDetailSummaryDto {+ id: string;+ repoTags: string[];+ repoDigests: string[];+ parent: string;+ comment: string;+ created: string; // ISO string+ dockerVersion: string;+ author: string;+ config: {+ exposedPorts?: Record<string, unknown>;+ env?: string[];+ cmd?: string[];+ volumes?: Record<string, unknown>;+ workingDir?: string;+ argsEscaped?: boolean;+ };+ architecture: string;+ os: string;+ size: number;+ graphDriver: {+ data: unknown | null;+ name: string;+ };+ rootFs: {+ type: string;+ layers: string[];+ };+ metadata: {+ lastTagTime: string;+ };+ descriptor: {+ mediaType: string;+ digest: string;+ size: number;+ };+}diff --git a/frontend/src/routes/images/[imageId]/+page.svelte b/frontend/src/routes/images/[imageId]/+page.svelteindex 9a4d625e2..7e7506eb4 100644--- a/frontend/src/routes/images/[imageId]/+page.svelte+++ b/frontend/src/routes/images/[imageId]/+page.svelte@@ -24,14 +24,14 @@refreshing: false});- const shortId = $derived(image?.Id?.split(':')[1]?.substring(0, 12) || 'N/A');+ const shortId = $derived(image?.id?.split(':')[1]?.substring(0, 12) || 'N/A');const createdDate = $derived(() => {- if (!image?.Created) {+ if (!image?.created) {return 'N/A';}try {- const date = new Date(image.Created);+ const date = new Date(image.created);if (isNaN(date.getTime())) {return 'N/A';}@@ -41,9 +41,9 @@}});- const imageSize = $derived(formatBytes(image?.Size || 0));- const architecture = $derived(image?.Architecture || 'N/A');- const osName = $derived(image?.Os || 'N/A');+ const imageSize = $derived(formatBytes(image?.size || 0));+ const architecture = $derived(image?.architecture || 'N/A');+ const osName = $derived(image?.os || 'N/A');async function handleImageRemove(id: string) {openConfirmDialog({@@ -84,7 +84,7 @@</Breadcrumb.Root><div class="mt-2 flex items-center gap-2"><h1 class="text-2xl font-bold tracking-tight break-all">- {image?.RepoTags?.[0] || shortId}+ {image?.repoTags?.[0] || shortId}</h1></div></div>@@ -92,7 +92,7 @@<div class="flex flex-wrap gap-2"><ArcaneButtonaction="remove"- onClick={() => handleImageRemove(image.Id)}+ onClick={() => handleImageRemove(image.id)}loading={isLoading.removing}disabled={isLoading.removing}size="sm"@@ -117,7 +117,7 @@</div><div class="min-w-0 flex-1"><p class="text-muted-foreground text-sm font-medium">ID</p>- <p class="mt-1 truncate text-base font-semibold" title={image.Id}>{shortId}</p>+ <p class="mt-1 truncate text-base font-semibold" title={image.id}>{shortId}</p></div></div>@@ -177,7 +177,7 @@</Card.Root><!-- Tags Card -->- {#if image.RepoTags && image.RepoTags.length > 0}+ {#if image.repoTags && image.repoTags.length > 0}<Card.Root class="border shadow-sm"><Card.Header><Card.Title class="flex items-center gap-2"@@ -186,7 +186,7 @@</Card.Header><Card.Content><div class="flex flex-wrap gap-2">- {#each image.RepoTags as tag (tag)}+ {#each image.repoTags as tag (tag)}<Badge variant="secondary">{tag}</Badge>{/each}</div>@@ -194,36 +194,14 @@</Card.Root>{/if}- <!-- Labels Card -->- {#if image.Config?.Labels && Object.keys(image.Config.Labels).length > 0}- <Card.Root class="border shadow-sm">- <Card.Header>- <Card.Title>Labels</Card.Title>- </Card.Header>- <Card.Content class="space-y-2">- {#each Object.entries(image.Config.Labels) as [key, value] (key)}- <div class="flex flex-col text-sm sm:flex-row sm:items-center">- <span class="text-muted-foreground w-full font-medium break-all sm:w-1/4"- >{key}:</span- >- <span class="w-full font-mono text-xs break-all sm:w-3/4 sm:text-sm">{value}</span>- </div>- {#if !Object.is(Object.keys(image.Config.Labels).length - 1, Object.keys(image.Config.Labels).indexOf(key))}- <Separator class="my-2" />- {/if}- {/each}- </Card.Content>- </Card.Root>- {/if}-<!-- Environment Variables Card -->- {#if image.Config?.Env && image.Config.Env.length > 0}+ {#if image.config?.env && image.config.env.length > 0}<Card.Root class="border shadow-sm"><Card.Header><Card.Title>Environment Variables</Card.Title></Card.Header><Card.Content class="space-y-2">- {#each image.Config.Env as env (env)}+ {#each image.config.env as env (env)}{@const [key, ...valueParts] = env.split('=')}{@const value = valueParts.join('=')}<div class="flex flex-col text-sm sm:flex-row sm:items-center">@@ -232,7 +210,7 @@><span class="w-full font-mono text-xs break-all sm:w-3/4 sm:text-sm">{value}</span></div>- {#if env !== image.Config.Env[image.Config.Env.length - 1]}+ {#if env !== image.config.env[image.config.env.length - 1]}<Separator class="my-2" />{/if}{/each}diff --git a/frontend/src/routes/images/[imageId]/+page.ts b/frontend/src/routes/images/[imageId]/+page.tsindex c4f264c20..b68ebce35 100644--- a/frontend/src/routes/images/[imageId]/+page.ts+++ b/frontend/src/routes/images/[imageId]/+page.ts@@ -1,9 +1,9 @@import { environmentAPI } from '$lib/services/api';-import type { EnhancedImageInfo } from '$lib/models/image.type';+import type { ImageDetailSummaryDto } from '$lib/types/image.type.js';import { error } from '@sveltejs/kit';type ImageDetailData = {- image: EnhancedImageInfo;+ image: ImageDetailSummaryDto;error?: string;};