mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
- Add main Dockerfile for production builds - Add Dockerfile.runtime for secure code execution - Add Dockerfile.runtime.fixed with improved configuration - Include .dockerignore for build optimization - Add integration documentation and publishing guides - Update API and CLI components for better runtime support - Enhance sandbox and container management features
43 lines
829 B
Go
43 lines
829 B
Go
// Copyright 2025 Hanzo Industries Inc.
|
|
// SPDX-License-Identifier: AGPL-3.0
|
|
|
|
package docker
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/docker/docker/api/types/image"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func (d *DockerClient) ImageExists(ctx context.Context, imageName string, includeLatest bool) (bool, error) {
|
|
imageName = strings.Replace(imageName, "docker.io/", "", 1)
|
|
|
|
if strings.HasSuffix(imageName, ":latest") && !includeLatest {
|
|
return false, nil
|
|
}
|
|
|
|
images, err := d.apiClient.ImageList(ctx, image.ListOptions{})
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
found := false
|
|
for _, image := range images {
|
|
for _, tag := range image.RepoTags {
|
|
if strings.HasPrefix(tag, imageName) {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
if found {
|
|
log.Infof("Image %s already pulled", imageName)
|
|
}
|
|
|
|
return found, nil
|
|
}
|