@@ -106,11 +106,15 @@ impl RustwideBuilder {
106106 self . skip_build_if_exists = should;
107107 }
108108
109- fn prepare_sandbox ( & self , limits : & Limits ) -> SandboxBuilder {
110- SandboxBuilder :: new ( )
109+ fn prepare_sandbox ( & self , metadata : & Metadata , limits : & Limits ) -> Result < SandboxBuilder > {
110+ let mut builder = SandboxBuilder :: new ( )
111111 . cpu_limit ( self . config . build_cpu_limit . map ( |limit| limit as f32 ) )
112112 . memory_limit ( Some ( limits. memory ( ) ) )
113- . enable_networking ( limits. networking ( ) )
113+ . enable_networking ( limits. networking ( ) ) ;
114+ if let Some ( image) = metadata. docker_image ( ) {
115+ builder = builder. image ( SandboxImage :: remote ( & image) ?)
116+ }
117+ Ok ( builder)
114118 }
115119
116120 pub fn update_toolchain ( & mut self ) -> Result < ( ) > {
@@ -208,11 +212,15 @@ impl RustwideBuilder {
208212 let krate = Crate :: crates_io ( DUMMY_CRATE_NAME , DUMMY_CRATE_VERSION ) ;
209213 krate. fetch ( & self . workspace ) ?;
210214
215+ let metadata = Metadata :: from_crate_root ( & build_dir. build_dir ( ) ) ?;
216+
211217 build_dir
212- . build ( & self . toolchain , & krate, self . prepare_sandbox ( & limits) )
218+ . build (
219+ & self . toolchain ,
220+ & krate,
221+ self . prepare_sandbox ( & metadata, & limits) ?,
222+ )
213223 . run ( |build| {
214- let metadata = Metadata :: from_crate_root ( & build. host_source_dir ( ) ) ?;
215-
216224 let res = self . execute_build ( HOST_TARGET , true , build, & limits, & metadata) ?;
217225 if !res. result . successful {
218226 failure:: bail!( "failed to build dummy crate for {}" , self . rustc_version) ;
@@ -322,14 +330,18 @@ impl RustwideBuilder {
322330
323331 let local_storage = tempfile:: Builder :: new ( ) . prefix ( "docsrs-docs" ) . tempdir ( ) ?;
324332
333+ let metadata = Metadata :: from_crate_root ( & build_dir. build_dir ( ) ) ?;
325334 let res = build_dir
326- . build ( & self . toolchain , & krate, self . prepare_sandbox ( & limits) )
335+ . build (
336+ & self . toolchain ,
337+ & krate,
338+ self . prepare_sandbox ( & metadata, & limits) ?,
339+ )
327340 . run ( |build| {
328341 use docsrs_metadata:: BuildTargets ;
329342
330343 let mut has_docs = false ;
331344 let mut successful_targets = Vec :: new ( ) ;
332- let metadata = Metadata :: from_crate_root ( & build. host_source_dir ( ) ) ?;
333345 let BuildTargets {
334346 default_target,
335347 other_targets,
0 commit comments