Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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