@@ -97,6 +97,28 @@ def _default_log_level(self):
9797 """
9898 )
9999
100+ extra_build_kwargs = Dict (
101+ {},
102+ help = """
103+ extra kwargs to limit CPU quota when building a docker image.
104+ Dictionary that allows the user to set the desired runtime flag
105+ to configure the amount of access to CPU resources your container has.
106+ Reference https://docs.docker.com/config/containers/resource_constraints/#cpu
107+ """ ,
108+ config = True
109+ )
110+
111+ extra_run_kwargs = Dict (
112+ {},
113+ help = """
114+ extra kwargs to limit CPU quota when running a docker image.
115+ Dictionary that allows the user to set the desired runtime flag
116+ to configure the amount of access to CPU resources your container has.
117+ Reference https://docs.docker.com/config/containers/resource_constraints/#cpu
118+ """ ,
119+ config = True
120+ )
121+
100122 default_buildpack = Any (
101123 PythonBuildPack ,
102124 config = True ,
@@ -499,15 +521,20 @@ def start_container(self):
499521 'mode' : 'rw'
500522 }
501523
502- container = client .containers .run (
503- self .output_image_spec ,
524+ run_kwargs = dict (
504525 publish_all_ports = self .all_ports ,
505526 ports = ports ,
506527 detach = True ,
507528 command = run_cmd ,
508529 volumes = container_volumes ,
509530 environment = self .environment
510531 )
532+
533+ run_kwargs .update (self .extra_run_kwargs )
534+
535+ container = client .containers .run (
536+ self .output_image_spec , ** run_kwargs )
537+
511538 while container .status == 'created' :
512539 time .sleep (0.5 )
513540 container .reload ()
@@ -636,7 +663,8 @@ def build(self):
636663 self .output_image_spec ,
637664 self .build_memory_limit ,
638665 build_args ,
639- self .cache_from ):
666+ self .cache_from ,
667+ self .extra_build_kwargs ):
640668 if 'stream' in l :
641669 self .log .info (l ['stream' ],
642670 extra = dict (phase = 'building' ))
0 commit comments