@decocms/sandbox-controller 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -2
- package/dist/index.js +14 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3715,10 +3715,10 @@ interface FreestyleSandboxProviderOptions {
|
|
|
3715
3715
|
image?: string;
|
|
3716
3716
|
/** The org-fs sidecar image. Default: the chart's `orgFs.image`. */
|
|
3717
3717
|
orgFsSidecarImage?: string;
|
|
3718
|
-
/** Pause a VM after this long without network activity. Default
|
|
3718
|
+
/** Pause a VM after this long without network activity. Default 5 min. */
|
|
3719
3719
|
idleTimeoutSeconds?: number;
|
|
3720
3720
|
/**
|
|
3721
|
-
* Delete a VM after this long without running. Default
|
|
3721
|
+
* Delete a VM after this long without running. Default 1 day. A plan
|
|
3722
3722
|
* that caps it lower gets its cap.
|
|
3723
3723
|
*/
|
|
3724
3724
|
autoDeleteSeconds?: number;
|
|
@@ -3752,6 +3752,11 @@ declare class FreestyleSandboxProvider implements SandboxProvider {
|
|
|
3752
3752
|
* A snapshot of a VM with both images already pulled, so a sandbox boots in
|
|
3753
3753
|
* seconds instead of pulling ~2GB. One per image pair; built on first use.
|
|
3754
3754
|
*/
|
|
3755
|
+
/**
|
|
3756
|
+
* Build this image's base snapshot now, so the first sandbox after an image
|
|
3757
|
+
* bump boots from it instead of waiting on the pull. Never throws.
|
|
3758
|
+
*/
|
|
3759
|
+
warm(): Promise<void>;
|
|
3755
3760
|
private baseSnapshot;
|
|
3756
3761
|
private snapshotExists;
|
|
3757
3762
|
private run;
|
package/dist/index.js
CHANGED
|
@@ -6759,7 +6759,7 @@ var Freestyle = class {
|
|
|
6759
6759
|
// ../sandbox/package.json
|
|
6760
6760
|
var package_default = {
|
|
6761
6761
|
name: "@decocms/sandbox",
|
|
6762
|
-
version: "1.
|
|
6762
|
+
version: "1.83.0",
|
|
6763
6763
|
private: true,
|
|
6764
6764
|
type: "module",
|
|
6765
6765
|
description: "Sandbox runtime for isolated Studio tool execution",
|
|
@@ -6838,7 +6838,7 @@ var WORKDIR = "/app";
|
|
|
6838
6838
|
var DEFAULT_DEV_PORT2 = 3e3;
|
|
6839
6839
|
var CONTAINER = "sandbox";
|
|
6840
6840
|
var SIDECAR = "orgfs";
|
|
6841
|
-
var DEFAULT_SIDECAR_IMAGE = "ghcr.io/decocms/studio/orgfs-sidecar:0.
|
|
6841
|
+
var DEFAULT_SIDECAR_IMAGE = "ghcr.io/decocms/studio/orgfs-sidecar:0.2.0";
|
|
6842
6842
|
var HOST_ORG_DIR = "/srv/sandbox/org";
|
|
6843
6843
|
var HOST_CTL_DIR = "/srv/sandbox/orgfs-ctl";
|
|
6844
6844
|
var CTL_DIR = "/run/orgfs";
|
|
@@ -6890,8 +6890,8 @@ var FreestyleSandboxProvider = class {
|
|
|
6890
6890
|
});
|
|
6891
6891
|
this.image = opts.image ?? `ghcr.io/decocms/studio/studio-sandbox-go:${package_default.version}`;
|
|
6892
6892
|
this.sidecarImage = opts.orgFsSidecarImage ?? DEFAULT_SIDECAR_IMAGE;
|
|
6893
|
-
this.idleTimeoutSeconds = opts.idleTimeoutSeconds ??
|
|
6894
|
-
this.autoDeleteSeconds = opts.autoDeleteSeconds ??
|
|
6893
|
+
this.idleTimeoutSeconds = opts.idleTimeoutSeconds ?? 5 * 60;
|
|
6894
|
+
this.autoDeleteSeconds = opts.autoDeleteSeconds ?? 24 * 60 * 60;
|
|
6895
6895
|
this.domainSuffix = opts.domainSuffix ?? "style.dev";
|
|
6896
6896
|
this.timeDaemonRequest = daemonProxyTimer(opts.meter);
|
|
6897
6897
|
}
|
|
@@ -6937,6 +6937,15 @@ var FreestyleSandboxProvider = class {
|
|
|
6937
6937
|
* A snapshot of a VM with both images already pulled, so a sandbox boots in
|
|
6938
6938
|
* seconds instead of pulling ~2GB. One per image pair; built on first use.
|
|
6939
6939
|
*/
|
|
6940
|
+
/**
|
|
6941
|
+
* Build this image's base snapshot now, so the first sandbox after an image
|
|
6942
|
+
* bump boots from it instead of waiting on the pull. Never throws.
|
|
6943
|
+
*/
|
|
6944
|
+
async warm() {
|
|
6945
|
+
await this.baseSnapshot().catch(
|
|
6946
|
+
(err) => console.warn(`[${LOG_LABEL2}] base snapshot warm failed: ${errMsg2(err)}`)
|
|
6947
|
+
);
|
|
6948
|
+
}
|
|
6940
6949
|
baseSnapshot() {
|
|
6941
6950
|
const { image, sidecarImage } = this;
|
|
6942
6951
|
const slug = `studio-sandbox-${createHash3("sha256").update(`${image}
|
|
@@ -7070,7 +7079,7 @@ ${sidecarImage}`).digest("hex").slice(0, 16)}`;
|
|
|
7070
7079
|
const envFlags = Object.keys(env).map((k) => `-e ${shellQuote(k)}`).join(" ");
|
|
7071
7080
|
await this.run(
|
|
7072
7081
|
vm,
|
|
7073
|
-
`sudo sh -c ${shellQuote(HOST_SETUP)} && docker run -d --name ${SIDECAR} --restart=always --privileged --device /dev/fuse -e APP_ROOT=${WORKDIR} -v ${HOST_ORG_DIR}:${WORKDIR}/org:rshared -v ${HOST_CTL_DIR}:${CTL_DIR} ${shellQuote(this.sidecarImage)}`,
|
|
7082
|
+
`sudo sh -c ${shellQuote(HOST_SETUP)} && docker run -d --name ${SIDECAR} --restart=always --privileged --device /dev/fuse -e APP_ROOT=${WORKDIR} -e ORGFS_FEED_IDLE_MS=60000 -v ${HOST_ORG_DIR}:${WORKDIR}/org:rshared -v ${HOST_CTL_DIR}:${CTL_DIR} ${shellQuote(this.sidecarImage)}`,
|
|
7074
7083
|
{ timeoutMs: IMAGE_PULL_TIMEOUT_MS }
|
|
7075
7084
|
);
|
|
7076
7085
|
await this.run(
|