fix: run compose commmands using spawn instead of execAsync
This commit is contained in:
parent
71c38dbd1b
commit
35a2bcff04
3 changed files with 23 additions and 6 deletions
2
.github/workflows/alpha-release.yml
vendored
2
.github/workflows/alpha-release.yml
vendored
|
@ -121,6 +121,8 @@ jobs:
|
|||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
body: |
|
||||
**${{ needs.create-tag.outputs.tagname }}**
|
||||
tag_name: ${{ needs.create-tag.outputs.tagname }}
|
||||
release_name: ${{ needs.create-tag.outputs.tagname }}
|
||||
draft: false
|
||||
|
|
|
@ -23,6 +23,7 @@ import { getEnv } from '@/utils/environment/environment';
|
|||
import { fileLogger } from '@/utils/logger/file-logger';
|
||||
import { runPostgresMigrations } from '@/utils/migrations/run-migration';
|
||||
import { getUserIds } from '@/utils/environment/user';
|
||||
import { runComposeCommand } from '@/utils/docker-helpers';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
|
@ -233,10 +234,7 @@ export class SystemExecutors {
|
|||
spinner.setMessage('Pulling images...');
|
||||
spinner.start();
|
||||
this.logger.info('Pulling new images...');
|
||||
// await execAsync(`docker compose --env-file "${this.envFile}" pull`).catch((e) => {
|
||||
// this.logger.error(`Failed to pull images: ${e}`);
|
||||
// throw e;
|
||||
// });
|
||||
await runComposeCommand(['--env-file', `${this.envFile}`, 'pull']);
|
||||
|
||||
spinner.done('Images pulled');
|
||||
|
||||
|
@ -244,8 +242,8 @@ export class SystemExecutors {
|
|||
spinner.setMessage('Starting containers...');
|
||||
spinner.start();
|
||||
this.logger.info('Starting containers...');
|
||||
await execAsync(`docker compose --env-file "${this.envFile}" up --detach --remove-orphans --build`);
|
||||
|
||||
await runComposeCommand(['--env-file', `${this.envFile}`, 'up', '--detach', '--remove-orphans', '--build']);
|
||||
spinner.done('Containers started');
|
||||
|
||||
// start watcher cli in the background
|
||||
|
|
|
@ -1,12 +1,29 @@
|
|||
import path from 'path';
|
||||
import { promisify } from 'util';
|
||||
import { exec } from 'child_process';
|
||||
import { exec, spawn } from 'child_process';
|
||||
import { getEnv } from '../environment/environment';
|
||||
import { pathExists } from '../fs-helpers/fs-helpers';
|
||||
import { fileLogger } from '../logger/file-logger';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
export const runComposeCommand = async (args: string[]) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const dockerCompose = spawn('docker', ['compose', ...args]);
|
||||
|
||||
dockerCompose.on('close', (code) => {
|
||||
if (code !== 0) {
|
||||
reject(new Error(`docker-compose exited with code ${code}`));
|
||||
}
|
||||
resolve('');
|
||||
});
|
||||
|
||||
dockerCompose.on('error', (error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const composeUp = async (args: string[]) => {
|
||||
const { stdout, stderr } = await execAsync(`docker compose ${args.join(' ')}`);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue