-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom docker image support #1193
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,11 +106,15 @@ impl RustwideBuilder { | |
self.skip_build_if_exists = should; | ||
} | ||
|
||
fn prepare_sandbox(&self, limits: &Limits) -> SandboxBuilder { | ||
SandboxBuilder::new() | ||
fn prepare_sandbox(&self, metadata: &Metadata, limits: &Limits) -> Result<SandboxBuilder> { | ||
let mut builder = SandboxBuilder::new() | ||
.cpu_limit(self.config.build_cpu_limit.map(|limit| limit as f32)) | ||
.memory_limit(Some(limits.memory())) | ||
.enable_networking(limits.networking()) | ||
.enable_networking(limits.networking()); | ||
if let Some(image) = metadata.docker_image() { | ||
builder = builder.image(SandboxImage::remote(&image)?) | ||
} | ||
Ok(builder) | ||
} | ||
|
||
pub fn update_toolchain(&mut self) -> Result<()> { | ||
|
@@ -208,11 +212,15 @@ impl RustwideBuilder { | |
let krate = Crate::crates_io(DUMMY_CRATE_NAME, DUMMY_CRATE_VERSION); | ||
krate.fetch(&self.workspace)?; | ||
|
||
let metadata = Metadata::from_crate_root(&build_dir.build_dir())?; | ||
|
||
build_dir | ||
.build(&self.toolchain, &krate, self.prepare_sandbox(&limits)) | ||
.build( | ||
&self.toolchain, | ||
&krate, | ||
self.prepare_sandbox(&metadata, &limits)?, | ||
) | ||
.run(|build| { | ||
let metadata = Metadata::from_crate_root(&build.host_source_dir())?; | ||
|
||
let res = self.execute_build(HOST_TARGET, true, build, &limits, &metadata)?; | ||
if !res.result.successful { | ||
failure::bail!("failed to build dummy crate for {}", self.rustc_version); | ||
|
@@ -322,14 +330,18 @@ impl RustwideBuilder { | |
|
||
let local_storage = tempfile::Builder::new().prefix("docsrs-docs").tempdir()?; | ||
|
||
let metadata = Metadata::from_crate_root(&build_dir.build_dir())?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, are you sure this is right? I think builds happen in a temporary directory, not in the source directory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't tested it, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have build_dir here, not source_dir - is that intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this won't work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about a BuildDir::create_or_get_source_dir (or whatever name) which both docs.rs and run() can call so we don't waste cpu cycles moving everything twice |
||
let res = build_dir | ||
.build(&self.toolchain, &krate, self.prepare_sandbox(&limits)) | ||
.build( | ||
&self.toolchain, | ||
&krate, | ||
self.prepare_sandbox(&metadata, &limits)?, | ||
) | ||
.run(|build| { | ||
use docsrs_metadata::BuildTargets; | ||
|
||
let mut has_docs = false; | ||
let mut successful_targets = Vec::new(); | ||
let metadata = Metadata::from_crate_root(&build.host_source_dir())?; | ||
let BuildTargets { | ||
default_target, | ||
other_targets, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's return a borrow here, since it's not dynamic.