diff --git a/cli/package.json b/cli/package.json index 0df7ba952..0a94d6138 100644 --- a/cli/package.json +++ b/cli/package.json @@ -9,7 +9,7 @@ }, "scripts": { "start": "yarn build && build/monitor-cli.js", - "build": "vite build && node transform.mjs && chmod +x build/monitor-cli.js", + "build": "vite build && node post-build.mjs && chmod +x build/monitor-cli.js", "publish-cli": "yarn build && cd build && npm publish --access=public && node update-version.mjs" }, "devDependencies": { diff --git a/cli/transform.mjs b/cli/post-build.mjs similarity index 100% rename from cli/transform.mjs rename to cli/post-build.mjs diff --git a/cli/src/components/mongo/SetupMongo.tsx b/cli/src/components/mongo/SetupMongo.tsx index a34279b46..82f44b5d7 100644 --- a/cli/src/components/mongo/SetupMongo.tsx +++ b/cli/src/components/mongo/SetupMongo.tsx @@ -1,7 +1,7 @@ import { CommandLogError } from "@monitor/types"; import { Box, Newline, Text, useInput } from "ink"; import React, { Fragment, useState } from "react"; -import { startMongo } from "../../helpers/mongo"; +import { startMongo } from "../../helpers/deploy/mongo"; import LabelledSelector from "../util/LabelledSelector"; import YesNo from "../util/YesNo"; diff --git a/cli/src/components/registry/SetupRegistry.tsx b/cli/src/components/registry/SetupRegistry.tsx index 0c96311d6..ae0b37bae 100644 --- a/cli/src/components/registry/SetupRegistry.tsx +++ b/cli/src/components/registry/SetupRegistry.tsx @@ -1,7 +1,7 @@ import { CommandLogError } from "@monitor/types"; import { Box, Newline, Text, useInput } from "ink"; import React, { Fragment, useState } from "react"; -import { startRegistry } from "../../helpers/registry"; +import { startRegistry } from "../../helpers/deploy/registry"; import LabelledSelector from "../util/LabelledSelector"; import YesNo from "../util/YesNo"; diff --git a/cli/src/config.ts b/cli/src/config.ts new file mode 100644 index 000000000..2d34785dc --- /dev/null +++ b/cli/src/config.ts @@ -0,0 +1,2 @@ +export const CORE_IMAGE = "mbecker2020/monitor-core"; +export const PERIPHERY_IMAGE = "mbecker2020/monitor-periphery"; diff --git a/cli/src/helpers/mongo.ts b/cli/src/helpers/deploy/mongo.ts similarity index 88% rename from cli/src/helpers/mongo.ts rename to cli/src/helpers/deploy/mongo.ts index 5a612c8ba..687146dc8 100644 --- a/cli/src/helpers/mongo.ts +++ b/cli/src/helpers/deploy/mongo.ts @@ -1,4 +1,4 @@ -import { execute } from "./execute"; +import { execute } from "../execute"; export async function startMongo( name: string, diff --git a/cli/src/helpers/deploy/monitor.ts b/cli/src/helpers/deploy/monitor.ts new file mode 100644 index 000000000..77665dfe6 --- /dev/null +++ b/cli/src/helpers/deploy/monitor.ts @@ -0,0 +1,16 @@ +import { CORE_IMAGE } from "../../config"; +import { Config } from "../../types"; +import { execute } from "../execute"; + +export async function startMonitorCore({ + monitorCore: { + + }, + mongo: { url: mongoURL }, + registry: { url: registryURL }, +}: Config) { + const command = `docker run -d --name monitor-core -e MONGO_URL=${mongoURL}${ + registryURL ? ` -e REGISTRY_URL=${registryURL}` : "" + } ${CORE_IMAGE}`; + return await execute(command); +} diff --git a/cli/src/helpers/registry.ts b/cli/src/helpers/deploy/registry.ts similarity index 88% rename from cli/src/helpers/registry.ts rename to cli/src/helpers/deploy/registry.ts index 85117cf18..cb12cadc9 100644 --- a/cli/src/helpers/registry.ts +++ b/cli/src/helpers/deploy/registry.ts @@ -1,4 +1,4 @@ -import { execute } from "./execute"; +import { execute } from "../execute"; export async function startRegistry( name: string, diff --git a/cli/src/types.d.ts b/cli/src/types.d.ts index 83cdc6b5d..b91fe10d8 100644 --- a/cli/src/types.d.ts +++ b/cli/src/types.d.ts @@ -1,10 +1,28 @@ export type Config = { - mongoURL: string; - registryURL: string; + monitorCore: { + name: string; + + }; + mongo: { + url: string; + deploymentConfig?: { + // if mongo container already exists locally running on docker and should be added as a monitor managed deployment + }; + startConfig?: { + // if this is attached, the cli will start container with this config and add + }; + }; + registry: { + exists: boolean; // if this is false, dont use a registry and builds will be disabled + url?: string; + deploymentConfig?: {}; + startConfig?: {}; + }; }; export type SetConfig = ( - field: keyof Config, + domain: keyof Config, + field: keyof Config[keyof Config], val: string | number | boolean ) => void; diff --git a/core/package.json b/core/package.json index 0d24c21fd..0d834b6b9 100644 --- a/core/package.json +++ b/core/package.json @@ -6,7 +6,7 @@ "license": "MIT", "scripts": { "start": "tsc && node build/main.js", - "build": "vite build && node transform.mjs && docker build -t mbecker2020/monitor-core .", + "build": "vite build && node post-build.mjs && docker build -t mbecker2020/monitor-core .", "docker-run": "docker run -d --name monitor-core --network=\"host\" -v /Users/max/GitHub/monitor/core/secrets:/secrets -v /Users/max/GitHub/monitor/frontend/build:/frontend mbecker2020/monitor-core", "docker-remove": "docker stop monitor-core && docker container rm monitor-core" }, diff --git a/core/transform.mjs b/core/post-build.mjs similarity index 100% rename from core/transform.mjs rename to core/post-build.mjs diff --git a/core/src/plugins/ws.ts b/core/src/plugins/ws.ts index 71a39f70d..e89b1dd1f 100644 --- a/core/src/plugins/ws.ts +++ b/core/src/plugins/ws.ts @@ -17,7 +17,7 @@ const ws = fp((app: FastifyInstance, _: {}, done: () => void) => { const messages = createObservable(); app.decorate( - "broadcast", + "broadcast", // used to sending state updates to all connected clients (type: string, msg: Action & MessageType) => { msg.type = type; messages.publish(msg); diff --git a/periphery/package.json b/periphery/package.json index 9a8a55489..56c1486c2 100644 --- a/periphery/package.json +++ b/periphery/package.json @@ -6,7 +6,7 @@ "license": "MIT", "scripts": { "start": "tsc && node build/main.js", - "build": "vite build && node transform.mjs && docker build -t mbecker2020/monitor-periphery ." + "build": "vite build && node post-build.mjs && docker build -t mbecker2020/monitor-periphery ." }, "devDependencies": { "@monitor/types": "1.0.0", diff --git a/periphery/transform.mjs b/periphery/post-build.mjs similarity index 100% rename from periphery/transform.mjs rename to periphery/post-build.mjs