Files
zeekay 0c7efccf40 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

46 lines
1.0 KiB
Go

// Copyright 2025 Hanzo Industries Inc.
// SPDX-License-Identifier: AGPL-3.0
package docker
import (
"context"
"fmt"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/client"
)
func ImageExistsLocally(ctx context.Context, dockerClient *client.Client, imageName string) (bool, error) {
images, err := dockerClient.ImageList(ctx, image.ListOptions{})
if err != nil {
return false, fmt.Errorf("failed to list images: %w", err)
}
for _, image := range images {
for _, tag := range image.RepoTags {
if tag == imageName {
return true, nil
}
}
}
return false, nil
}
func CheckAmdArchitecture(ctx context.Context, dockerClient *client.Client, imageName string) (bool, error) {
inspect, _, err := dockerClient.ImageInspectWithRaw(ctx, imageName)
if err != nil {
return false, fmt.Errorf("failed to inspect image: %w", err)
}
x64Architectures := []string{"amd64", "x86_64"}
for _, arch := range x64Architectures {
if inspect.Architecture == arch {
return true, nil
}
}
return false, nil
}