aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Tillmanns <[email protected]>2025-05-21 15:46:22 +0200
committerMarcus Tillmanns <[email protected]>2025-05-22 13:12:53 +0000
commite34d8e80fa0a57b6d6ae15b1c7736143a79a3431 (patch)
tree7c3c0f500930b9320c161a32b5ba983c9153b463
parent82c66314795e253aa0c5c52c58756cdac6c27a44 (diff)
DevContainer: Tag images based on workingFolder hashHEADmaster
-rw-r--r--src/libs/devcontainer/devcontainer.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libs/devcontainer/devcontainer.cpp b/src/libs/devcontainer/devcontainer.cpp
index 30da1e5937f..2663d8dfb81 100644
--- a/src/libs/devcontainer/devcontainer.cpp
+++ b/src/libs/devcontainer/devcontainer.cpp
@@ -7,6 +7,8 @@
#include <utils/qtcprocess.h>
+#include <QCryptographicHash>
+
using namespace Utils;
namespace DevContainer {
@@ -72,9 +74,15 @@ static Group prepareContainerRecipe(
containerConfig.context.value_or("."));
const FilePath dockerFile = configFileDir.resolvePath(containerConfig.dockerfile);
+ const QString hash = QString::fromLatin1(
+ QCryptographicHash::hash(
+ instanceConfig.workspaceFolder.nativePath().toUtf8(), QCryptographicHash::Sha256)
+ .toHex());
+ const QString imageName = QString("qtc-devcontainer-%1").arg(hash);
+
CommandLine buildCmdLine{
instanceConfig.dockerCli,
- {"build", "-f", dockerFile.nativePath(), contextPath.nativePath()}};
+ {"build", "-f", dockerFile.nativePath(), "-t", imageName, contextPath.nativePath()}};
process.setCommand(buildCmdLine);
process.setWorkingDirectory(instanceConfig.workspaceFolder);