@@ -24,6 +24,11 @@ def initialize(config, opts)
2424 def cached_dependencies
2525 return nil if @config . get ( :diego , :enable_declarative_asset_downloads )
2626
27+ # Custom stacks don't need lifecycle bundles
28+ if @stack . is_a? ( String ) && is_custom_stack? ( @stack )
29+ return nil
30+ end
31+
2732 lifecycle_bundle_key = :"cnb/#{ @stack } "
2833 lifecycle_bundle = @config . get ( :diego , :lifecycle_bundles ) [ lifecycle_bundle_key ]
2934 raise InvalidStack . new ( "no compiler defined for requested stack '#{ @stack } '" ) unless lifecycle_bundle
@@ -38,6 +43,11 @@ def cached_dependencies
3843 end
3944
4045 def root_fs
46+ # Handle custom stacks (docker:// URLs)
47+ if @stack . is_a? ( String ) && is_custom_stack? ( @stack )
48+ return normalize_stack_url ( @stack )
49+ end
50+
4151 @stack_obj ||= Stack . find ( name : @stack )
4252 raise CloudController ::Errors ::ApiError . new_from_details ( 'StackNotFound' , @stack ) unless @stack_obj
4353
@@ -63,22 +73,27 @@ def setup
6373 def image_layers
6474 return [ ] unless @config . get ( :diego , :enable_declarative_asset_downloads )
6575
66- lifecycle_bundle_key = :"cnb/#{ @stack } "
67- lifecycle_bundle = @config . get ( :diego , :lifecycle_bundles ) [ lifecycle_bundle_key ]
68- raise InvalidStack . new ( "no compiler defined for requested stack '#{ @stack } '" ) unless lifecycle_bundle
69-
70- destination = @config . get ( :diego , :droplet_destinations ) [ @stack . to_sym ]
71- raise InvalidStack . new ( "no droplet destination defined for requested stack '#{ @stack } '" ) unless destination
72-
73- layers = [
74- ::Diego ::Bbs ::Models ::ImageLayer . new (
75- name : "cnb-#{ @stack } -lifecycle" ,
76- url : LifecycleBundleUriGenerator . uri ( lifecycle_bundle ) ,
77- destination_path : '/tmp/lifecycle' ,
78- layer_type : ::Diego ::Bbs ::Models ::ImageLayer ::Type ::SHARED ,
79- media_type : ::Diego ::Bbs ::Models ::ImageLayer ::MediaType ::TGZ
80- )
81- ]
76+ # Custom stacks don't need lifecycle bundles
77+ if @stack . is_a? ( String ) && is_custom_stack? ( @stack )
78+ layers = [ ]
79+ else
80+ lifecycle_bundle_key = :"cnb/#{ @stack } "
81+ lifecycle_bundle = @config . get ( :diego , :lifecycle_bundles ) [ lifecycle_bundle_key ]
82+ raise InvalidStack . new ( "no compiler defined for requested stack '#{ @stack } '" ) unless lifecycle_bundle
83+
84+ destination = @config . get ( :diego , :droplet_destinations ) [ @stack . to_sym ]
85+ raise InvalidStack . new ( "no droplet destination defined for requested stack '#{ @stack } '" ) unless destination
86+
87+ layers = [
88+ ::Diego ::Bbs ::Models ::ImageLayer . new (
89+ name : "cnb-#{ @stack } -lifecycle" ,
90+ url : LifecycleBundleUriGenerator . uri ( lifecycle_bundle ) ,
91+ destination_path : '/tmp/lifecycle' ,
92+ layer_type : ::Diego ::Bbs ::Models ::ImageLayer ::Type ::SHARED ,
93+ media_type : ::Diego ::Bbs ::Models ::ImageLayer ::MediaType ::TGZ
94+ )
95+ ]
96+ end
8297
8398 if @checksum_algorithm == 'sha256'
8499 layers << ::Diego ::Bbs ::Models ::ImageLayer . new ( {
@@ -124,6 +139,23 @@ def default_container_env
124139 ::Diego ::Bbs ::Models ::EnvironmentVariable . new ( name : 'CNB_APP_DIR' , value : '/home/vcap/workspace' )
125140 ]
126141 end
142+
143+ private
144+
145+ def is_custom_stack? ( stack_name )
146+ # Check for various container registry URL formats
147+ return true if stack_name . include? ( 'docker://' )
148+ return true if stack_name . match? ( %r{^https?://} ) # Any https/http URL
149+ return true if stack_name . include? ( '.' ) # Any string with a dot (likely a registry)
150+ false
151+ end
152+
153+ def normalize_stack_url ( stack_url )
154+ return stack_url if stack_url . start_with? ( 'docker://' )
155+ return stack_url . sub ( /^https?:\/ \/ / , 'docker://' ) if stack_url . match? ( %r{^https?://} )
156+ return "docker://#{ stack_url } " if stack_url . include? ( '.' )
157+ stack_url
158+ end
127159 end
128160 end
129161 end
0 commit comments