forked from junosuarez/dockerfile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
98 lines (81 loc) · 1.77 KB
/
index.js
File metadata and controls
98 lines (81 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
function dockerfile () {
if (!(this instanceof dockerfile)) {
return new dockerfile()
}
this.file = []
}
var methods = dockerfile.prototype
methods.rem = function (comment) {
this.file.push(['#', comment])
return this
}
methods.section = function (title) {
this.file.push([''],
[''],
['#', title]
)
return this
}
methods.name = function (name) {
this.file.push(['#','name', name])
return this
}
methods.from = function (image) {
this.file.push(['from', image])
return this
}
methods.maintainer = function (name) {
this.file.push(['maintainer', name])
return this
}
methods.dockerVersion = function (version) {
this.file.push(['docker-version', version])
return this
}
methods.version = function (version) {
this.file.push(['version', version])
return this
}
methods.run = function (command) {
this.file.push(['run', command])
return this
}
methods.cmd = function (command) {
this.file.push(['cmd', command])
return this
}
methods.expose = function (ports) {
ports = [].concat(ports).join(' ')
this.file.push(['expose', ports])
return this
}
methods.env = function (key, val) {
if (typeof key === 'object') {
var env = key
for (key in env) {
this.env(key, env[key])
}
} else {
this.file.push(['env', key, val])
}
return this
}
methods.add = function (src, dest) {
this.file.push(['add', src, dest])
return this
}
methods.entrypoint = function (command) {
this.file.push(['entrypoint', command])
return this
}
methods.volume = function (path) {
this.file.push(['volume', path])
return this
}
methods.export = function () {
var file = this.file.reduce(function (out, line) {
return out + line.join(' ') + '\n'
}, '')
return file
}
module.exports = dockerfile