This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from Microsoft/feature/cleanupDockerfilecreation
Simplify dockerfile creation.
- Loading branch information
Showing
9 changed files
with
153 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/*--------------------------------------------------------- | ||
* Copyright (C) Microsoft Corporation. All rights reserved. | ||
*--------------------------------------------------------*/ | ||
'use strict' | ||
|
||
/** | ||
* Helper for creating dockerfile contents. | ||
* @constructor | ||
*/ | ||
var DockerfileHelper = function() { | ||
this._commandMap = []; | ||
} | ||
|
||
/** | ||
* Adds the FROM [imagename] line. | ||
*/ | ||
DockerfileHelper.prototype.addFromCommand = function(command) { | ||
this._addCommand('FROM', command); | ||
} | ||
|
||
/** | ||
* Adds the RUN [command] line. | ||
*/ | ||
DockerfileHelper.prototype.addRunCommand = function(command) { | ||
this._addCommand('RUN', command); | ||
} | ||
|
||
/** | ||
* Adds COPY [command] line. | ||
*/ | ||
DockerfileHelper.prototype.addCopyCommand = function(command) { | ||
this._addCommand('COPY', command); | ||
} | ||
|
||
/** | ||
* Adds WORKDIR [command] line. | ||
*/ | ||
DockerfileHelper.prototype.addWorkdirCommand = function(command) { | ||
this._addCommand('WORKDIR', command); | ||
} | ||
|
||
/** | ||
* Adds ADD [command] line. | ||
*/ | ||
DockerfileHelper.prototype.addAddCommand = function(command) { | ||
this._addCommand('ADD', command); | ||
} | ||
|
||
DockerfileHelper.prototype.addExposeCommand = function(command) { | ||
this._addCommand('EXPOSE', command); | ||
} | ||
|
||
/** | ||
* Adds ENTRYPOINT [command] line. | ||
*/ | ||
DockerfileHelper.prototype.addEntrypointCommand = function(command) { | ||
this._addCommand('ENTRYPOINT', command); | ||
} | ||
|
||
/** | ||
* Adds CMD [command] line. | ||
*/ | ||
DockerfileHelper.prototype.addCmdCommand = function(command) { | ||
this._addCommand('CMD', command); | ||
} | ||
|
||
/** | ||
* Iterates through the array of commands and creates the contents. | ||
*/ | ||
DockerfileHelper.prototype.createDockerfileContents = function() { | ||
var contents = ''; | ||
for (var i = 0; i < this._commandMap.length; i ++) { | ||
var item = this._commandMap[i]; | ||
contents += item.commandName + ' ' + item.value + '\n'; | ||
} | ||
|
||
return contents; | ||
} | ||
|
||
/** | ||
* Adds the command name and value to the list of commands. | ||
*/ | ||
DockerfileHelper.prototype._addCommand = function(commandName, value) { | ||
this._commandMap.push({ commandName: commandName, value: value }); | ||
} | ||
|
||
module.exports = DockerfileHelper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters