@@ -221,6 +221,10 @@ def components_selected(self):
221221 def cephadm_build_args (self ):
222222 return list (self ._cli .cephadm_build_arg or [])
223223
224+ @property
225+ def run_before_commands (self ):
226+ return list (self ._cli .run_before or [])
227+
224228 def build_components (self ):
225229 if self ._cli .components :
226230 return self ._cli .components
@@ -315,6 +319,11 @@ def parse(cls):
315319 action = "append" ,
316320 help = "Pass additional arguments to cephadm build script." ,
317321 )
322+ parser .add_argument (
323+ "--run-before" ,
324+ action = "append" ,
325+ help = "Add a RUN command before other actions"
326+ )
318327 # selectors
319328 component_selections = [
320329 # aggregated components:
@@ -441,6 +450,8 @@ def add(self, component):
441450 def build (self ):
442451 """Build the container image."""
443452 dlines = [f"FROM { self ._ctx .base_image } " ]
453+ for cmd in self ._ctx .run_before_commands :
454+ dlines .append (f'RUN { cmd } ' )
444455 jcount = len (self ._jobs )
445456 for idx , (component , job ) in enumerate (self ._jobs ):
446457 num = idx + 1
@@ -456,8 +467,10 @@ def build(self):
456467 def _container_build (self ):
457468 log .info ("Building container image" )
458469 cmd = [self ._ctx .engine , "build" , "--tag" , self ._ctx .target , "." ]
470+ cmd .append ('--net=host' )
459471 if self ._ctx .root_build :
460472 cmd .insert (0 , "sudo" )
473+ log .debug ("Container build command: %r" , cmd )
461474 _run (cmd , cwd = self ._workdir ).check_returncode ()
462475
463476 def _build_tar (
0 commit comments