mirror of
https://github.com/moghtech/komodo.git
synced 2026-07-16 12:02:55 -05:00
add deploy funcs
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
export const DEFAULT_PORT = 9000;
|
||||
export const DEFAULT_MONGO_URL = "mongodb://127.0.0.1:27017/monitor";
|
||||
export const DEFAULT_REGISTRY_URL = "http://127.0.0.1:5000/";
|
||||
export const DEFAULT_REGISTRY_URL = "http://127.0.0.1:5000/";
|
||||
export const CORE_IMAGE = "mbecker2020/monitor-core";
|
||||
export const PERIPHERY_IMAGE = "mbecker2020/monitor-periphery";
|
||||
40
cli/src/util/helpers/deploy.ts
Normal file
40
cli/src/util/helpers/deploy.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { CORE_IMAGE } from "../../config";
|
||||
import { Config, CoreConfig, StartConfig } from "../../types";
|
||||
import { execute } from "./execute";
|
||||
import { toDashedName } from "./general";
|
||||
|
||||
export async function deployCore({ core, mongo, registry }: Config) {
|
||||
const { name, hostNetwork, secretVolume, port } = core!;
|
||||
const nameConfig = `--name ${toDashedName(name)}`;
|
||||
const volume = `-v ${secretVolume}:/secrets`;
|
||||
const network = hostNetwork ? '--network="host"' : `-p ${port}:9000`;
|
||||
const env = `-e MONGO_URL=${mongo?.url} -e REGISTRY_URL=${registry?.url}${
|
||||
hostNetwork ? ` -e PORT=${port}` : ""
|
||||
}`;
|
||||
const command = `docker run -d ${nameConfig} ${volume} ${network} ${env} ${CORE_IMAGE}`;
|
||||
return await execute(command);
|
||||
}
|
||||
|
||||
export async function deployMongo({
|
||||
name,
|
||||
port,
|
||||
volume,
|
||||
restart,
|
||||
}: StartConfig) {
|
||||
const command = `docker run -d --name ${name} -p ${port}:27017${
|
||||
volume ? ` -v ${volume}:/data/db` : ""
|
||||
} --restart ${restart} mongo:latest`;
|
||||
return await execute(command);
|
||||
}
|
||||
|
||||
export async function deployRegistry({
|
||||
name,
|
||||
port,
|
||||
volume,
|
||||
restart,
|
||||
}: StartConfig) {
|
||||
const command = `docker run -d --name ${name} -p ${port}:5000${
|
||||
volume ? ` -v ${volume}:/var/lib/registry` : ""
|
||||
} --restart ${restart} registry:2`;
|
||||
return await execute(command);
|
||||
}
|
||||
Reference in New Issue
Block a user