-
Notifications
You must be signed in to change notification settings - Fork 18
/
install-and-run-deep.js
48 lines (40 loc) · 1.32 KB
/
install-and-run-deep.js
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
37
38
39
40
41
42
43
44
45
46
47
48
const { spawn } = require('child_process');
const execCommand = async (command) => {
return new Promise((resolve, reject) => {
const childProcess = spawn(command, {
stdio: 'inherit',
shell: true
});
childProcess.on('error', (error) => {
reject(error);
});
childProcess.on('exit', (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Command exited with code ${code}.`));
}
});
});
};
(async () => {
try {
console.log('Install docker and docker-compose...');
// For Ubuntu, you can use these commands to install docker and docker-compose
await execCommand('sudo apt-get update');
await execCommand('sudo apt-get install -y docker.io docker-compose');
console.log('Install dependencies...');
await execCommand('npm ci');
await execCommand('npm run packages');
console.log('Start the local server...');
const startLocal = execCommand('npm run local');
console.log('Wait for local server to start...');
await new Promise(resolve => setTimeout(resolve, 10000));
console.log('Run local migrations...');
await execCommand(`npm run local-migrate`);
console.log('Rejoin local server logs...');
await startLocal;
} catch (error) {
console.error(`Error: ${error.message}`);
}
})();