fix refactor deployment

This commit is contained in:
Simon Larsen
2022-11-08 15:24:58 +00:00
parent 522ffad4d3
commit f1cf299611
58 changed files with 352 additions and 23558 deletions

6
.gitignore vendored
View File

@@ -60,4 +60,8 @@ GoSDK/tester/
.gitconfig
secret.env
secret.env
*/.env
config.env

View File

@@ -1 +0,0 @@
SAMPLE=test

View File

@@ -1 +0,0 @@
CLUSTER_KEY=test

0
AdminDashboard/.env.tpl Normal file
View File

View File

@@ -1 +0,0 @@
CLUSTER_KEY=test

1
Alert/.env.tpl Normal file
View File

@@ -0,0 +1 @@
ONEUPTIME_SECRET={{ .Env.ONEUPTIME_SECRET }}

0
ApiDocs/.env.tpl Normal file
View File

View File

@@ -30,7 +30,7 @@ export const AirtableApiKey: string = process.env['AIRTABLE_API_KEY'] || '';
export const AirtableBaseId: string = process.env['AIRTABLE_BASE_ID'] || '';
export const ClusterKey: ObjectID = new ObjectID(
process.env['CLUSTER_KEY'] || ''
process.env['ONEUPTIME_SECRET'] || ''
);
export const RealtimeHostname: Hostname = Hostname.fromString(

View File

@@ -1,4 +1,4 @@
import { ClusterKey as CLUSTER_KEY } from '../Config';
import { ClusterKey as ONEUPTIME_SECRET } from '../Config';
import {
ExpressRequest,
ExpressResponse,
@@ -34,7 +34,7 @@ export default class ClusterKeyAuthorization {
);
}
const isAuthorized: boolean = clusterKey === CLUSTER_KEY;
const isAuthorized: boolean = clusterKey === ONEUPTIME_SECRET;
if (!isAuthorized) {
return Response.sendErrorResponse(

View File

@@ -9,7 +9,7 @@ import {
OneUptimeRequest,
} from '../Utils/Express';
import { ClusterKey as CLUSTER_KEY } from '../Config';
import { ClusterKey as ONEUPTIME_SECRET } from '../Config';
import ObjectID from 'Common/Types/ObjectID';
import LocalCache from '../Infrastructure/LocalCache';
import Probe from 'Model/Models/Probe';
@@ -82,7 +82,7 @@ export default class ProbeMiddleware {
throw new BadDataException('Probe version not found.');
}
if (clusterKey && clusterKey === CLUSTER_KEY) {
if (clusterKey && clusterKey === ONEUPTIME_SECRET) {
/*
* If cluster key matches then just query by probe name,
* Because if the probe key does not match, we can update probe key later
@@ -129,7 +129,7 @@ export default class ProbeMiddleware {
}
}
if (!probeId && (!clusterKey || clusterKey !== CLUSTER_KEY)) {
if (!probeId && (!clusterKey || clusterKey !== ONEUPTIME_SECRET)) {
throw new BadDataException(
'Probe key and probe name do not match.'
);

View File

@@ -14,7 +14,7 @@ class Service {
public constructor() {
this.api = new API(HttpProtocol, RealtimeHostname);
this.headers = {
CLUSTER_KEY: ClusterKey.toString(),
ONEUPTIME_SECRET: ClusterKey.toString(),
};
}

View File

@@ -41,6 +41,6 @@ export default {
serverUrl: process.env['SERVER_URL'],
containerScannerName: process.env['CONTAINER_SCANNER_NAME'],
containerScannerKey: process.env['CONTAINER_SCANNER_KEY'],
clusterKey: process.env['CLUSTER_KEY'],
clusterKey: process.env['ONEUPTIME_SECRET'],
containerScannerVersion: packageJson.version,
};

View File

@@ -35,6 +35,6 @@ RUN apk add curl
COPY haraka.sh /
RUN chmod 755 /haraka.sh
EXPOSE $PORT
EXPOSE 2525
CMD ["/haraka.sh"]

View File

@@ -40,7 +40,7 @@ spec:
value: {{ $.Values.applicationScanner.name }}
- name: APPLICATION_SCANNER_KEY
value: {{ $.Values.applicationScanner.key }}
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -126,7 +126,7 @@ spec:
value: {{ $.Values.logstashHost | quote }}
- name: LOGSTASH_PORT
value: {{ $.Values.logstashPort | quote }}
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -40,7 +40,7 @@ spec:
value: {{ $.Values.containerScanner.name }}
- name: CONTAINER_SCANNER_KEY
value: {{ $.Values.containerScanner.key }}
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -39,7 +39,7 @@ spec:
value: {{ template "oneuptime.scriptRunnerUrl" $ }}
- name: REALTIME_URL
value: {{ template "oneuptime.realtimeUrl" $ }}
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -46,7 +46,7 @@ spec:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}
key: encryptionkey
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -36,7 +36,7 @@ spec:
value: {{ template "oneuptime.serverUrl" $ }}
- name: IS_SAAS_SERVICE
value: 'true'
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -34,7 +34,7 @@ spec:
limits:
cpu: 700m
env:
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -62,7 +62,7 @@ spec:
value: {{ template "oneuptime.probeApiUrl" $ }}
- name: RESOURCES_LIMIT
value: '10'
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -51,7 +51,7 @@ spec:
fieldPath: spec.serviceAccountName
- name: PORT
value: {{ $.Values.host.realtimePort | quote }}
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -56,7 +56,7 @@ spec:
value: {{ template "oneuptime.serverUrl" $ }}
- name: IS_SAAS_SERVICE
value: 'true'
- name: CLUSTER_KEY
- name: ONEUPTIME_SECRET
valueFrom:
configMapKeyRef:
name: {{ printf "%s-%s" $.Release.Name "configmap" }}

View File

@@ -1,14 +0,0 @@
import { question } from 'zx';
import ScriptOptions from './Types/ScriptOptions';
import Compile from './Services/Compile';
await (async (): Promise<void> => {
const token: $TSFixMe = await question('Choose Option: ', {
choices: [ScriptOptions.CompileTypeScript],
});
if (token === ScriptOptions.CompileTypeScript) {
await Compile.compileAllTypeScriptProjects();
}
})();

View File

@@ -0,0 +1,41 @@
// This script merges config.env.tpl to config.env
import fs from 'fs';
try {
const tempate = fs.readFileSync('./config.env.tpl', 'utf8');
const env = fs.readFileSync('./config.env', 'utf8');
const linesInTemplate = tempate.split("\n");
const linesInEnv = env.split("\n");
for (const line of linesInTemplate) {
// this is a comment, ignore.
if (line.startsWith("//")) {
continue;
}
// comment. Ignore.
if (line.startsWith("#")) {
continue;
}
// if the line is present in template but is not present in env file then add it to the env file. We assume, values in template file are default values.
if (line.split("=").length > 0) {
if (linesInEnv.filter((envLine) => {
return envLine.split("=").length > 0 && envLine.split("=")[0] === line.split("=")[0]
}).length === 0) {
linesInEnv.push(line);
}
}
}
// write the file back to disk and exit.
fs.writeFileSync('./config.env', linesInEnv.join("\n"));
} catch (err) {
console.error(err);
}

View File

@@ -1,13 +0,0 @@
import Project from '../Utils/Projects';
import { $ } from 'zx';
export default class Compile {
public static async compileAllTypeScriptProjects(): Promise<void> {
const projects: $TSFixMe = Project.getProjects();
for (const project of projects) {
await $`cd ${project.path}`;
await $`npm run compile`;
await $`cd ..`;
}
}
}

View File

@@ -1,8 +0,0 @@
export default interface Project {
path: string;
name: string;
isApiServer: boolean;
isReact: boolean;
isTypeScript: boolean;
isDependency: boolean;
}

View File

@@ -1,5 +0,0 @@
enum ScriptOptions {
CompileTypeScript = 'Compile all typescript projects',
}
export default ScriptOptions;

View File

@@ -1,227 +0,0 @@
import ProjectType from '../Types/Project';
class Project {
public static getProjects(): Array<ProjectType> {
return [
{
name: 'licensing',
path: 'licensing',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'dashboard',
path: 'dashboard',
isReact: true,
isApiServer: false,
isTypeScript: false,
isDependency: false,
},
{
name: 'AdminDashboard',
path: 'AdminDashboard',
isReact: true,
isApiServer: false,
isTypeScript: false,
isDependency: false,
},
{
name: 'accounts',
path: 'accounts',
isReact: true,
isApiServer: false,
isTypeScript: false,
isDependency: false,
},
{
name: 'StatusPage',
path: 'StatusPage',
isReact: true,
isApiServer: false,
isTypeScript: false,
isDependency: false,
},
{
name: 'HttpTestServer',
path: 'HttpTestServer',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'ApiDocs',
path: 'ApiDocs',
isReact: false,
isApiServer: false,
isTypeScript: true,
isDependency: false,
},
{
name: 'backend',
path: 'backend',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'ApplicationScanner',
path: 'aplication-scanner',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'common',
path: 'common',
isReact: false,
isApiServer: true,
isTypeScript: true,
isDependency: true,
},
{
name: 'CommonUI',
path: 'CommonUI',
isReact: true,
isApiServer: false,
isTypeScript: true,
isDependency: true,
},
{
name: 'CommonServer',
path: 'CommonServer',
isReact: false,
isApiServer: true,
isTypeScript: true,
isDependency: true,
},
{
name: 'data-ingestor',
path: 'data-ingestor',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'HelmChart',
path: 'HelmChart',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'home',
path: 'home',
isReact: false,
isApiServer: true,
isTypeScript: true,
isDependency: false,
},
{
name: 'InitScript',
path: 'InitScript',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'JavaScriptSDK',
path: 'JavaScriptSDK',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'licesning',
path: 'licesning',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'LighthouseRunner',
path: 'LighthouseRunner',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'oneuptime-acme-http-01',
path: 'oneuptime-acme-http-01',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'oneuptime-gl-manager',
path: 'oneuptime-gl-manager',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'oneuptime-le-store',
path: 'oneuptime-le-store',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'probe',
path: 'probe',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'ProbeAPI',
path: 'ProbeAPI',
isReact: false,
isApiServer: true,
isTypeScript: true,
isDependency: false,
},
{
name: 'ScriptRunner',
path: 'ScriptRunner',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'realtime',
path: 'realtime',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
{
name: 'zapier',
path: 'zapier',
isReact: false,
isApiServer: true,
isTypeScript: false,
isDependency: false,
},
];
}
}
export default Project;

1291
Scripts/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +0,0 @@
{
"name": "scripts",
"version": "1.0.0",
"description": "This package is for automating misc tasks",
"main": "generate_coupons.js",
"type": "commonjs",
"scripts": {
"preinstall": "npx npm-force-resolutions || echo 'No package-lock.json file. Skipping force resolutions'",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "zx ./build/dist/index.js",
"compile": "tsc"
},
"resolutions": {},
"devDependencies": {
"npm-force-resolutions": "0.0.10"
},
"author": "",
"license": "MIT",
"dependencies": {
"ts-node": "^10.7.0",
"typescript": "^4.6.3",
"zx": "^6.0.7"
}
}

View File

@@ -1,103 +0,0 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Projects */
// "incremental": true, /* Enable incremental compilation */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "es2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "react" /* Specify what JSX code is generated. */,
"experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
"emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
// "module": "es2022" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
"typeRoots": [
], /* Specify multiple folders that act like `./node_modules/@types`. */
"types": ["node"], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "resolveJsonModule": true, /* Enable importing .json files */
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
"outDir": "./build/dist", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
/* Interop Constraints */
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
"strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
"strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
"strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
"strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
"noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
"useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
"noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
"exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
"noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
"noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
"noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

View File

@@ -1,3 +0,0 @@
# Readme
This is a temporary directory to do manual testing of various components.

View File

@@ -1,48 +0,0 @@
import oneuptime from 'oneuptime-staging'
// constructor
// set up tracking configurations
const options: $TSFixMe = {
maxTimeline: 10,
};
// constructor
const tracker: $TSFixMe = new oneuptime.ErrorTracker(
'https://staging.oneuptime.com/api',
'605bad70ae110c0013e14005',
'cb4b107a-7f28-464d-9fda-32715fa4cd68',
options // Optional Field
);
// capturing a timeline manually
tracker.addToTimeline(
'payment',
{ account: 'debit', amount: '6000.00', userId: 401 },
'info'
);
// setting custom tags
tracker.setTag('category', 'Customer'); // a single tag
tracker.setTags([
{ key: 'type', value: 'notice' },
{ key: 'location', value: 'online' },
]); // an array of tags
// capturing error exception authomatically
NonExistingMethodCall(); // this is authomatically captured and sent to your oneuptime dashboard
// capturing error exception manually
try {
// your code logic
NonExistingMethodCall();
} catch (error) {
tracker.captureException(error);
}
// capturing error message
tracker.captureMessage('Message');

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +0,0 @@
{
"name": "error-tracker",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"type": "module",
"dependencies": {
"oneuptime-staging": "^3.0.9531"
}
}

View File

@@ -1,23 +0,0 @@
// In a FrontEnd Environment
import oneuptime from 'oneuptime-staging';
const Logger: $TSFixMe = oneuptime.Logger;
// constructor
const logger: $TSFixMe = new Logger(
'https://staging.oneuptime.com/api',
'6053aae39b79460013b35102',
'4904db2d-968c-4656-b6c0-aac450c97ee2'
);
// Sending a JSON object log to the server
const item: $TSFixMe = {
user: 'Test User',
page: {
title: 'Landing Page',
loadTime: '6s',
},
};
logger.log(item); // returns a promise

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +0,0 @@
{
"name": "logger",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"type": "module",
"dependencies": {
"oneuptime-staging": "^3.0.9421"
}
}

5057
_test/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +0,0 @@
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"type": "module",
"dependencies": {
"oneuptime-staging": "^4.0.34"
}
}

View File

@@ -1,45 +0,0 @@
import express, { Request, Response } from 'CommonServer/utils/Express'
import OneUptime from 'oneuptime-staging'
const app: $TSFixMe = express()
import axios from 'axios'
// set up performance tracker configuration
const options: $TSFixMe = {
apiUrl: 'https://staging.oneuptime.com/api',
appId: '609975b682d0790014cba640',
appKey: '9a715493-f7d5-4b50-a229-7ae79a5d2336',
app, // express app instance (optional field)
};
// constructor
new OneUptime.PerformanceTracker(
options
);
app.get('/', (req: ExpressRequest, res: ExpressResponse) => {
res.send({ status: "ok" })
})
app.get('/error', (req: ExpressRequest, res: ExpressResponse) => {
res.status(500).send({ error: "Error" })
})
app.get('/outgoing-requests', async (req: ExpressRequest, res: ExpressResponse) => {
await axios('https://google.com');
res.send({ status: "ok" })
})
app.get('/user/:id', async (req: ExpressRequest, res: ExpressResponse) => {
res.send({ user: req.params['id'] })
})
app.post('/post', async (req: ExpressRequest, res: ExpressResponse) => {
res.send({ "status": "this is a post request" })
})
app.listen(4050, function ():void {
logger.info("Server running on PORT: " + 4050)
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +0,0 @@
{
"name": "performance-tracker",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"type": "module",
"dependencies": {
"express": "^4.17.1",
"oneuptime-staging": "^3.0.10585"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +0,0 @@
{
"name": "script-monitor",
"version": "1.0.0",
"description": "Test for script monitor",
"main": "index.ts",
"scripts": {
"test": "mocha ."
},
"author": "Dave",
"license": "MIT",
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^8.4.0",
"request": "^2.88.2"
},
"type": "module",
"dependencies": {
"axios": "^0.21.1",
"express": "^4.17.1",
"vm2": "^3.9.2"
}
}

View File

@@ -1,125 +0,0 @@
import { expect } from "chai"
import { runScript } from "./scriptSandbox"
import axios from 'axios';
describe('ScriptMonitor V2', function ():void {
this.timeout(10000);
describe("runScript function", function ():void {
let server: $TSFixMe;
// create a quick express server
before(function ():void {
import express from "express"
const app: $TSFixMe = express.getExpressApp();
app.get("/test", (req: ExpressRequest, res: ExpressResponse) => res.send("yipee!"));
server = app.listen(5050);
});
// close express server
after(function ():void {
server.close();
});
it("should return success for a valid script", async function ():void {
const someFunction: Function = async (done: $TSFixMe): void => {
const res: $TSFixMe = await axios.get("http://localhost:5050/test");
done();
}
const result: $TSFixMe = await runScript(someFunction.toString(), true);
expect(result).to.not.be.undefined;
expect(result.success).to.be.true;
expect(result.status).eq("completed");
expect(result.executionTime).to.be.a('number');
console.log(result.executionTime);
expect(result.consoleLogs.length).eql(2);
expect(result.consoleLogs).to.include('[log]: hello');
expect(result.consoleLogs).to.include('[log]: world!');
});
it("should return false for error thrown in script", async function ():void {
const someFunction: Function = async (done: $TSFixMe): void => {
console.log('Error log');
logger.error('Bad Error');
throw new Error("Bad error");
}
const result: $TSFixMe = await runScript(someFunction.toString(), true);
expect(result).to.not.be.undefined;
expect(result.success).to.be.false;
expect(result.status).eq("error");
expect(result.executionTime).to.be.a('number');
console.log(result.executionTime);
expect(result.consoleLogs.length).eql(2);
expect(result.consoleLogs).to.include('[error]: Bad Error');
expect(result.consoleLogs).to.include('[log]: Error log');
});
it("should return scriptMonitor error when script returns a value in cb", async function ():void {
const someFunction: Function = async (done: $TSFixMe): void => {
done("Some Error");
}
const result: $TSFixMe = await runScript(someFunction.toString(), true);
expect(result).to.be.ok;
expect(result.success).to.be.false;
expect(result.message).to.be.string("Script monitor resource error");
expect(result.errors).to.be.ok;
expect(result.status).eq("nonEmptyCallback");
expect(result.executionTime).to.be.a('number');
console.log(result.executionTime);
});
it("should return timeout error when script takes too long", async function ():void {
const someFunction: Function = async (done: $TSFixMe): void => {
return new Promise((resolve) => {
setTimeout(() => "All timed out", 7000);
})
}
const result: $TSFixMe = await runScript(someFunction.toString(), true, { maxScriptRunTime: 1500 });
expect(result).to.be.ok;
expect(result.success).to.be.false;
expect(result.message).contains("Max. script execution time exceeded");
expect(result.status).eq("timeout");
expect(result.executionTime).to.be.a('number');
console.log(result.executionTime);
});
it("should return timeout error when statement takes too long", async function ():void {
const someFunction: Function = async (done: $TSFixMe): void => {
while (true) {
// statement stuck in loop or too busy
}
}
const result: $TSFixMe = await runScript(someFunction.toString(), true, { maxSyncStatementDuration: 300 });
expect(result).to.be.ok;
expect(result.success).to.be.false;
expect(result.message).contains("Max. synchronous statement execution time exceeded");
expect(result.status).eq("timeout");
expect(result.executionTime).to.be.a('number');
console.log(result.executionTime);
});
});
});

View File

@@ -1,224 +0,0 @@
import { join } from "path"
import { performance } from 'perf_hooks'
import {
isMainThread,
Worker,
parentPort,
workerData,
} from 'worker_threads';
// TODO - make this configurable from AdminDashboard
const runConfig: $TSFixMe = {
availableImports: ['axios'], // init allowed modules
maxSyncStatementDuration: 3000,
maxScriptRunTime: 5000,
};
class ScriptMonitorError extends Error {
errors: $TSFixMe;
public constructor(errors: $TSFixMe, message = "Script monitor resource error") {
super();
this.message = message;
this.errors = Array.isArray(errors)
? errors.reduce(
(allErr: $TSFixMe, err: $TSFixMe)[...allErr, err.message].join(','),
[]
)
: (errors.message ?? errors);
}
}
const {
availableImports,
maxScriptRunTime,
maxSyncStatementDuration,
} = runConfig;
const runScript: Function = async (functionCode: $TSFixMe, isCalled: $TSFixMe, options = { maxScriptRunTime, maxSyncStatementDuration }): void => {
if (isMainThread) {
// modifiable option in development mode only
const { maxScriptRunTime, maxSyncStatementDuration } = options;
if (!isCalled) return;
const start: $TSFixMe = performance.now();
return new Promise((resolve: $TSFixMe) => {
const worker: $TSFixMe = new Worker(__filename, {
workerData: { functionCode },
execArgv: [
...process.execArgv,
'--unhandled-rejections=strict',
], // handle promise rejection warnings
});
const consoleLogs: $TSFixMe = [];
let lastMessage: $TSFixMe = null;
worker.on('message', ({
type,
payload
}: $TSFixMe) => {
switch (type) {
case 'ping': {
lastMessage = Date.now();
break;
}
case 'log': {
consoleLogs.push(payload);
break;
}
default: {
if (type.error) {
resolve({
success: false,
error: type.error,
status: 'error',
executionTime: performance.now() - start,
consoleLogs,
});
}
break;
}
}
});
worker.on('online', () => {
lastMessage = Date.now();
});
worker.on('exit', (exitCode: $TSFixMe) => {
switch (exitCode) {
case 0:
resolve({
success: true,
status: 'completed',
executionTime: performance.now() - start,
consoleLogs,
});
break;
case 1: {
const message: $TSFixMe = statementTimeExceeded
? `Max. synchronous statement execution time exceeded (${maxSyncStatementDuration}ms)`
: scriptTimeExceeded
? `Max. script execution time exceeded (${maxScriptRunTime}ms)`
: 'Script was terminated';
resolve({
success: false,
message,
status: 'timeout',
executionTime: performance.now() - start,
consoleLogs,
});
break;
}
default:
resolve({
success: false,
message: 'Unknown Error: script terminated',
status: 'terminated',
executionTime: performance.now() - start,
consoleLogs,
});
break;
}
clearInterval(checker);
});
worker.on('error', (err: $TSFixMe) => {
if (err.errors) {
resolve({
success: false,
message: err.message,
errors: err.errors,
status: 'nonEmptyCallback',
executionTime: performance.now() - start,
consoleLogs,
});
return;
}
resolve({
success: false,
message: err.message,
status: 'error',
executionTime: performance.now() - start,
consoleLogs,
});
clearInterval(checker);
worker.terminate();
});
let totalRuntime: $TSFixMe = 0,
statementTimeExceeded = false,
scriptTimeExceeded = false;
const checker: $TSFixMe = setInterval(
() => {
totalRuntime += 1000;
if (totalRuntime > maxScriptRunTime) {
clearInterval(checker);
scriptTimeExceeded = true;
worker.terminate();
}
// Last ping was too long ago, terminate it
if (
lastMessage !== null &&
Date.now() - lastMessage >= maxSyncStatementDuration
) {
clearInterval(checker);
statementTimeExceeded = true;
worker.terminate();
}
},
1000,
maxSyncStatementDuration
);
});
} else {
// worker_threads code
import { NodeVM } from 'vm2'
const vm: $TSFixMe = new NodeVM({
eval: false,
wasm: false,
require: {
root: './',
external: availableImports,
import: availableImports,
},
console: 'redirect',
});
vm.on('logger.info', (log: $TSFixMe) => {
parentPort.postMessage({ type: 'log', payload: `[log]: ${log}` });
});
vm.on('logger.error', (error: $TSFixMe) => {
parentPort.postMessage({ type: 'log', payload: `[error]: ${error}` });
});
vm.on('console.warn', (error: $TSFixMe) => {
parentPort.postMessage({ type: 'log', payload: `[warn]: ${error}` });
});
const scriptCompletedCallback: Function = (err: $TSFixMe): void => {
if (err) {
throw new ScriptMonitorError(err);
}
};
const code: $TSFixMe = workerData.functionCode;
setInterval(() => parentPort.postMessage({ type: 'ping' }), 500);
const sandboxFunction: $TSFixMe = await vm.run(
`export default ${code}`,
join(process.cwd(), 'node_modules')
);
await sandboxFunction(scriptCompletedCallback);
process.exit();
}
};
export default runScript();
module.exports.runScript = runScript;

View File

@@ -1,84 +0,0 @@
<div class="bubble-box">
<div id="oneuptime-status-bubble"></div>
<div id="oneuptime-bubble-text"></div>
</div>
<style>
.all {
width: 20px;
height: 20px;
border-radius: 50%;
margin-right: 5px;
background-color: rgba(108, 219, 86);
}
.some {
width: 20px;
height: 20px;
border-radius: 50%;
margin-right: 5px;
background-color: rgba(250, 109, 70);
}
.none {
width: 20px;
height: 20px;
border-radius: 50%;
margin-right: 5px;
background-color: rgba(250, 109, 70);
}
.degraded {
width: 20px;
height: 20px;
border-radius: 50%;
margin-right: 5px;
background-color: rgba(255, 222, 36);
}
.text {
color: rgb(76, 76, 76);
font-size: 13px;
padding-top: 4px;
}
.bubble-box {
display: flex;
flex-direction: row;
}
</style>
<script language="javascript" type="text/javascript">
function initializeBubble() {
var placeholderDiv = document.getElementById('oneuptime-status-bubble');
var placeholderTitleDiv = document.getElementById(
'oneuptime-bubble-text'
);
var bubble = 'all';
var statusMessage = '';
var url =
'https://staging.oneuptime.com/api/StatusPage/statusBubble?statusPageId=5ffa98e25f166c0014d9c045&statusBubbleId=04013896-dcbe-40bd-8f1d-f4825badd782';
fetch(url, {
method: 'GET',
headers: {
'Access-Control-Allow-Origin': '*',
Accept: 'application/json',
'Content-Type': 'application/json;charset=UTF-8',
},
})
.then(response => response.json())
.then(json => {
bubble = json && json.bubble ? json.bubble : null;
statusMessage =
json && json.statusMessage ? json.statusMessage : null;
if (bubble === 'all') {
placeholderDiv.className = 'all';
} else if (bubble === 'some') {
placeholderDiv.className = 'some';
} else if (bubble === 'none') {
placeholderDiv.className = 'none';
} else if (bubble === 'some-degraded') {
placeholderDiv.className = 'degraded';
}
placeholderTitleDiv.className = 'text';
placeholderTitleDiv.innerHTML = statusMessage;
})
.catch(err => logger.error(err));
}
window.onload = function() {
initializeBubble();
};
</script>

14
config.env.tpl Normal file
View File

@@ -0,0 +1,14 @@
# What image should we pull from docker hub. This only applies when the ENVIRONMENT is production or test
APP_TAG=latest
# This supports test | production | development.
# Development is used for local development. Test is used for insider / beta / staging builds. Production is used for production ready app.
ENVIRONMENT=production
# IS BILLING ENABLED for this installer.
BILLING_ENABLED=false
# Public and private key for billing provider, usually stripe.
BILLING_PUBLIC_KEY=
BILLING_PRIVATE_KEY=

View File

@@ -1,382 +0,0 @@
# This docker file is for CI.
# It it builds and tests docker containers in the CI pipeline.
version: '3.7'
x-common-variables: &common-variables
IS_SAAS_SERVICE: ${IS_SAAS_SERVICE}
services:
postgres:
image: postgres:latest
restart: always
env_file:
- ./Postgres/.env
ports:
- '5400:5432'
volumes:
- postgres:/var/lib/postgresql/data
saml:
image: kenchan0130/simplesamlphp
ports:
- 9876:8080
- 8443:8443
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./SAML/.env
volumes:
- ./saml/users.php:/var/www/simplesamlphp/config/authsources.php
redis:
image: redis:7.0.3
ports:
- '6379:6379'
command: redis-server
env_file:
- ./Redis/.env
dashboard-api:
ports:
- '3002:3002'
build:
context: .
dockerfile: ./DashboardAPI/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./DashboardAPI/.env
environment: *common-variables
depends_on:
- redis
- postgres
workers:
ports:
- '3452:3452'
build:
context: .
dockerfile: ./Workers/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Workers/.env
environment: *common-variables
depends_on:
- postgres
- mail
file:
ports:
- '3125:3125'
build:
context: .
dockerfile: ./File/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./File/.env
environment: *common-variables
depends_on:
- redis
- postgres
identity:
ports:
- '3087:3087'
build:
context: .
dockerfile: ./Identity/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Identity/.env
environment: *common-variables
depends_on:
- redis
- postgres
- mail
alert:
ports:
- '3088:3088'
build:
context: .
dockerfile: ./Alert/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Alert/.env
environment: *common-variables
depends_on:
- redis
- postgres
integration:
ports:
- '3089:3089'
build:
context: .
dockerfile: ./Integration/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Integration/.env
environment: *common-variables
depends_on:
- redis
- postgres
accounts:
ports:
- '3003:3003'
build:
context: .
dockerfile: ./Accounts/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./Accounts/.env
environment: *common-variables
depends_on:
- identity
dashboard:
ports:
- '3009:3009'
build:
context: .
dockerfile: ./Dashboard/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./Dashboard/.env
environment: *common-variables
depends_on:
- dashboard-api
- accounts
status-page:
ports:
- '3105:3105'
build:
context: .
dockerfile: ./StatusPage/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./Dashboard/.env
environment: *common-variables
depends_on:
- dashboard-api
home:
ports:
- '1444:1444'
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./Home/.env
environment: *common-variables
build:
context: .
dockerfile: ./Home/Dockerfile
admin-dashboard:
ports:
- '3100:3100'
build:
context: .
dockerfile: ./AdminDashboard/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./AdminDashboard/.env
environment: *common-variables
depends_on:
- dashboard-api
- accounts
http-test-server:
ports:
- '3010:3010'
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./HttpTestServer/.env
environment: *common-variables
build:
context: .
dockerfile: ./HttpTestServer/Dockerfile
licensing:
ports:
- '3004:3004'
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Licensing/.env
environment: *common-variables
build:
context: .
dockerfile: ./Licensing/Dockerfile
realtime:
ports:
- '3300:3300'
build:
context: .
dockerfile: ./Realtime/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Realtime/.env
environment: *common-variables
helmchart:
ports:
- '3423:3423'
build:
context: .
dockerfile: ./HelmChart/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./HelmChart/.env
environment: *common-variables
probe-api:
ports:
- '3400:3400'
build:
context: .
dockerfile: ./ProbeAPI/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./ProbeAPI/.env
environment: *common-variables
probe1:
build:
context: .
dockerfile: ./Probe/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Probe/.env
environment:
<<: *common-variables
PROBE_NAME: Probe 1
PROBE_KEY: test-key
depends_on:
- dashboard-api
probe2:
build:
context: .
dockerfile: ./Probe/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Probe/.env
environment:
<<: *common-variables
PROBE_NAME: Probe 2
PROBE_KEY: test-key
depends_on:
- dashboard-api
api-docs:
ports:
- '1445:1445'
build:
context: .
dockerfile: ./ApiDocs/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./ApiDocs/.env
environment: *common-variables
haraka:
ports:
- '2525:2525'
build:
context: ./Haraka
args:
PORT: '2525'
env_file:
- ./Haraka/.env
mail:
ports:
- 3190:3190
build:
context: .
dockerfile: ./Mail/Dockerfile
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Mail/.env
environment: *common-variables
depends_on:
- haraka
- postgres
nginx:
depends_on:
- dashboard-api
- home
- dashboard
- accounts
- admin-dashboard
restart: always
build:
dockerfile: Dockerfile
context: ./Nginx
ports:
- '80:80'
- '443:443'
volumes:
postgres:

View File

@@ -1,11 +1,5 @@
# This docker file is for development.
# It connects to debugging ports that help you debug the app.
version: '3.7'
x-common-variables: &common-variables
IS_SAAS_SERVICE: ${IS_SAAS_SERVICE}
services:
##IMPORTANT:
## This container is an SMTP server used to send emails.
@@ -16,10 +10,18 @@ services:
build:
network: host
context: ./Haraka
args:
PORT: '2525'
env_file:
- ./Haraka/.env
redis:
image: redis:7.0.3
ports:
- '6379:6379'
command: redis-server /usr/local/etc/redis/redis.conf
env_file:
- ./Redis/.env
volumes:
- ./Redis/redis.conf:/usr/local/etc/redis/redis.conf
postgres:
image: postgres:latest
@@ -33,22 +35,28 @@ services:
mail:
ports:
{{ if eq .Env.ENVIRONMENT "development" }}
- 9110:9229 # Debugging port.
{{ end }}
- 3190:3190
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./Mail/Dockerfile.dev
dockerfile: ./Mail/Dockerfile
{{ else }}
image: oneuptime/mail:{{ .Env.APP_TAG }}
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Mail/.env
environment: *common-variables
depends_on:
- haraka
- postgres
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./Mail:/usr/src/app
# Use node modules of the container and not host system.
@@ -62,46 +70,30 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
saml:
image: kenchan0130/simplesamlphp
ports:
- 9876:8080
- 8443:8443
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./SAML/.env
volumes:
- ./SAML/users.php:/var/www/simplesamlphp/config/authsources.php
redis:
image: redis:7.0.3
ports:
- '6379:6379'
command: redis-server /usr/local/etc/redis/redis.conf
env_file:
- ./Redis/.env
volumes:
- ./Redis/redis.conf:/usr/local/etc/redis/redis.conf
accounts:
ports:
- '3003:3003'
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./Accounts/Dockerfile.dev
dockerfile: ./Accounts/Dockerfile
{{ else }}
image: oneuptime/accounts:{{ .Env.APP_TAG }}
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./Accounts/.env
environment: *common-variables
depends_on:
- identity
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./Accounts:/usr/src/app
# Use node modules of the container and not host system.
@@ -115,23 +107,29 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
dashboard:
ports:
- '3009:3009'
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./Dashboard/Dockerfile.dev
dockerfile: ./Dashboard/Dockerfile
{{ else }}
image: oneuptime/dashboard:{{ .Env.APP_TAG }}
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./Accounts/.env
environment: *common-variables
depends_on:
- identity
- accounts
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./Dashboard:/usr/src/app
- /usr/src/app/node_modules/
@@ -143,24 +141,30 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
status-page:
ports:
- '3105:3105'
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./StatusPage/Dockerfile.dev
dockerfile: ./StatusPage/Dockerfile
{{ else }}
image: oneuptime/status-page:{{ .Env.APP_TAG }}
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonUI/.env
- ./StatusPage/.env
environment: *common-variables
depends_on:
- accounts
- dashboard-api
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./StatusPage:/usr/src/app
- /usr/src/app/node_modules/
@@ -172,22 +176,29 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
dashboard-api:
ports:
- '3002:3002'
{{ if eq .Env.ENVIRONMENT "development" }}
- '9232:9229' # Debugging port.
{{ end }}
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./DashboardAPI/Dockerfile.dev
dockerfile: ./DashboardAPI/Dockerfile
{{ else }}
image: oneuptime/dashboard-api:{{ .Env.APP_TAG }}
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./DashboardAPI/.env
environment: *common-variables
depends_on:
- redis
- postgres
@@ -196,6 +207,7 @@ services:
- redis
- postgres
- mail
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./DashboardAPI:/usr/src/app
# Use node modules of the container and not host system.
@@ -209,30 +221,38 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
workers:
ports:
- '3452:3452'
{{ if eq .Env.ENVIRONMENT "development" }}
- '9654:9229' # Debugging port.
{{ end }}
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./Workers/Dockerfile.dev
dockerfile: ./Workers/Dockerfile
{{ else }}
image: oneuptime/workers:{{ .Env.APP_TAG }}
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Workers/.env
environment: *common-variables
depends_on:
- postgres
- mail
links:
- postgres
- mail
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./Workers:/usr/src/app
# Use node modules of the container and not host system.
@@ -246,26 +266,32 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
identity:
ports:
- '3087:3087'
{{ if eq .Env.ENVIRONMENT "development" }}
- '9132:9229' # Debugging port.
{{ end }}
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./Identity/Dockerfile.dev
dockerfile: ./Identity/Dockerfile
{{ else }}
image: oneuptime/identity:{{ .Env.APP_TAG }}
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Identity/.env
environment: *common-variables
depends_on:
- redis
- postgres
@@ -274,6 +300,7 @@ services:
- redis
- postgres
- mail
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./Identity:/usr/src/app
# Use node modules of the container and not host system.
@@ -287,27 +314,35 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
file:
ports:
- '3125:3125'
{{ if eq .Env.ENVIRONMENT "development" }}
- '9012:9229' # Debugging port.
{{ end }}
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./File/Dockerfile.dev
dockerfile: ./File/Dockerfile
{{ else }}
image: oneuptime/file:{{ .Env.APP_TAG }}
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./File/.env
environment: *common-variables
depends_on:
- postgres
links:
- postgres
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./File:/usr/src/app
# Use node modules of the container and not host system.
@@ -321,23 +356,30 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
home:
ports:
- '1444:1444'
{{ if eq .Env.ENVIRONMENT "development" }}
- '9235:9229' # Debugging port.
{{ end }}
env_file:
- ./Common/.env
- ./Common/secret.env
- ./CommonServer/.env
- ./CommonServer/secret.env
- ./Home/.env
environment: *common-variables
{{ if eq .Env.ENVIRONMENT "development" }}
build:
network: host
context: .
dockerfile: ./Home/Dockerfile.dev
dockerfile: ./Home/Dockerfile
{{ else }}
image: oneuptime/home:{{ .Env.APP_TAG }}
{{ end }}
{{ if eq .Env.ENVIRONMENT "development" }}
volumes:
- ./Home:/usr/src/app
# Use node modules of the container and not host system.
@@ -351,6 +393,7 @@ services:
- /usr/src/CommonUI/node_modules/
- /usr/src/CommonServer/node_modules/
- /usr/src/Model/node_modules/
{{ end }}
nginx:

View File

@@ -1,5 +0,0 @@
DKIM_PRIVATE_KEY=LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcFFJQkFBS0NBUUVBd0U0R1hxai9lODQ4VW1mNkttN0xsQUliZnpFTG5VbmdHQVc0NXBhYzhKelZoNzRNCmloVWZPZnB5cGNJVXZHSnFOaHRuSHJnRHE1Wk9QQTlNc2pFM1drYXQyZ2dUV0V2RFhDY3d0eHZVWnU3blpudkIKK3cxMzVRajNQeGZGVE1Tb1c4VWR5cHQ3UXlpRUhpVXVPZGNrVFhKM2sra1U5Qk41OVgxNmhPQlJtN2JkcnNNagpNQlEvNUQ3VHRjMGJ5TjBnd2dBUit6OXhueFFQWWpwNEtmaE1XWUxXRjFLTHdPQUZoZ1E4eFp3ZF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OMAIN=test.oneuptime.com
IS_SAAS_SERVICE=true

View File

@@ -1,6 +1,64 @@
#!/usr/bin/env bash
chmod +x env-setup.sh
set -e
bash ./env-setup.sh
#Docker compose up as a daemon.
sudo -E docker-compose up -d --build
bash preinstall.sh
if [[ ! $(which docker) && ! $(docker --version) ]]; then
echo "Setting up Docker"
sudo curl -sSL https://get.docker.com/ | sh
fi
# If docker still fails to install, then quit.
if [[ ! $(which docker) && ! $(docker --version) ]]; then
echo -e "Failed to install docker. Please install Docker manually here: https://docs.docker.com/install."
echo -e "Exiting the OneUptime installer."
exit
fi
# enable docker without sudo
sudo usermod -aG docker "${USER}" || true
if [[ ! $(which docker-compose) && ! $(docker-compose --version) ]]; then
mkdir -p /usr/local/lib/docker/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/lib/docker/cli-plugins
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
docker compose version
fi
# If docker still fails to install, then quit.
if [[ ! $(which docker-compose) && ! $(docker-compose --version) ]]; then
echo -e "Failed to install docker-domcpose. Please install Docker Compose manually here: https://docs.docker.com/compose/install/linux/#install-the-plugin-manually."
echo -e "Exiting the OneUptime installer."
exit
fi
echo "We will need to wait ~5-10 minutes for things to settle down, migrations to finish, and TLS certs to be issued"
echo ""
echo "⏳ Waiting for OneUptime to boot (this will take a few minutes)"
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/api/status)" != "200" ]]; do sleep 5; done'
echo "Progress 1/5"
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/dashboard/status)" != "200" ]]; do sleep 5; done'
echo "Progress 2/5"
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/status)" != "200" ]]; do sleep 5; done'
echo "Progress 3/5"
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost/staus-page/status)" != "200" ]]; do sleep 5; done'
echo "Progress 4/5"
echo "⌛️ OneUptime is up!"
echo ""
echo "🎉🎉🎉 Done! 🎉🎉🎉"
echo "We would like to hear your feedback to make this product better for you and for other users, please email us at hello@oneuptime.com."
echo " - If you notice a bug, we will fix it for you."
echo " - If you need a feature, we will add that to the roadmap and let you know the estimated time to ship."
echo "We would love to hear your feedback. Email: hello@oneuptime.com"

116
preinstall.sh Normal file
View File

@@ -0,0 +1,116 @@
#!/usr/bin/env bash
set -e
export ONEUPTIME_APP_TAG="${ONEUPTIME_APP_TAG:-latest}"
ONEUPTIME_SECRET=$(head -c 28 /dev/urandom | sha224sum -b | head -c 56)
export ONEUPTIME_SECRET
# Talk to the user
echo "Welcome to the single instance OneUptime 🟢 installer"
echo ""
echo "⚠️ You really need 8gb or more of memory to run this stack ⚠️"
echo ""
echo ""
echo "Please enter your sudo password now:"
sudo echo ""
echo "Thanks! 🙏"
echo ""
echo "Ok! We'll take it from here 🚀"
echo "Making sure any stack that might exist is stopped"
# If docker-compose is installed and if docker-compose.yml is found then, stop the stack.
if [[ $(which docker-compose) ]]; then
if [ -f ./docker-compose.yml ]; then
sudo -E docker-compose -f docker-compose.yml stop || true
fi
fi
# If Mac
if [[ "$OSTYPE" == "darwin"* ]]; then
if [[ ! $(which brew) ]]; then
echo "Homebrew not installed. Please install homebrew and restart installer"
exit
fi
fi
# If linux
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "Grabbing latest apt caches"
sudo apt update
fi
# clone oneuptime
echo "Installing OneUptime 🟢"
if [[ ! $(which git) ]]; then
if [[ "$OSTYPE" != "darwin"* ]]; then
sudo apt install -y git
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install git
fi
fi
GIT_REPO_URL=$(git config --get remote.origin.url)
if [[ $GIT_REPO_URL != *oneuptime.git ]] # * is used for pattern matching
then
git clone https://github.com/OneUptime/oneuptime.git || true
cd oneuptime
fi
# try to clone - if folder is already there pull latest for that branch
git pull
cd ..
if [[ ! $(which node) && ! $(node --version) ]]; then
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "Setting up NodeJS"
sudo apt-get install -y nodejs
sudo apt-get install -y npm
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install nodejs
fi
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install gomplate
fi
if [[ "$OSTYPE" != "darwin"* ]]; then
sudo apt-get install -y gomplate
fi
cd oneuptime
# Create .env file if it does not exist.
touch config.env
#Run a scirpt to merge config.env.tpl to config.env
node ./Scripts/Install/MergeEnvTemplate.js
echo "Config file has been generated at config.env. Please look at the config, make changes and when you're done - hit enter to continue with the setup."
read -r ENTER
# Load env values from config.env
export $(grep -v '^#' config.env | xargs)
# Write env vars in config files.
for d in */ ; do
if [ -f /$d/.env.tpl ]; then
cat /$d/.env.tpl | gomplate > /$d/.env
fi
done
# Write this to docker-compose.
cat docker-compose.yml.tpl | gomplate > docker-compose.yml