@@ -26,6 +26,14 @@ def cached_dependencies
26
26
27
27
lifecycle_bundle_key = :"cnb/#{ @stack } "
28
28
lifecycle_bundle = @config . get ( :diego , :lifecycle_bundles ) [ lifecycle_bundle_key ]
29
+
30
+ # If custom stack doesn't have a bundle, use the default stack's bundle
31
+ if !lifecycle_bundle && @stack . is_a? ( String ) && is_custom_stack? ( @stack )
32
+ default_stack = Stack . default . name
33
+ lifecycle_bundle_key = :"cnb/#{ default_stack } "
34
+ lifecycle_bundle = @config . get ( :diego , :lifecycle_bundles ) [ lifecycle_bundle_key ]
35
+ end
36
+
29
37
raise InvalidStack . new ( "no compiler defined for requested stack '#{ @stack } '" ) unless lifecycle_bundle
30
38
31
39
[
@@ -38,6 +46,11 @@ def cached_dependencies
38
46
end
39
47
40
48
def root_fs
49
+ # Handle custom stacks (docker:// URLs)
50
+ if @stack . is_a? ( String ) && is_custom_stack? ( @stack )
51
+ return normalize_stack_url ( @stack )
52
+ end
53
+
41
54
@stack_obj ||= Stack . find ( name : @stack )
42
55
raise CloudController ::Errors ::ApiError . new_from_details ( 'StackNotFound' , @stack ) unless @stack_obj
43
56
@@ -65,9 +78,22 @@ def image_layers
65
78
66
79
lifecycle_bundle_key = :"cnb/#{ @stack } "
67
80
lifecycle_bundle = @config . get ( :diego , :lifecycle_bundles ) [ lifecycle_bundle_key ]
81
+
82
+ # If custom stack doesn't have a bundle, use the default stack's bundle
83
+ if !lifecycle_bundle && @stack . is_a? ( String ) && is_custom_stack? ( @stack )
84
+ default_stack = Stack . default . name
85
+ lifecycle_bundle_key = :"cnb/#{ default_stack } "
86
+ lifecycle_bundle = @config . get ( :diego , :lifecycle_bundles ) [ lifecycle_bundle_key ]
87
+ end
88
+
68
89
raise InvalidStack . new ( "no compiler defined for requested stack '#{ @stack } '" ) unless lifecycle_bundle
69
90
70
91
destination = @config . get ( :diego , :droplet_destinations ) [ @stack . to_sym ]
92
+ # For custom stacks, use a default destination if not configured
93
+ if !destination && @stack . is_a? ( String ) && is_custom_stack? ( @stack )
94
+ default_stack = Stack . default . name
95
+ destination = @config . get ( :diego , :droplet_destinations ) [ default_stack . to_sym ]
96
+ end
71
97
raise InvalidStack . new ( "no droplet destination defined for requested stack '#{ @stack } '" ) unless destination
72
98
73
99
layers = [
@@ -124,6 +150,23 @@ def default_container_env
124
150
::Diego ::Bbs ::Models ::EnvironmentVariable . new ( name : 'CNB_APP_DIR' , value : '/home/vcap/workspace' )
125
151
]
126
152
end
153
+
154
+ private
155
+
156
+ def is_custom_stack? ( stack_name )
157
+ # Check for various container registry URL formats
158
+ return true if stack_name . include? ( 'docker://' )
159
+ return true if stack_name . match? ( %r{^https?://} ) # Any https/http URL
160
+ return true if stack_name . include? ( '.' ) # Any string with a dot (likely a registry)
161
+ false
162
+ end
163
+
164
+ def normalize_stack_url ( stack_url )
165
+ return stack_url if stack_url . start_with? ( 'docker://' )
166
+ return stack_url . sub ( /^https?:\/ \/ / , 'docker://' ) if stack_url . match? ( %r{^https?://} )
167
+ return "docker://#{ stack_url } " if stack_url . include? ( '.' )
168
+ stack_url
169
+ end
127
170
end
128
171
end
129
172
end
0 commit comments