mirror of
https://github.com/noodlapp/noodl-cloudservice.git
synced 2026-01-11 23:02:54 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
413e7b3fcd |
@@ -58,3 +58,16 @@ This package contains the docker image of the Noodl Self Hosted Cloud Service.
|
|||||||
**Description**: The **`MAX_UPLOAD_SIZE`** variable specifies the maximum allowed size for file uploads in the application.
|
**Description**: The **`MAX_UPLOAD_SIZE`** variable specifies the maximum allowed size for file uploads in the application.
|
||||||
|
|
||||||
**Default Value: `20mb`**
|
**Default Value: `20mb`**
|
||||||
|
|
||||||
|
### `NOODL_CLOUD_RUNTIMES_LOCATION`
|
||||||
|
|
||||||
|
**Description**: The **`NOODL_CLOUD_RUNTIMES_LOCATION`** variable specifies the URL location where to find the runtime to use.
|
||||||
|
|
||||||
|
To use the Noodl hosted cloud runtimes, use this URL:
|
||||||
|
`https://runtimes.noodl.cloud/{runtime}.js`
|
||||||
|
|
||||||
|
`{runtime}` will be replaced with the desired runtime by the Cloud Functions.
|
||||||
|
|
||||||
|
If this variable is not provided then the built in cloud runtime will be used.
|
||||||
|
|
||||||
|
**Default Value: `undefined`**
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@noodl/cloudservice-docker",
|
"name": "@noodl/cloudservice-docker",
|
||||||
"version": "0.2.5",
|
"version": "0.3.0",
|
||||||
"description": "Low-code for when experience matter",
|
"description": "Low-code for when experience matter",
|
||||||
"author": "Noodl <info@noodl.net>",
|
"author": "Noodl <info@noodl.net>",
|
||||||
"homepage": "https://noodl.net",
|
"homepage": "https://noodl.net",
|
||||||
|
|||||||
15
packages/noodl-cloudservice/package-lock.json
generated
15
packages/noodl-cloudservice/package-lock.json
generated
@@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@noodl/cloudservice",
|
"name": "@noodl/cloudservice",
|
||||||
"version": "0.2.4",
|
"version": "0.2.5",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@noodl/cloudservice",
|
"name": "@noodl/cloudservice",
|
||||||
"version": "0.2.4",
|
"version": "0.2.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@noodl/cloud-runtime": "^0.6.3",
|
||||||
"isolated-vm": "^4.4.2",
|
"isolated-vm": "^4.4.2",
|
||||||
"node-fetch": "2.6.7",
|
"node-fetch": "2.6.7",
|
||||||
"parse-server": "^4.10.4",
|
"parse-server": "^4.10.4",
|
||||||
@@ -656,6 +657,11 @@
|
|||||||
"tslib": "^2.0.1"
|
"tslib": "^2.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@noodl/cloud-runtime": {
|
||||||
|
"version": "0.6.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@noodl/cloud-runtime/-/cloud-runtime-0.6.3.tgz",
|
||||||
|
"integrity": "sha512-RZtzTSi4I5UVBEMVAhmA1OX7Gqo5mcVkHWWm51oCNk/7benNa/D+PEUmGl5VMicVrJUG+/Ca6KI+9xq0D+kr1A=="
|
||||||
|
},
|
||||||
"node_modules/@parse/fs-files-adapter": {
|
"node_modules/@parse/fs-files-adapter": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@parse/fs-files-adapter/-/fs-files-adapter-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@parse/fs-files-adapter/-/fs-files-adapter-1.2.0.tgz",
|
||||||
@@ -7405,6 +7411,11 @@
|
|||||||
"tslib": "^2.0.1"
|
"tslib": "^2.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@noodl/cloud-runtime": {
|
||||||
|
"version": "0.6.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@noodl/cloud-runtime/-/cloud-runtime-0.6.3.tgz",
|
||||||
|
"integrity": "sha512-RZtzTSi4I5UVBEMVAhmA1OX7Gqo5mcVkHWWm51oCNk/7benNa/D+PEUmGl5VMicVrJUG+/Ca6KI+9xq0D+kr1A=="
|
||||||
|
},
|
||||||
"@parse/fs-files-adapter": {
|
"@parse/fs-files-adapter": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@parse/fs-files-adapter/-/fs-files-adapter-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@parse/fs-files-adapter/-/fs-files-adapter-1.2.0.tgz",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@noodl/cloudservice",
|
"name": "@noodl/cloudservice",
|
||||||
"version": "0.2.5",
|
"version": "0.3.0",
|
||||||
"description": "Low-code for when experience matter",
|
"description": "Low-code for when experience matter",
|
||||||
"author": "Noodl <info@noodl.net>",
|
"author": "Noodl <info@noodl.net>",
|
||||||
"homepage": "https://noodl.net",
|
"homepage": "https://noodl.net",
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
"build": "npm run build:clean && npm run build:ts && npm run build:static"
|
"build": "npm run build:clean && npm run build:ts && npm run build:static"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@noodl/cloud-runtime": "^0.6.3",
|
||||||
"isolated-vm": "^4.4.2",
|
"isolated-vm": "^4.4.2",
|
||||||
"node-fetch": "2.6.7",
|
"node-fetch": "2.6.7",
|
||||||
"parse-server": "^4.10.4",
|
"parse-server": "^4.10.4",
|
||||||
|
|||||||
@@ -9,3 +9,12 @@ fs.cpSync(
|
|||||||
dist,
|
dist,
|
||||||
{ recursive: true }
|
{ recursive: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Copy the noodl cloud runtime to the dist folder
|
||||||
|
fs.copyFile(
|
||||||
|
path.join(__dirname, "../node_modules/@noodl/cloud-runtime/dist/main.js"),
|
||||||
|
path.join(__dirname, "../dist/static/cloud-runtime.js"),
|
||||||
|
(err) => {
|
||||||
|
if (err) throw err;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -219,17 +219,7 @@ export async function createContext(global: ContextGlobalState, env: CreateConte
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const _defaultRuntime = process.env.NOODL_DEFAULT_CLOUD_RUNTIME;
|
const snapshot = await getRuntimeSnapshot(cloudRuntime);
|
||||||
let runtime = cloudRuntime || _defaultRuntime;
|
|
||||||
if (!runtime.endsWith(".js")) runtime = runtime + ".js";
|
|
||||||
|
|
||||||
console.log("- Using runtime: " + runtime);
|
|
||||||
const snapshot = await getRuntimeSnapshot(
|
|
||||||
(process.env.NOODL_CLOUD_RUNTIMES_LOCATION ||
|
|
||||||
"https://runtimes.noodl.cloud") +
|
|
||||||
"/" +
|
|
||||||
runtime
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log("- Starting up isolate");
|
console.log("- Starting up isolate");
|
||||||
const isolate = new ivm.Isolate({ memoryLimit: env.memoryLimit, snapshot });
|
const isolate = new ivm.Isolate({ memoryLimit: env.memoryLimit, snapshot });
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import ivm from "isolated-vm";
|
import ivm from "isolated-vm";
|
||||||
|
import path from "path";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
// Create a snapshot of a given runtime if needed
|
// Create a snapshot of a given runtime if needed
|
||||||
// of serve from the cache
|
// of serve from the cache
|
||||||
@@ -21,20 +23,39 @@ async function fetchRuntime(url: string) {
|
|||||||
return createSnapshot(script)
|
return createSnapshot(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getRuntimeSnapshot(url: string) {
|
export async function getRuntimeSnapshot(functionRuntimeVersion: string) {
|
||||||
if (snapshots[url]) {
|
const cloudRuntimeUrl = process.env.NOODL_CLOUD_RUNTIMES_LOCATION;
|
||||||
try {
|
if (cloudRuntimeUrl) {
|
||||||
await snapshots[url];
|
const url = cloudRuntimeUrl.replace("{runtime}", functionRuntimeVersion);
|
||||||
} catch (e) {
|
if (snapshots[url]) {
|
||||||
console.log(`Disposing runtime snapshot due to error in create: `, e);
|
try {
|
||||||
delete snapshots[url];
|
await snapshots[url];
|
||||||
|
} catch (e) {
|
||||||
|
console.log(`Disposing runtime snapshot due to error in create: `, e);
|
||||||
|
delete snapshots[url];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (snapshots[url]) {
|
if (!snapshots[url]) {
|
||||||
|
snapshots[url] = fetchRuntime(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("- Using runtime: " + url);
|
||||||
return snapshots[url];
|
return snapshots[url];
|
||||||
} else {
|
|
||||||
return snapshots[url] = fetchRuntime(url);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// Create a snapshot with the builtin cloud runtime
|
||||||
|
if (!snapshots['__builtin']) {
|
||||||
|
const filePath = path.join(__dirname, '../static/cloud-runtime.js');
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
throw new Error("Failed to find builtin cloud runtime: " + filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
||||||
|
snapshots['__builtin'] = Promise.resolve(createSnapshot(fileContent));
|
||||||
|
|
||||||
|
console.log("- Using runtime: builtin");
|
||||||
|
}
|
||||||
|
|
||||||
|
return snapshots['__builtin'];
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user