-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Expand file tree
/
Copy pathdocker-compose.ts
More file actions
36 lines (27 loc) · 1014 Bytes
/
docker-compose.ts
File metadata and controls
36 lines (27 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { exec, spawn } from 'node:child_process';
import { setTimeout } from 'node:timers';
const setup = async () => {
let _resolve: () => unknown;
let _reject: (error: Error) => unknown;
const ready = new Promise<void>((resolve, reject) => {
_resolve = resolve;
_reject = reject;
});
const timeout = setTimeout(() => _reject(new Error('Timeout starting e2e environment')), 60_000);
const command = 'compose up --build --renew-anon-volumes --force-recreate --remove-orphans';
const child = spawn('docker', command.split(' '), { stdio: 'pipe' });
child.stdout.on('data', (data) => {
const input = data.toString();
console.log(input);
if (input.includes('Immich Microservices is running')) {
_resolve();
}
});
child.stderr.on('data', (data) => console.log(data.toString()));
await ready;
clearTimeout(timeout);
return async () => {
await new Promise<void>((resolve) => exec('docker compose down', () => resolve()));
};
};
export default setup;