File tree Expand file tree Collapse file tree 6 files changed +34
-11
lines changed Expand file tree Collapse file tree 6 files changed +34
-11
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,6 @@ module.exports = class Command {
24
24
25
25
_runInternal ( ) {
26
26
log . warn ( 'Command run on base class' ) ;
27
- return Promise . resolve ( ) ; // todo : maybe reject
27
+ return Promise . reject ( ) ;
28
28
}
29
29
} ;
Original file line number Diff line number Diff line change 1
1
const log = require ( '../logger' ) ;
2
- const Command = require ( '../command ' ) ;
2
+ const BaseCommand = require ( './BaseCommand ' ) ;
3
3
4
- module . exports = class NetworkCommand extends Command {
4
+ module . exports = class NetworkCommand extends BaseCommand {
5
5
constructor ( name , options ) {
6
6
super ( name , options )
7
7
}
Original file line number Diff line number Diff line change 1
1
const log = require ( '../logger' ) ;
2
- const Command = require ( '../command' ) ;
2
+ const BaseCommand = require ( './BaseCommand' ) ;
3
+ const docker = require ( '../docker/client' ) ;
3
4
4
- module . exports = class ServiceCommand extends Command {
5
+
6
+ module . exports = class ServiceCommand extends BaseCommand {
5
7
constructor ( name , options ) {
6
8
super ( name , options )
7
9
}
8
10
9
11
_runInternal ( ) {
10
- return new Promise ( resolve => setTimeout ( resolve , 1000 ) )
12
+ const { image} = this . options ;
13
+ return docker
14
+ . pull ( image )
15
+ . then ( ( ) => docker . createContainer ( {
16
+ 'Hostname' : '' ,
17
+ 'User' : '' ,
18
+ 'AttachStdin' : false ,
19
+ 'AttachStdout' : false ,
20
+ 'AttachStderr' : false ,
21
+ 'Tty' : false ,
22
+ 'OpenStdin' : false ,
23
+ 'StdinOnce' : false ,
24
+ 'Env' : null ,
25
+ 'Cmd' : [ ] ,
26
+ 'Image' : image ,
27
+ 'Volumes' : { } ,
28
+ 'VolumesFrom' : [ ] ,
29
+ 'name' : this . name
30
+ } ) )
31
+ . then ( container => container . start ( ) )
11
32
. then ( ( ) => log . info ( `service created: '${ this . name } '` ) ) ;
33
+
12
34
}
13
35
} ;
Original file line number Diff line number Diff line change 1
1
const log = require ( '../logger' ) ;
2
- const Command = require ( '../command ' ) ;
2
+ const BaseCommand = require ( './BaseCommand ' ) ;
3
3
4
- module . exports = class VolumeCommand extends Command {
4
+ module . exports = class VolumeCommand extends BaseCommand {
5
5
constructor ( name , options ) {
6
6
super ( name , options )
7
7
}
Original file line number Diff line number Diff line change
1
+ const Docker = require ( 'dockerode' ) ;
2
+ module . exports = new Docker ( { socketPath : '/var/run/docker.sock' } ) ;
Original file line number Diff line number Diff line change 9
9
},
10
10
"dependencies" : {
11
11
"debug" : " ~2.6.9" ,
12
- "docker-client " : " ^1.38.1 " ,
12
+ "dockerode " : " ^2.5.7 " ,
13
13
"express" : " ~4.16.0" ,
14
14
"express-fileupload" : " ^1.0.0" ,
15
15
"http-errors" : " ~1.6.2" ,
16
16
"morgan" : " ~1.9.0" ,
17
17
"nconf" : " ^0.10.0" ,
18
18
"parser-yaml" : " ^0.1.1" ,
19
- "winston" : " ^3.1.0" ,
20
- "yaml" : " ^1.0.0"
19
+ "winston" : " ^3.1.0"
21
20
},
22
21
"devDependencies" : {
23
22
"@types/node" : " ^10.12.0"
You can’t perform that action at this time.
0 commit comments