better-decomposerize
v1.6.5
Published
[](https://www.npmjs.com/package/better-decomposerize) [](https://github.com/MatrixDJ96)
Downloads
623
Readme
better-decomposerize
https://decomposerize.com - Turns Docker Compose files into docker run commands.
Looking for the reverse? https://composerize.com / Composerize
Want to convert between Docker Compose file formats? https://composeverter.com / Composeverter
CLI
Install globally:
npm install -g better-decomposerizeThe installed command is still:
decomposerizeBasic usage:
decomposerize docker-compose.ymlOptions can be placed before the compose file:
decomposerize --docker-run --multiline docker-compose.ymlIf input is piped or redirected, the CLI reads from stdin:
cat docker-compose.yml | decomposerize --docker-run
decomposerize --docker-run < docker-compose.ymlIf neither a compose file nor stdin input is provided, the CLI exits with an error and prints the help message.
CLI options
Usage: decomposerize [options] <compose-file>--help,-h--services=service1,service2--docker-run--docker-run-command=<cmd>--docker-run-rm--docker-run-detach--docker-build--stop-and-remove--create-volumes--create-networks--delete-images--ansible-env-vars-format--multiline--long-args--arg-value-separator=<sep>
API
The package exports a function:
const decomposerize = require('better-decomposerize');Signature
decomposerize(dockerComposeContent, configuration = {})dockerComposeContent: a string containing the Docker Compose YAML.configuration: optional configuration object.
Supported configuration fields:
services: string[]stopAndRemoveContainers: booleancreateVolumes: booleancreateNetworks: booleandockerBuild: booleandockerRun: booleandockerRunCommand: stringdockerRunRm: booleandockerRunDetach: booleandeleteImages: booleanansibleEnvVarsFormat: booleanmultiline: boolean'long-args': boolean'arg-value-separator': ' ' | '='
Example
const decomposerize = require('better-decomposerize');
const dockerComposeInput = `
version: '3'
services:
myapp:
image: myapp-image
`;
const configuration = {
dockerRun: true,
dockerRunCommand: 'docker run',
dockerRunRm: true,
dockerRunDetach: false,
multiline: true,
'long-args': false,
'arg-value-separator': ' ',
};
const output = decomposerize(dockerComposeInput, configuration);
console.log(output);Development
This package uses make for common tasks:
make eslint
make test
make build
make rebuild
make release
make publishBuild outputs
dist/decomposerize.js→ library bundledist/cli.bundle.js→ bundled npm CLIdist/decomposerize→ standalone executable built with Node SEA
Standalone binary
Build the standalone executable:
make releaseRun it:
./dist/decomposerize docker-compose.ymlInstall it system-wide:
sudo make installInstall it under a custom prefix:
make install PREFIX=$HOME/.localUninstall it:
sudo make uninstall
make uninstall PREFIX=$HOME/.localContributing
- Clone a fork of the repo and install dependencies with
yarn - Make your changes and build them with
make build - Run
make test
Maintainers
License
MIT
