forked from qt-creator/qt-creator
DockerDevice: Do not change the containers entrypoint
Some containers may use their entrypoint to setup their environment. Simply overwriting it from our side would disable such setup and make the containers useless. Change-Id: I3385858c49aa8217c3191acdb85343ffd6163cf9 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -482,7 +482,7 @@ bool DockerDevicePrivate::createContainer()
|
||||
continue;
|
||||
dockerCreate.addArgs({"-v", path.nativePath() + ':' + containerPath.nativePath()});
|
||||
}
|
||||
|
||||
if (!m_data.keepEntryPoint)
|
||||
dockerCreate.addArgs({"--entrypoint", "/bin/sh"});
|
||||
|
||||
dockerCreate.addArg(m_data.repoAndTag());
|
||||
@@ -563,6 +563,7 @@ const char DockerDeviceDataTagKey[] = "DockerDeviceDataTag";
|
||||
const char DockerDeviceDataSizeKey[] = "DockerDeviceDataSize";
|
||||
const char DockerDeviceUseOutsideUser[] = "DockerDeviceUseUidGid";
|
||||
const char DockerDeviceMappedPaths[] = "DockerDeviceMappedPaths";
|
||||
const char DockerDeviceKeepEntryPoint[] = "DockerDeviceKeepEntryPoint";
|
||||
|
||||
void DockerDevice::fromMap(const QVariantMap &map)
|
||||
{
|
||||
@@ -576,6 +577,7 @@ void DockerDevice::fromMap(const QVariantMap &map)
|
||||
data.useLocalUidGid = map.value(DockerDeviceUseOutsideUser, HostOsInfo::isLinuxHost())
|
||||
.toBool();
|
||||
data.mounts = map.value(DockerDeviceMappedPaths).toStringList();
|
||||
data.keepEntryPoint = map.value(DockerDeviceKeepEntryPoint).toBool();
|
||||
d->setData(data);
|
||||
}
|
||||
|
||||
@@ -590,6 +592,7 @@ QVariantMap DockerDevice::toMap() const
|
||||
map.insert(DockerDeviceDataSizeKey, data.size);
|
||||
map.insert(DockerDeviceUseOutsideUser, data.useLocalUidGid);
|
||||
map.insert(DockerDeviceMappedPaths, data.mounts);
|
||||
map.insert(DockerDeviceKeepEntryPoint, data.keepEntryPoint);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ public:
|
||||
bool operator==(const DockerDeviceData &other) const
|
||||
{
|
||||
return imageId == other.imageId && repo == other.repo && tag == other.tag
|
||||
&& useLocalUidGid == other.useLocalUidGid && mounts == other.mounts;
|
||||
&& useLocalUidGid == other.useLocalUidGid && mounts == other.mounts
|
||||
&& keepEntryPoint == other.keepEntryPoint;
|
||||
}
|
||||
|
||||
bool operator!=(const DockerDeviceData &other) const { return !(*this == other); }
|
||||
@@ -45,6 +46,7 @@ public:
|
||||
QString size;
|
||||
bool useLocalUidGid = true;
|
||||
QStringList mounts = {Core::DocumentManager::projectsDirectory().toString()};
|
||||
bool keepEntryPoint = false;
|
||||
};
|
||||
|
||||
class DockerDevice : public ProjectExplorer::IDevice
|
||||
|
||||
@@ -65,6 +65,18 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
|
||||
DockerApi::recheckDockerDaemon();
|
||||
});
|
||||
|
||||
m_keepEntryPoint = new QCheckBox(Tr::tr("Don't modify entry point"));
|
||||
m_keepEntryPoint->setToolTip(
|
||||
Tr::tr("If checked, the entry point of the image will not be modified. Only use this if "
|
||||
"the image starts into a shell."));
|
||||
m_keepEntryPoint->setChecked(m_data.keepEntryPoint);
|
||||
m_keepEntryPoint->setEnabled(true);
|
||||
|
||||
connect(m_keepEntryPoint, &QCheckBox::toggled, this, [this, dockerDevice](bool on) {
|
||||
m_data.keepEntryPoint = on;
|
||||
dockerDevice->setData(m_data);
|
||||
});
|
||||
|
||||
m_runAsOutsideUser = new QCheckBox(Tr::tr("Run as outside user"));
|
||||
m_runAsOutsideUser->setToolTip(Tr::tr("Uses user ID and group ID of the user running Qt Creator "
|
||||
"in the docker container."));
|
||||
@@ -164,6 +176,7 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
|
||||
idLabel, m_idLineEdit, br,
|
||||
daemonStateLabel, m_daemonReset, m_daemonState, br,
|
||||
m_runAsOutsideUser, br,
|
||||
m_keepEntryPoint, br,
|
||||
Column {
|
||||
pathListLabel,
|
||||
m_pathsListEdit,
|
||||
|
||||
@@ -36,6 +36,7 @@ private:
|
||||
QToolButton *m_daemonReset;
|
||||
QLabel *m_daemonState;
|
||||
QCheckBox *m_runAsOutsideUser;
|
||||
QCheckBox *m_keepEntryPoint;
|
||||
Utils::PathListEditor *m_pathsListEdit;
|
||||
KitDetector m_kitItemDetector;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user