Skip to content

Commit 44069a2

Browse files
committed
Bind mount the directory with SSH keys
That allows to build Rust crates with private repositories as dependencies. Fixes #6
1 parent 7fe7e6a commit 44069a2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main.rs

+8
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,14 @@ fn mounts(volumes: Vec<String>) -> anyhow::Result<Vec<Mount>> {
569569
// resolve domains.
570570
let resolv_mount = bind_mount("/etc/resolv.conf", "/etc/resolv.conf")?;
571571
mounts.push(resolv_mount);
572+
// Mount the directory with SSH keys (`$HOME/.ssh`) to be able to access
573+
// private repositories.
574+
let home_dir = env::var_os("HOME").ok_or(anyhow!(
575+
"cannot find the home directory, `HOME` environment variable is not defined"
576+
))?;
577+
let ssh_keys_dir = Path::new(&home_dir).join(".ssh");
578+
let ssh_keys_mount = bind_mount(ssh_keys_dir, "/root/.ssh")?;
579+
mounts.push(ssh_keys_mount);
572580
// Mount all the user-provided volumes.
573581
for volume in volumes {
574582
let parts: Vec<&str> = volume.split(':').collect();

0 commit comments

Comments
 (0)