Last active
January 28, 2018 12:32
-
-
Save kjendrzyca/a284d398e3d022de3ed14e596c78089d to your computer and use it in GitHub Desktop.
docker-run
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
#!/usr/bin/env node | |
const program = require('commander') // eslint-disable-line | |
program | |
.version('0.1.0') | |
.option('-r, --rebuild', 'Start the containers and rebuild the images') | |
.option('-d, --down', 'Stop the containers') | |
.option('-l, --logs', 'Log the output of all containers') | |
.option('-f, --follow', 'Log the output of all containers in watch mode') | |
.parse(process.argv) | |
const getArgs = () => { | |
if (program.rebuild) { | |
return ['up', '-d', '--build', '--force-recreate', '--remove-orphans'] | |
} | |
if (program.down) { | |
return ['down', '--volumes', '--remove-orphans'] | |
} | |
if (program.logs) { | |
return ['logs'] | |
} | |
if (program.follow || (program.logs && program.follow)) { | |
return ['logs', '-f'] | |
} | |
return ['up', '-d'] | |
} | |
const opts = {stdio: 'inherit', shell: true} | |
require('child_process').spawn('docker-compose', getArgs(), opts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment