Skip to content

Commit a9cdaf9

Browse files
committed
twoliter: Use unique token for sdk container
1 parent 0879545 commit a9cdaf9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

twoliter/src/cmd/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ pub(crate) struct BuildVariant {
4141
impl BuildVariant {
4242
pub(super) async fn run(&self) -> Result<()> {
4343
let project = project::load_or_find_project(self.project_path.clone()).await?;
44+
let token = project.token();
4445
let tempdir = tools_tempdir()?;
4546
install_tools(&tempdir).await?;
4647
let makefile_path = tempdir.path().join("Makefile.toml");
4748
let packages_dir =
4849
TempDir::new().context("Unable to create a tempdir for Twoliter's packages")?;
4950

5051
let sdk_container = DockerContainer::new(
51-
"sdk",
52+
format!("sdk-{}", token),
5253
project
5354
.sdk(&self.arch)
5455
.context("The project was missing an sdk")?

twoliter/src/project.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use log::{debug, trace};
55
use non_empty_string::NonEmptyString;
66
use serde::de::Error;
77
use serde::{Deserialize, Deserializer, Serialize, Serializer};
8+
use sha2::{Digest, Sha512};
89
use std::fmt;
910
use std::path::{Path, PathBuf};
1011
use tokio::fs;
@@ -115,6 +116,13 @@ impl Project {
115116
pub(crate) fn toolchain(&self, arch: &str) -> Option<ImageArchUri> {
116117
self.toolchain_name().map(|s| s.uri(arch))
117118
}
119+
120+
pub(crate) fn token(&self) -> String {
121+
let mut d = Sha512::new();
122+
d.update(self.filepath().display().to_string());
123+
let digest = hex::encode(d.finalize());
124+
(digest[..12]).to_string()
125+
}
118126
}
119127

120128
/// A base name for an image that can be suffixed using a naming convention. For example,

0 commit comments

Comments
 (0)