Files
runtime/apps/runner/pkg/docker/image_exists.go
zeekay ea80dc3638 feat: Add new Dockerfiles and improve containerization
- 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
2025-08-16 23:03:39 -05:00

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
}