@@ -26,6 +26,14 @@ def cached_dependencies
2626
2727 lifecycle_bundle_key = :"cnb/#{ @stack } "
2828 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+
2937 raise InvalidStack . new ( "no compiler defined for requested stack '#{ @stack } '" ) unless lifecycle_bundle
3038
3139 [
@@ -38,6 +46,11 @@ def cached_dependencies
3846 end
3947
4048 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+
4154 @stack_obj ||= Stack . find ( name : @stack )
4255 raise CloudController ::Errors ::ApiError . new_from_details ( 'StackNotFound' , @stack ) unless @stack_obj
4356
@@ -65,9 +78,22 @@ def image_layers
6578
6679 lifecycle_bundle_key = :"cnb/#{ @stack } "
6780 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+
6889 raise InvalidStack . new ( "no compiler defined for requested stack '#{ @stack } '" ) unless lifecycle_bundle
6990
7091 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
7197 raise InvalidStack . new ( "no droplet destination defined for requested stack '#{ @stack } '" ) unless destination
7298
7399 layers = [
@@ -124,6 +150,23 @@ def default_container_env
124150 ::Diego ::Bbs ::Models ::EnvironmentVariable . new ( name : 'CNB_APP_DIR' , value : '/home/vcap/workspace' )
125151 ]
126152 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
127170 end
128171 end
129172 end
0 commit comments