8000 feat: add variable port args · aj-may/dotdocker@c36aa1b · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit c36aa1b

Browse files
committed
feat: add variable port args
1 parent 27eecf3 commit c36aa1b

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/actions/start.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import setupDNS from '../tasks/setupDNS';
66
import proxyConfig from '../containers/proxyConfig';
77
import dnsmasqConfig from '../containers/dnsmasqConfig';
88

9-
const start = () =>
9+
const start = port =>
1010
new Listr([
1111
{
1212
title: 'Start dotdocker containers',
@@ -26,9 +26,9 @@ const start = () =>
2626
title: 'Start dnsmasq',
2727
task: () =>
2828
new Listr([
29-
pullImage(dnsmasqConfig),
30-
createContainer(dnsmasqConfig),
31-
startContainer(dnsmasqConfig),
29+
pullImage(dnsmasqConfig(port)),
30+
createContainer(dnsmasqConfig(port)),
31+
startContainer(dnsmasqConfig(port)),
3232
]),
3333
},
3434
],

src/containers/dnsmasqConfig.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
export default {
1+
export default port => ({
22
Image: 'andyshinn/dnsmasq:latest',
33
name: 'dotdocker-dnsmasq',
44
Cmd: ['--address=/docker/127.0.0.1', '--log-facility=-'],
55
ExposedPorts: {
6-
'53/tcp': {},
7-
'53/udp': {},
6+
[`${port}/tcp`]: {},
7+
[`${port}/udp`]: {},
88
},
99
HostConfig: {
1010
PortBindings: {
1111
'53/tcp': [
1212
{
13-
HostPort: '53',
13+
HostPort: `${port}`,
1414
},
1515
],
1616
'53/udp': [
1717
{
18-
HostPort: '53',
18+
HostPort: `${port}`,
1919
},
2020
],
2121
},
2222
RestartPolicy: { Name: 'always' },
2323
CapAdd: ['NET_ADMIN'],
2424
},
25-
};
25+
});

src/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ import stop from './actions/stop';
44
import restart from './actions/restart';
55
import { version } from '../package.json';
66

7+
const isDarwin = process.platform === 'darwin';
8+
79
program
810
.version(version)
911
.description('A utility to help setup a docker development environment with host based routing');
1012

1113
program
1214
.command('start')
15+
.option('-p, --port <port>', 'port')
1316
.description('Pull and start the dotdocker containers and configure DNS')
14-
.action(start);
17+
.action(res => {
18+
start(isDarwin ? res.port : 53);
19+
});
1520

1621
program
1722
.command('stop')

0 commit comments

Comments
 (0)
0