Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await system.run(`docker image inspect ${DOCKER_CURL}`);
print.info(
`docker image ${print.colors.success('✔')} ${print.colors.warning(
DOCKER_CURL
)} already exists`
);
} catch (err) {
const spinner1 = print.spin(
`Fetching ${print.colors.warning(DOCKER_CURL)} image`
);
await system.run(`docker pull ${DOCKER_CURL}`);
spinner1.succeed();
}
const port = await getPort();
const spinner2 = print.spin(
`Starting dummy HTTP server on port ${print.colors.warning(
port
)} and fetch IP`
);
const server = await startServer(port);
// check the list, and ping inside of docker to see if it's reachable
const ips = await Promise.map(listDeviceIps(), async ip => {
const reachable = await isIpReachableInsideDocker(ip.address, port);
return {
...ip,
reachable,
};
}).filter(ip => ip.reachable);
async function getReachableIP() {
print.info(`Starting Docker IP Detection`);
try {
await system.run(`docker image inspect ${DOCKER_CURL}`);
print.info(
`docker image ${print.colors.success('✔')} ${print.colors.warning(
DOCKER_CURL
)} already exists`
);
} catch (err) {
const spinner1 = print.spin(
`Fetching ${print.colors.warning(DOCKER_CURL)} image`
);
await system.run(`docker pull ${DOCKER_CURL}`);
spinner1.succeed();
}
const port = await getPort();
const spinner2 = print.spin(
`Starting dummy HTTP server on port ${print.colors.warning(
port
)} and fetch IP`
);
const server = await startServer(port);
// check the list, and ping inside of docker to see if it's reachable
const ips = await Promise.map(listDeviceIps(), async ip => {
return async ({ cmd, msg, options }) => {
const command = `docker-compose -f "${compose}" ${cmd}`;
if (async) {
const spinner = msg && print.spin(msg);
try {
const output = await system.run(command);
msg && spinner.succeed();
return output;
} catch (err) {
msg && spinner.fail(err.stderr);
throw err;
}
}
return execSync(command, options);
};
}