diff --git a/README.md b/README.md index d70155b..d095f3b 100644 --- a/README.md +++ b/README.md @@ -279,7 +279,7 @@ Builds and starts local database server container. It only rebuilds the image when dump have been modified. ```text -$ myt run [-c|--ci] [-r|--random] +$ myt run [-c|--ci] [-r|--random] [-n|--network ] ``` ### start diff --git a/myt-run.js b/myt-run.js index 6d9ccb4..42880eb 100644 --- a/myt-run.js +++ b/myt-run.js @@ -18,13 +18,15 @@ class Run extends Command { description: 'Build and start local database server container', params: { ci: 'Workaround for continuous integration system', - random: 'Whether to use a random container name or port' + network: 'Docker network to attach container to', + random: 'Whether to use a random container name and port' } }; static opts = { alias: { ci: 'c', + network: 'n', random: 'r' }, boolean: [ @@ -104,6 +106,9 @@ class Run extends Command { } catch (e) {} } + if (opts.network) + Object.assign(runOptions, {network: opts.network}); + const runChown = process.platform != 'linux'; Object.assign(runOptions, null, { @@ -120,10 +125,11 @@ class Run extends Command { format: '{{json .NetworkSettings}}' }); - if (opts.ci) - dbConfig.host = netSettings.Gateway; - - dbConfig.port = netSettings.Ports['3306/tcp'][0].HostPort; + if (opts.ci) { + dbConfig.host = netSettings.Networks[networkName].IPAddress; + dbConfig.port = 3306; + } else + dbConfig.port = netSettings.Ports['3306/tcp'][0].HostPort; } catch (err) { await server.rm(); throw err; diff --git a/package-lock.json b/package-lock.json index 34ba54a..9d99104 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@verdnatura/myt", - "version": "1.5.31", + "version": "1.5.32", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@verdnatura/myt", - "version": "1.5.31", + "version": "1.5.32", "license": "GPL-3.0", "dependencies": { "@sqltools/formatter": "^1.2.5", diff --git a/package.json b/package.json index c29db8a..0aac60e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@verdnatura/myt", - "version": "1.5.31", + "version": "1.5.32", "author": "Verdnatura Levante SL", "description": "MySQL version control", "license": "GPL-3.0",