fix(run): refs#6706 Remove container on failure, network param fix

This commit is contained in:
Juan Ferrer 2024-02-06 22:21:31 +01:00
parent ed248aed93
commit 26ac3e995a
3 changed files with 94 additions and 86 deletions

View File

@ -118,6 +118,8 @@ class Run extends Command {
detach: true
});
const ct = await docker.run(opts.code, null, runOptions);
try {
const server = new Server(ct, dbConfig);
if (isRandom) {
@ -126,7 +128,7 @@ class Run extends Command {
format: '{{json .NetworkSettings}}'
});
if (opts.ci) {
if (opts.ci || opts.network) {
dbConfig.host = opts.network
? netSettings.Networks[opts.network].IPAddress
: netSettings.Gateway;
@ -204,6 +206,12 @@ class Run extends Command {
await conn.end();
return server;
} catch (err) {
try {
await ct.rm({force: true});
} catch (e) {}
throw err;
}
}
}

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@verdnatura/myt",
"version": "1.6.3",
"version": "1.6.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@verdnatura/myt",
"version": "1.6.3",
"version": "1.6.4",
"license": "GPL-3.0",
"dependencies": {
"@sqltools/formatter": "^1.2.5",

View File

@ -1,6 +1,6 @@
{
"name": "@verdnatura/myt",
"version": "1.6.3",
"version": "1.6.5",
"author": "Verdnatura Levante SL",
"description": "MySQL version control",
"license": "GPL-3.0",