Skip to content

Commit 5241be1

Browse files
committed
Implement loading Docker images from local folder in airgap mode
1 parent e29287e commit 5241be1

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

installer/docker/stack.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,31 @@ func StackUP(tag string) error {
116116
fmt.Println(" [OK]")
117117
}
118118
} else {
119-
// TODO: Implement unzip images from local folder
119+
fmt.Println(" Loading images from local folder (airgap mode):")
120+
loadedImages := make(map[string]bool)
121+
122+
for _, service := range compose.Services {
123+
imageName := *service.Image
124+
imageName = strings.ReplaceAll(imageName, "${UTMSTACK_TAG}", tag)
125+
parts := strings.Split(imageName, "/")
126+
shortName := parts[len(parts)-1]
127+
shortName = strings.ReplaceAll(shortName, ":"+tag, "")
128+
tarPattern := fmt.Sprintf("utmstack-%s-%s-enterprise.tar", shortName, strings.ReplaceAll(tag, ".", "_"))
129+
tarPath := filepath.Join(config.ImagesPath, tarPattern)
130+
if loadedImages[shortName] {
131+
continue // Skip if already loaded
132+
}
133+
if _, err := os.Stat(tarPath); err == nil {
134+
fmt.Printf(" Importing %s...", tarPath)
135+
if err := utils.RunCmd("docker", "load", "-i", tarPath); err != nil {
136+
return fmt.Errorf("failed to load image from %s: %w", tarPath, err)
137+
}
138+
fmt.Println(" [OK]")
139+
loadedImages[shortName] = true
140+
} else {
141+
return fmt.Errorf("required image archive not found: %s", tarPath)
142+
}
143+
}
120144
}
121145

122146
env := []string{"UTMSTACK_TAG=" + tag}

0 commit comments

Comments
 (0)