-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstallation.js
34 lines (28 loc) · 1.4 KB
/
Installation.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
import { selectServices, selectTag, enterParams, selectNetwork, selectDependsOn } from '../utils/ServicePrompts.js';
import { copyIncFiles, getServices } from '../utils/FileOperations.js';
import { renderTemplate } from '../utils/TemplateRendering.js';
import { loadDockerCompose, updateDockerCompose } from '../utils/DockerComposeOperations.js';
import config from '../../config.js';
async function handleService(serviceName, networks) {
const tagAnswer = await selectTag(serviceName);
const params = await enterParams(serviceName);
const networkAnswer = await selectNetwork(serviceName, networks);
const installedServices = await getServices(config.dockerServicesDestination);
let dependsOnAnswer = { dependsOn: [] };
if (installedServices.length > 0) {
dependsOnAnswer = await selectDependsOn(serviceName, installedServices);
}
const dockerComposeContent = renderTemplate(serviceName, tagAnswer.imageTag, params);
updateDockerCompose(serviceName, dockerComposeContent, networkAnswer.network, dependsOnAnswer.dependsOn);
copyIncFiles(serviceName);
}
async function install() {
const dockerCompose = loadDockerCompose();
const networks = Object.keys(dockerCompose.networks || {});
const docker = await selectServices();
const servicePromise = handleService(docker.services, networks);
await Promise.all([servicePromise]);
}
export default {
install,
};