Skip to content

Commit

Permalink
fix(compas): only print info on changes to the started docker containers
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 committed Sep 18, 2023
1 parent e493d16 commit 01ef1eb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/compas/src/main/development/integrations/docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export class DockerIntegration extends BaseIntegration {
if (!(await this.checkEnv())) {
return;
}

let didExecuteAHostAction = false;

const { containersOnHost, runningContainersOnHost } =
await this.containersOnHost();

Expand All @@ -54,6 +57,8 @@ export class DockerIntegration extends BaseIntegration {
);

if (containersToStop.length > 0) {
didExecuteAHostAction = true;

this.state.logInformation(
"Stopping containers that are not required for the current project.",
);
Expand All @@ -68,6 +73,8 @@ export class DockerIntegration extends BaseIntegration {
}

if (imagesToPull.length > 0) {
didExecuteAHostAction = true;

this.state.logInformation(
"Downloading images and creating containers in the background...",
);
Expand All @@ -76,6 +83,8 @@ export class DockerIntegration extends BaseIntegration {

for (const key of Object.keys(containerObject)) {
if (!containersOnHost.includes(key)) {
didExecuteAHostAction = true;

const info = containerObject[key];
await exec(
`docker create ${info.createArguments ?? ""} --name ${key} ${
Expand All @@ -90,10 +99,14 @@ export class DockerIntegration extends BaseIntegration {
);

if (containersToStart.length > 0) {
didExecuteAHostAction = true;

await exec(`docker start ${Object.keys(containerObject).join(" ")}`);
}

this.state.logInformation("Required docker containers are running!");
if (didExecuteAHostAction) {
this.state.logInformation("Required docker containers are running!");
}
}

async containersOnHost() {
Expand Down

0 comments on commit 01ef1eb

Please sign in to comment.