Skip to content

Commit

Permalink
Merge #934
Browse files Browse the repository at this point in the history
934: Add support for pre-build hooks with remote docker. r=Emilgardis a=Alexhuszagh

Closes #928.

Co-authored-by: Alex Huszagh <[email protected]>
  • Loading branch information
bors[bot] and Alexhuszagh authored Jul 11, 2022
2 parents 635bd70 + 0ffbff7 commit c8bb213
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changes/934.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "added",
"description": "add support for pre-build hooks with remote docker",
"issues": [928]
}
9 changes: 8 additions & 1 deletion src/docker/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,14 @@ pub(crate) fn run(
docker.arg("-t");
}

docker.arg(&image_name(&options.config, target)?);
let mut image = options.image_name()?;
if options.needs_custom_image() {
image = options
.custom_image_build(&paths, msg_info)
.wrap_err("when building custom image")?;
}

docker.arg(&image);
if !is_tty {
// ensure the process never exits until we stop it
// we only need this infinite loop if we don't allocate
Expand Down
25 changes: 2 additions & 23 deletions src/docker/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl DockerOptions {
paths: &DockerPaths,
msg_info: &mut MessageInfo,
) -> Result<String> {
let mut image = image_name(&self.config, &self.target)?;
let mut image = self.image_name()?;

if let Some(path) = self.config.dockerfile(&self.target)? {
let context = self.config.dockerfile_context(&self.target)?;
Expand Down Expand Up @@ -167,28 +167,7 @@ impl DockerOptions {
}

pub(crate) fn image_name(&self) -> Result<String> {
if let Some(image) = self.config.image(&self.target)? {
return Ok(image);
}

if !DOCKER_IMAGES.contains(&self.target.triple()) {
eyre::bail!(
"`cross` does not provide a Docker image for target {target}, \
specify a custom image in `Cross.toml`.",
target = self.target
);
}

let version = if include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")).is_empty() {
env!("CARGO_PKG_VERSION")
} else {
"main"
};

Ok(format!(
"{CROSS_IMAGE}/{target}:{version}",
target = self.target
))
image_name(&self.config, &self.target)
}
}

Expand Down

0 comments on commit c8bb213

Please sign in to comment.