Constructor
# new DockerComposeFile(composeFileString) → {DockerComposeFile}
Creates a DockerComposeFile instance with provided docker-compose.yml file or string.
Name | Type | Description |
---|---|---|
composeFileString |
String | DockerComposeFile | a path to a docker-compose.yml file, a full yaml string or a DockerComposeFile instance. |
- Source:
DockerComposeFile instance with all files or strings merged together.
- Type
- DockerComposeFile
const composeFile = new DockerComposeFile(`${__dirname}/docker-compose.yml`);
const composeFile = new DockerComposeFile(`${__dirname}/docker-compose.yml`, `${__dirname}/docker-compose.vpn.yml`);
const composeFile = new DockerComposeFile(`${__dirname}/docker-compose.yml, "version: '3'");
Members
# yaml :String
Merges the new yaml string to the current yaml also takes file paths or DockerComposeFiles.
- String
- Source:
Methods
# add(…composeFiles) → {String}
Merges the provided compose files into the current yaml class object.
Name | Type | Attributes | Description |
---|---|---|---|
composeFiles |
String | DockerComposeFile |
<repeatable> |
Any number of compose file paths or DockerComposeFile objects. |
- Source:
Merged yaml string.
- Type
- String
# mapTemplate(…substitutions)
Takes a docker-compose file with template strings and generates an array of substituted docker compose files. Only operates with arrays of substitutions of the same length.
Name | Type | Attributes | Description |
---|---|---|---|
substitutions |
Array.<String, Array.<String>> |
<repeatable> |
Each set of substitutions an key and an array of values to map. |
- Source:
- To Do:
-
- allow for variable length substitutions.
Array of substituted docker compose files.
// docker-compose file containing template strings for ${REGION} and ${ID}.
const yamlString =
`
services:
vpn-${REGION}-${ID}:
container_name: 'vpn-${REGION}-${ID}'
environment:
- REGION=${REGION}
`;
const composeFileTemplate = new DockerComposeFile(yamlString);
// Will return a array of 2 compose files for each substitution.
const composeFiles = composeFileTemplate.mapTemplate(
['REGION', ['US_West', 'US_Seattle']],
['ID', ['1', '2']]
);
# write(path)
Save the yaml file to disk.
Name | Type | Description |
---|---|---|
path |
File path to save the yaml. |
- Source: