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 detach: true
}); });
const ct = await docker.run(opts.code, null, runOptions); const ct = await docker.run(opts.code, null, runOptions);
try {
const server = new Server(ct, dbConfig); const server = new Server(ct, dbConfig);
if (isRandom) { if (isRandom) {
@ -126,7 +128,7 @@ class Run extends Command {
format: '{{json .NetworkSettings}}' format: '{{json .NetworkSettings}}'
}); });
if (opts.ci) { if (opts.ci || opts.network) {
dbConfig.host = opts.network dbConfig.host = opts.network
? netSettings.Networks[opts.network].IPAddress ? netSettings.Networks[opts.network].IPAddress
: netSettings.Gateway; : netSettings.Gateway;
@ -204,6 +206,12 @@ class Run extends Command {
await conn.end(); await conn.end();
return server; 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", "name": "@verdnatura/myt",
"version": "1.6.3", "version": "1.6.4",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@verdnatura/myt", "name": "@verdnatura/myt",
"version": "1.6.3", "version": "1.6.4",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"@sqltools/formatter": "^1.2.5", "@sqltools/formatter": "^1.2.5",

View File

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