2019-03-02 15:19:08 +00:00
|
|
|
import { exec } from '../../helpers/utils/exec';
|
2019-03-02 16:15:28 +00:00
|
|
|
import { execSync } from 'child_process';
|
2019-03-02 15:19:08 +00:00
|
|
|
|
|
|
|
class DockerCompose {
|
|
|
|
private commandPrefix: string;
|
|
|
|
|
|
|
|
constructor(composeFiles: string[]) {
|
|
|
|
this.commandPrefix = 'docker-compose ' + composeFiles.map((f) => '-f ' + f).join(' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
async up() {
|
2019-03-02 16:15:28 +00:00
|
|
|
return await exec(this.commandPrefix + ' up -d');
|
2019-03-02 15:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async down() {
|
2019-03-02 16:15:28 +00:00
|
|
|
return await exec(this.commandPrefix + ' down');
|
2019-03-02 15:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async restart(service: string) {
|
2019-03-02 16:15:28 +00:00
|
|
|
return await exec(this.commandPrefix + ' restart ' + service);
|
|
|
|
}
|
|
|
|
|
|
|
|
async ps() {
|
|
|
|
return Promise.resolve(execSync(this.commandPrefix + ' ps').toString('utf-8'));
|
2019-03-02 15:19:08 +00:00
|
|
|
}
|
2019-03-24 18:28:32 +00:00
|
|
|
|
|
|
|
async logs(service: string) {
|
|
|
|
await exec(this.commandPrefix + ' logs ' + service)
|
|
|
|
}
|
2019-03-02 15:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default DockerCompose;
|