@alchemy.run/daytona 0.0.0-stage → 2.0.0-beta.86
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/LICENSE +201 -0
- package/README.md +80 -2
- package/lib/ApiKey.d.ts +99 -0
- package/lib/ApiKey.d.ts.map +1 -0
- package/lib/ApiKey.js +152 -0
- package/lib/ApiKey.js.map +1 -0
- package/lib/AuthProvider.d.ts +55 -0
- package/lib/AuthProvider.d.ts.map +1 -0
- package/lib/AuthProvider.js +280 -0
- package/lib/AuthProvider.js.map +1 -0
- package/lib/Bootstrap.d.ts +8 -0
- package/lib/Bootstrap.d.ts.map +1 -0
- package/lib/Bootstrap.js +28 -0
- package/lib/Bootstrap.js.map +1 -0
- package/lib/ConnectSandbox.d.ts +72 -0
- package/lib/ConnectSandbox.d.ts.map +1 -0
- package/lib/ConnectSandbox.js +3 -0
- package/lib/ConnectSandbox.js.map +1 -0
- package/lib/ConnectSandboxHttp.d.ts +5 -0
- package/lib/ConnectSandboxHttp.d.ts.map +1 -0
- package/lib/ConnectSandboxHttp.js +22 -0
- package/lib/ConnectSandboxHttp.js.map +1 -0
- package/lib/Contributions.d.ts +7 -0
- package/lib/Contributions.d.ts.map +1 -0
- package/lib/Contributions.js +6 -0
- package/lib/Contributions.js.map +1 -0
- package/lib/CreateSandbox.d.ts +86 -0
- package/lib/CreateSandbox.d.ts.map +1 -0
- package/lib/CreateSandbox.js +3 -0
- package/lib/CreateSandbox.js.map +1 -0
- package/lib/CreateSandboxHttp.d.ts +5 -0
- package/lib/CreateSandboxHttp.d.ts.map +1 -0
- package/lib/CreateSandboxHttp.js +65 -0
- package/lib/CreateSandboxHttp.js.map +1 -0
- package/lib/CreateSecret.d.ts +56 -0
- package/lib/CreateSecret.d.ts.map +1 -0
- package/lib/CreateSecret.js +3 -0
- package/lib/CreateSecret.js.map +1 -0
- package/lib/CreateSecretHttp.d.ts +5 -0
- package/lib/CreateSecretHttp.d.ts.map +1 -0
- package/lib/CreateSecretHttp.js +39 -0
- package/lib/CreateSecretHttp.js.map +1 -0
- package/lib/CreateSnapshot.d.ts +80 -0
- package/lib/CreateSnapshot.d.ts.map +1 -0
- package/lib/CreateSnapshot.js +3 -0
- package/lib/CreateSnapshot.js.map +1 -0
- package/lib/CreateSnapshotHttp.d.ts +5 -0
- package/lib/CreateSnapshotHttp.d.ts.map +1 -0
- package/lib/CreateSnapshotHttp.js +47 -0
- package/lib/CreateSnapshotHttp.js.map +1 -0
- package/lib/CreateVolume.d.ts +81 -0
- package/lib/CreateVolume.d.ts.map +1 -0
- package/lib/CreateVolume.js +10 -0
- package/lib/CreateVolume.js.map +1 -0
- package/lib/CreateVolumeHttp.d.ts +5 -0
- package/lib/CreateVolumeHttp.d.ts.map +1 -0
- package/lib/CreateVolumeHttp.js +31 -0
- package/lib/CreateVolumeHttp.js.map +1 -0
- package/lib/Credentials.d.ts +9 -0
- package/lib/Credentials.d.ts.map +1 -0
- package/lib/Credentials.js +18 -0
- package/lib/Credentials.js.map +1 -0
- package/lib/DaytonaBindings.d.ts +51 -0
- package/lib/DaytonaBindings.d.ts.map +1 -0
- package/lib/DaytonaBindings.js +61 -0
- package/lib/DaytonaBindings.js.map +1 -0
- package/lib/IdentityProvider.d.ts +80 -0
- package/lib/IdentityProvider.d.ts.map +1 -0
- package/lib/IdentityProvider.js +111 -0
- package/lib/IdentityProvider.js.map +1 -0
- package/lib/MountVolume.d.ts +86 -0
- package/lib/MountVolume.d.ts.map +1 -0
- package/lib/MountVolume.js +27 -0
- package/lib/MountVolume.js.map +1 -0
- package/lib/OAuthClient.d.ts +14 -0
- package/lib/OAuthClient.d.ts.map +1 -0
- package/lib/OAuthClient.js +23 -0
- package/lib/OAuthClient.js.map +1 -0
- package/lib/Organization.d.ts +40 -0
- package/lib/Organization.d.ts.map +1 -0
- package/lib/Organization.js +80 -0
- package/lib/Organization.js.map +1 -0
- package/lib/OrganizationInvitation.d.ts +70 -0
- package/lib/OrganizationInvitation.d.ts.map +1 -0
- package/lib/OrganizationInvitation.js +109 -0
- package/lib/OrganizationInvitation.js.map +1 -0
- package/lib/OrganizationMember.d.ts +86 -0
- package/lib/OrganizationMember.d.ts.map +1 -0
- package/lib/OrganizationMember.js +109 -0
- package/lib/OrganizationMember.js.map +1 -0
- package/lib/OrganizationOtelConfig.d.ts +59 -0
- package/lib/OrganizationOtelConfig.d.ts.map +1 -0
- package/lib/OrganizationOtelConfig.js +87 -0
- package/lib/OrganizationOtelConfig.js.map +1 -0
- package/lib/OrganizationRole.d.ts +66 -0
- package/lib/OrganizationRole.d.ts.map +1 -0
- package/lib/OrganizationRole.js +106 -0
- package/lib/OrganizationRole.js.map +1 -0
- package/lib/OrganizationSettings.d.ts +76 -0
- package/lib/OrganizationSettings.d.ts.map +1 -0
- package/lib/OrganizationSettings.js +107 -0
- package/lib/OrganizationSettings.js.map +1 -0
- package/lib/Providers.d.ts +14 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +53 -0
- package/lib/Providers.js.map +1 -0
- package/lib/ReadAuditLogs.d.ts +30 -0
- package/lib/ReadAuditLogs.d.ts.map +1 -0
- package/lib/ReadAuditLogs.js +17 -0
- package/lib/ReadAuditLogs.js.map +1 -0
- package/lib/ReadOrganization.d.ts +39 -0
- package/lib/ReadOrganization.d.ts.map +1 -0
- package/lib/ReadOrganization.js +39 -0
- package/lib/ReadOrganization.js.map +1 -0
- package/lib/ReadUsage.d.ts +31 -0
- package/lib/ReadUsage.d.ts.map +1 -0
- package/lib/ReadUsage.js +17 -0
- package/lib/ReadUsage.js.map +1 -0
- package/lib/Region.d.ts +78 -0
- package/lib/Region.d.ts.map +1 -0
- package/lib/Region.js +169 -0
- package/lib/Region.js.map +1 -0
- package/lib/Registry.d.ts +84 -0
- package/lib/Registry.d.ts.map +1 -0
- package/lib/Registry.js +97 -0
- package/lib/Registry.js.map +1 -0
- package/lib/Runner.d.ts +66 -0
- package/lib/Runner.d.ts.map +1 -0
- package/lib/Runner.js +116 -0
- package/lib/Runner.js.map +1 -0
- package/lib/Sandbox.d.ts +376 -0
- package/lib/Sandbox.d.ts.map +1 -0
- package/lib/Sandbox.js +565 -0
- package/lib/Sandbox.js.map +1 -0
- package/lib/SandboxClient.d.ts +258 -0
- package/lib/SandboxClient.d.ts.map +1 -0
- package/lib/SandboxClient.js +233 -0
- package/lib/SandboxClient.js.map +1 -0
- package/lib/Secret.d.ts +93 -0
- package/lib/Secret.d.ts.map +1 -0
- package/lib/Secret.js +130 -0
- package/lib/Secret.js.map +1 -0
- package/lib/Snapshot.d.ts +327 -0
- package/lib/Snapshot.d.ts.map +1 -0
- package/lib/Snapshot.js +447 -0
- package/lib/Snapshot.js.map +1 -0
- package/lib/Volume.d.ts +99 -0
- package/lib/Volume.d.ts.map +1 -0
- package/lib/Volume.js +152 -0
- package/lib/Volume.js.map +1 -0
- package/lib/WarmPool.d.ts +61 -0
- package/lib/WarmPool.d.ts.map +1 -0
- package/lib/WarmPool.js +81 -0
- package/lib/WarmPool.js.map +1 -0
- package/lib/Webhooks.d.ts +58 -0
- package/lib/Webhooks.d.ts.map +1 -0
- package/lib/Webhooks.js +75 -0
- package/lib/Webhooks.js.map +1 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +36 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/BuildContext.d.ts +16 -0
- package/lib/internal/BuildContext.d.ts.map +1 -0
- package/lib/internal/BuildContext.js +50 -0
- package/lib/internal/BuildContext.js.map +1 -0
- package/lib/internal/Declared.d.ts +29 -0
- package/lib/internal/Declared.d.ts.map +1 -0
- package/lib/internal/Declared.js +31 -0
- package/lib/internal/Declared.js.map +1 -0
- package/lib/internal/Derived.d.ts +40 -0
- package/lib/internal/Derived.d.ts.map +1 -0
- package/lib/internal/Derived.js +64 -0
- package/lib/internal/Derived.js.map +1 -0
- package/lib/internal/Errors.d.ts +4 -0
- package/lib/internal/Errors.d.ts.map +1 -0
- package/lib/internal/Errors.js +1 -0
- package/lib/internal/Errors.js.map +1 -0
- package/lib/internal/Labels.d.ts +20 -0
- package/lib/internal/Labels.d.ts.map +1 -0
- package/lib/internal/Labels.js +22 -0
- package/lib/internal/Labels.js.map +1 -0
- package/lib/internal/Names.d.ts +18 -0
- package/lib/internal/Names.d.ts.map +1 -0
- package/lib/internal/Names.js +25 -0
- package/lib/internal/Names.js.map +1 -0
- package/lib/internal/Organization.d.ts +27 -0
- package/lib/internal/Organization.d.ts.map +1 -0
- package/lib/internal/Organization.js +32 -0
- package/lib/internal/Organization.js.map +1 -0
- package/lib/internal/Process.d.ts +14 -0
- package/lib/internal/Process.d.ts.map +1 -0
- package/lib/internal/Process.js +15 -0
- package/lib/internal/Process.js.map +1 -0
- package/lib/internal/Program.d.ts +83 -0
- package/lib/internal/Program.d.ts.map +1 -0
- package/lib/internal/Program.js +169 -0
- package/lib/internal/Program.js.map +1 -0
- package/lib/internal/Ref.d.ts +14 -0
- package/lib/internal/Ref.d.ts.map +1 -0
- package/lib/internal/Ref.js +7 -0
- package/lib/internal/Ref.js.map +1 -0
- package/lib/internal/Scoped.d.ts +31 -0
- package/lib/internal/Scoped.d.ts.map +1 -0
- package/lib/internal/Scoped.js +48 -0
- package/lib/internal/Scoped.js.map +1 -0
- package/lib/internal/Tar.d.ts +13 -0
- package/lib/internal/Tar.d.ts.map +1 -0
- package/lib/internal/Tar.js +62 -0
- package/lib/internal/Tar.js.map +1 -0
- package/lib/internal/Toolbox.d.ts +11 -0
- package/lib/internal/Toolbox.d.ts.map +1 -0
- package/lib/internal/Toolbox.js +20 -0
- package/lib/internal/Toolbox.js.map +1 -0
- package/lib/internal/Wait.d.ts +49 -0
- package/lib/internal/Wait.d.ts.map +1 -0
- package/lib/internal/Wait.js +57 -0
- package/lib/internal/Wait.js.map +1 -0
- package/package.json +79 -3
- package/src/ApiKey.ts +221 -0
- package/src/AuthProvider.ts +406 -0
- package/src/Bootstrap.ts +55 -0
- package/src/ConnectSandbox.ts +76 -0
- package/src/ConnectSandboxHttp.ts +26 -0
- package/src/Contributions.ts +9 -0
- package/src/CreateSandbox.ts +107 -0
- package/src/CreateSandboxHttp.ts +97 -0
- package/src/CreateSecret.ts +73 -0
- package/src/CreateSecretHttp.ts +58 -0
- package/src/CreateSnapshot.ts +133 -0
- package/src/CreateSnapshotHttp.ts +77 -0
- package/src/CreateVolume.ts +104 -0
- package/src/CreateVolumeHttp.ts +50 -0
- package/src/Credentials.ts +37 -0
- package/src/DaytonaBindings.ts +111 -0
- package/src/IdentityProvider.ts +181 -0
- package/src/MountVolume.ts +122 -0
- package/src/OAuthClient.ts +27 -0
- package/src/Organization.ts +121 -0
- package/src/OrganizationInvitation.ts +174 -0
- package/src/OrganizationMember.ts +174 -0
- package/src/OrganizationOtelConfig.ts +138 -0
- package/src/OrganizationRole.ts +167 -0
- package/src/OrganizationSettings.ts +187 -0
- package/src/Providers.ts +93 -0
- package/src/ReadAuditLogs.ts +50 -0
- package/src/ReadOrganization.ts +83 -0
- package/src/ReadUsage.ts +51 -0
- package/src/Region.ts +226 -0
- package/src/Registry.ts +164 -0
- package/src/Runner.ts +166 -0
- package/src/Sandbox.ts +927 -0
- package/src/SandboxClient.ts +625 -0
- package/src/Secret.ts +203 -0
- package/src/Snapshot.ts +685 -0
- package/src/Volume.ts +229 -0
- package/src/WarmPool.ts +128 -0
- package/src/Webhooks.ts +121 -0
- package/src/globals.d.ts +2 -0
- package/src/index.ts +46 -0
- package/src/internal/BuildContext.ts +62 -0
- package/src/internal/Declared.ts +80 -0
- package/src/internal/Derived.ts +97 -0
- package/src/internal/Errors.ts +4 -0
- package/src/internal/Labels.ts +39 -0
- package/src/internal/Names.ts +37 -0
- package/src/internal/Organization.ts +40 -0
- package/src/internal/Process.ts +25 -0
- package/src/internal/Program.ts +239 -0
- package/src/internal/Ref.ts +15 -0
- package/src/internal/Scoped.ts +102 -0
- package/src/internal/Tar.ts +72 -0
- package/src/internal/Toolbox.ts +27 -0
- package/src/internal/Wait.ts +105 -0
package/lib/Snapshot.js
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import * as BuildPlan from "@alchemy.run/docker/BuildPlan";
|
|
3
|
+
import * as DockerfileParser from "@alchemy.run/docker/DockerfileParser";
|
|
4
|
+
import { computeStaticSourceHash, makeContainerImageSource, } from "@alchemy.run/docker/ImageSource";
|
|
5
|
+
import * as dockerRegistry from "@distilled.cloud/daytona/docker_registry";
|
|
6
|
+
import * as sandboxes from "@distilled.cloud/daytona/sandbox";
|
|
7
|
+
import * as snapshots from "@distilled.cloud/daytona/snapshots";
|
|
8
|
+
import { Unowned } from "alchemy/AdoptPolicy";
|
|
9
|
+
import { isResolved } from "alchemy/Diff";
|
|
10
|
+
import * as Provider from "alchemy/Provider";
|
|
11
|
+
import { Resource } from "alchemy/Resource";
|
|
12
|
+
import * as Data from "effect/Data";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Stream from "effect/Stream";
|
|
15
|
+
import { uploadBuildContext } from "./internal/BuildContext.js";
|
|
16
|
+
import { declarable } from "./internal/Declared.js";
|
|
17
|
+
import { createInternalLabels } from "./internal/Labels.js";
|
|
18
|
+
import { isOwnedName, resolveName } from "./internal/Names.js";
|
|
19
|
+
import { runCommand } from "./internal/Process.js";
|
|
20
|
+
import { resolved } from "./internal/Ref.js";
|
|
21
|
+
import { waitForState, waitUntilGone } from "./internal/Wait.js";
|
|
22
|
+
/**
|
|
23
|
+
* A Daytona snapshot: the image sandboxes boot from, with its default
|
|
24
|
+
* size. Pull one from a registry, build one from a Dockerfile on
|
|
25
|
+
* Daytona's builders, or capture one from a sandbox after running setup
|
|
26
|
+
* commands in it (a warm base to fork from).
|
|
27
|
+
*
|
|
28
|
+
* Snapshots are immutable: changing what one is built from replaces it.
|
|
29
|
+
* Daytona deactivates a snapshot after two weeks without use; deploy
|
|
30
|
+
* reactivates it.
|
|
31
|
+
* @see https://www.daytona.io/docs/en/snapshots/
|
|
32
|
+
*
|
|
33
|
+
* ### Pulling an Image
|
|
34
|
+
* **Example:** A public image with a size
|
|
35
|
+
* ```typescript
|
|
36
|
+
* export const Node = Daytona.Snapshot("Node", {
|
|
37
|
+
* image: "node:22-bookworm",
|
|
38
|
+
* cpu: 2,
|
|
39
|
+
* memory: 4,
|
|
40
|
+
* disk: 10,
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* ### Building from a Dockerfile
|
|
45
|
+
* **Example:** An inline Dockerfile built by Daytona
|
|
46
|
+
* ```typescript
|
|
47
|
+
* export const Base = Daytona.Snapshot("Base", {
|
|
48
|
+
* dockerfile: Dockerfile.inline`
|
|
49
|
+
* FROM node:22-bookworm
|
|
50
|
+
* RUN apt-get update && apt-get install -y git ripgrep
|
|
51
|
+
* `,
|
|
52
|
+
* cpu: 2,
|
|
53
|
+
* memory: 4,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* ### Building a Directory
|
|
58
|
+
* **Example:** A Dockerfile and the files it copies
|
|
59
|
+
* ```typescript
|
|
60
|
+
* export const App = Daytona.Snapshot("App", {
|
|
61
|
+
* context: "./sandbox",
|
|
62
|
+
* build: { args: { NODE_ENV: "production" } },
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* ### Building with Local Docker
|
|
67
|
+
* **Example:** A build that reads a private npm token
|
|
68
|
+
* ```typescript
|
|
69
|
+
* export const App = Daytona.Snapshot("App", {
|
|
70
|
+
* context: "./sandbox",
|
|
71
|
+
* build: {
|
|
72
|
+
* remote: false,
|
|
73
|
+
* secrets: { npmrc: Redacted.make(process.env.NPM_TOKEN!) },
|
|
74
|
+
* },
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* ### A Warm Base to Fork From
|
|
79
|
+
* **Example:** Clone and install once, then start every sandbox from it
|
|
80
|
+
* ```typescript
|
|
81
|
+
* export const Warm = Daytona.Snapshot("Warm", {
|
|
82
|
+
* from: Base,
|
|
83
|
+
* run: [
|
|
84
|
+
* "git clone https://github.com/alchemy-run/alchemy /home/daytona/alchemy",
|
|
85
|
+
* "cd /home/daytona/alchemy && pnpm install",
|
|
86
|
+
* ],
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* ### Looking up an existing snapshot
|
|
91
|
+
* `Snapshot.lookup` references a snapshot Alchemy doesn't manage (created in
|
|
92
|
+
* the Daytona dashboard or by another stack). It is read during plan/deploy,
|
|
93
|
+
* never created, updated or deleted.
|
|
94
|
+
* `buildHash` is empty: the image wasn't built by this stack.
|
|
95
|
+
*
|
|
96
|
+
* **Example:** Start a sandbox from an existing snapshot
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const base = Daytona.Snapshot.lookup({ name: "python-ml" });
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @resource
|
|
102
|
+
* @product Snapshot
|
|
103
|
+
*/
|
|
104
|
+
export const Snapshot = declarable()(Resource("Daytona.Snapshot"));
|
|
105
|
+
/**
|
|
106
|
+
* What Daytona's builders can build: any Dockerfile, for amd64. Daytona's
|
|
107
|
+
* build request has no field for build arguments, so the plan bakes them
|
|
108
|
+
* into `ARG` defaults, nor for BuildKit secrets, so the plan rejects them.
|
|
109
|
+
*/
|
|
110
|
+
export const capabilities = {
|
|
111
|
+
target: "Daytona.Snapshot",
|
|
112
|
+
buildArgs: false,
|
|
113
|
+
secrets: false,
|
|
114
|
+
platforms: ["linux/amd64"],
|
|
115
|
+
};
|
|
116
|
+
/** The snapshot props name more than one of `image`, `dockerfile` and `from`, or none. */
|
|
117
|
+
export class SnapshotSourceInvalid extends Data.TaggedError("Daytona.SnapshotSourceInvalid") {
|
|
118
|
+
}
|
|
119
|
+
/** A runtime build's Dockerfile copies local files, which only a deploy-time `context` can provide. */
|
|
120
|
+
export class SnapshotContextUnsupported extends Data.TaggedError("Daytona.SnapshotContextUnsupported") {
|
|
121
|
+
get message() {
|
|
122
|
+
return `A snapshot built at runtime can't copy local files (${this.line.trim()}). Declare it with Daytona.Snapshot and a \`context\`, or fetch the files in a RUN step.`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** A `run` command exited non-zero while building a snapshot from a sandbox. */
|
|
126
|
+
export class SnapshotRunFailed extends Data.TaggedError("Daytona.SnapshotRunFailed") {
|
|
127
|
+
get message() {
|
|
128
|
+
return `\`${this.command}\` exited ${this.exitCode} while building the snapshot:\n${this.output.slice(-2000)}`;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** The image has no tag, or a moving one Daytona rejects. */
|
|
132
|
+
export class SnapshotImageTagInvalid extends Data.TaggedError("Daytona.SnapshotImageTagInvalid") {
|
|
133
|
+
get message() {
|
|
134
|
+
return `Daytona needs an image with a fixed tag or digest; got ${this.image} (latest, lts and stable are rejected)`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const sha256 = (value) => Effect.sync(() => createHash("sha256").update(JSON.stringify(value)).digest("hex"));
|
|
138
|
+
const refName = (ref) => Effect.succeed(ref === undefined ? undefined : resolved(ref).name);
|
|
139
|
+
const checkImage = (image) => {
|
|
140
|
+
const last = image.split("/").at(-1) ?? image;
|
|
141
|
+
const tag = image.includes("@")
|
|
142
|
+
? "digest"
|
|
143
|
+
: last.includes(":")
|
|
144
|
+
? last.split(":").at(-1)
|
|
145
|
+
: undefined;
|
|
146
|
+
return tag === undefined || ["latest", "lts", "stable"].includes(tag)
|
|
147
|
+
? Effect.fail(new SnapshotImageTagInvalid({ image }))
|
|
148
|
+
: Effect.void;
|
|
149
|
+
};
|
|
150
|
+
/** The Dockerfile's text for Daytona; the plan has baked build arguments in. */
|
|
151
|
+
const dockerfileText = (plan) => DockerfileParser.render(plan.dockerfile);
|
|
152
|
+
/**
|
|
153
|
+
* Check Dockerfile content built at runtime (a Worker has no file system,
|
|
154
|
+
* so there is no context to copy from).
|
|
155
|
+
*/
|
|
156
|
+
export const checkRuntimeDockerfile = Effect.fn(function* (content) {
|
|
157
|
+
const parsed = yield* DockerfileParser.parse(content);
|
|
158
|
+
const { violations } = BuildPlan.check(parsed, capabilities, "linux/amd64");
|
|
159
|
+
if (violations.length > 0) {
|
|
160
|
+
return yield* new BuildPlan.UnsupportedDockerfile({
|
|
161
|
+
target: capabilities.target,
|
|
162
|
+
violations,
|
|
163
|
+
message: violations.map((v) => `line ${v.line}: ${v.instruction}: ${v.reason}`).join("\n"),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
for (const stage of parsed.stages) {
|
|
167
|
+
for (const instruction of stage.instructions) {
|
|
168
|
+
if (instruction._tag !== "COPY" && instruction._tag !== "ADD")
|
|
169
|
+
continue;
|
|
170
|
+
if (instruction.flags.some((flag) => flag.name === "from"))
|
|
171
|
+
continue;
|
|
172
|
+
const local = instruction.sources.filter((source) => !/^(https?:\/\/|git@)/.test(source) && !source.startsWith("<<"));
|
|
173
|
+
if (local.length > 0)
|
|
174
|
+
return yield* new SnapshotContextUnsupported({ line: instruction.raw });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
/** What the snapshot is built from, resolved; its hash decides rebuilds. */
|
|
179
|
+
const resolveSource = Effect.fn(function* (news) {
|
|
180
|
+
const fromDockerfile = news.dockerfile !== undefined || news.context !== undefined;
|
|
181
|
+
const sources = [news.image, fromDockerfile ? true : undefined, news.from].filter((s) => s !== undefined);
|
|
182
|
+
if (sources.length !== 1) {
|
|
183
|
+
return yield* new SnapshotSourceInvalid({
|
|
184
|
+
message: "Daytona.Snapshot takes exactly one of `image`, `dockerfile`/`context` or `from`",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (news.image !== undefined)
|
|
188
|
+
yield* checkImage(news.image);
|
|
189
|
+
// A Dockerfile builds on Daytona unless it asks for local Docker, or
|
|
190
|
+
// has build secrets (Daytona's builders can't receive them).
|
|
191
|
+
const remote = news.build?.remote ?? news.build?.secrets === undefined;
|
|
192
|
+
const local = fromDockerfile && !remote
|
|
193
|
+
? {
|
|
194
|
+
dockerfile: news.dockerfile,
|
|
195
|
+
context: news.context,
|
|
196
|
+
build: { args: news.build?.args, secrets: news.build?.secrets },
|
|
197
|
+
}
|
|
198
|
+
: undefined;
|
|
199
|
+
const plan = fromDockerfile && remote
|
|
200
|
+
? yield* BuildPlan.plan({ dockerfile: news.dockerfile, context: news.context, build: { args: news.build?.args } }, { capabilities })
|
|
201
|
+
: undefined;
|
|
202
|
+
const sizing = {
|
|
203
|
+
entrypoint: news.entrypoint,
|
|
204
|
+
cpu: news.cpu,
|
|
205
|
+
memory: news.memory,
|
|
206
|
+
disk: news.disk,
|
|
207
|
+
gpu: news.gpu,
|
|
208
|
+
gpuType: news.gpuType,
|
|
209
|
+
regionId: news.regionId,
|
|
210
|
+
sandboxClass: news.sandboxClass,
|
|
211
|
+
};
|
|
212
|
+
const source = {
|
|
213
|
+
image: news.image,
|
|
214
|
+
dockerfile: plan ? dockerfileText(plan) : undefined,
|
|
215
|
+
from: yield* refName(news.from),
|
|
216
|
+
run: news.run ?? [],
|
|
217
|
+
...sizing,
|
|
218
|
+
};
|
|
219
|
+
const buildHash = yield* sha256({
|
|
220
|
+
image: source.image,
|
|
221
|
+
plan: plan?.hash,
|
|
222
|
+
local: local ? yield* computeStaticSourceHash(local, "linux/amd64") : undefined,
|
|
223
|
+
from: source.from,
|
|
224
|
+
run: source.run,
|
|
225
|
+
...sizing,
|
|
226
|
+
});
|
|
227
|
+
return { source, plan, local, buildHash };
|
|
228
|
+
});
|
|
229
|
+
export const toSnapshotAttributes = (s, buildHash) => ({
|
|
230
|
+
snapshotId: s.id,
|
|
231
|
+
name: s.name,
|
|
232
|
+
state: s.state,
|
|
233
|
+
imageName: s.imageName,
|
|
234
|
+
ref: s.ref,
|
|
235
|
+
cpu: s.cpu,
|
|
236
|
+
memory: s.mem,
|
|
237
|
+
disk: s.disk,
|
|
238
|
+
gpu: s.gpu,
|
|
239
|
+
sourceSandboxId: s.sourceSandboxId ?? undefined,
|
|
240
|
+
buildHash,
|
|
241
|
+
});
|
|
242
|
+
export const getSnapshot = (idOrName) => snapshots
|
|
243
|
+
.getSnapshot({ id: idOrName })
|
|
244
|
+
.pipe(Effect.catchTag("SnapshotNotFound", () => Effect.undefined));
|
|
245
|
+
/** Wait for a snapshot to become usable, reactivating it when Daytona has deactivated it. */
|
|
246
|
+
export const waitForSnapshot = Effect.fn(function* (idOrName) {
|
|
247
|
+
const current = yield* snapshots.getSnapshot({ id: idOrName });
|
|
248
|
+
if (current.state === "inactive")
|
|
249
|
+
yield* snapshots.activateSnapshot({ id: current.id });
|
|
250
|
+
return yield* waitForState({
|
|
251
|
+
kind: "snapshot",
|
|
252
|
+
id: idOrName,
|
|
253
|
+
observe: snapshots.getSnapshot({ id: idOrName }),
|
|
254
|
+
want: ["active"],
|
|
255
|
+
fail: ["error", "build_failed"],
|
|
256
|
+
reason: (s) => s.errorReason,
|
|
257
|
+
budget: "30 minutes",
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
/** Delete a snapshot by name (Daytona deletes by id). Deleting a missing one succeeds. */
|
|
261
|
+
export const deleteSnapshotByName = Effect.fn(function* (name) {
|
|
262
|
+
const found = yield* getSnapshot(name);
|
|
263
|
+
if (found !== undefined)
|
|
264
|
+
yield* deleteSnapshot(found.id);
|
|
265
|
+
});
|
|
266
|
+
export const deleteSnapshot = Effect.fn(function* (idOrName) {
|
|
267
|
+
yield* snapshots
|
|
268
|
+
.removeSnapshot({ id: idOrName })
|
|
269
|
+
.pipe(Effect.catchTag("SnapshotNotFound", () => Effect.void));
|
|
270
|
+
yield* waitUntilGone("snapshot", idOrName, getSnapshot(idOrName).pipe(Effect.map((s) => s !== undefined)), "5 minutes");
|
|
271
|
+
});
|
|
272
|
+
/**
|
|
273
|
+
* Start a sandbox from `from`, run the commands in it and capture it as a
|
|
274
|
+
* snapshot named `name`. The build sandbox is deleted whatever happens, and
|
|
275
|
+
* deletes itself after an hour if this process dies first.
|
|
276
|
+
*/
|
|
277
|
+
export const captureSnapshot = Effect.fn(function* (input) {
|
|
278
|
+
const build = yield* Effect.acquireRelease(sandboxes.createSandbox({
|
|
279
|
+
name: `${input.name}-build`.slice(0, 63),
|
|
280
|
+
snapshot: input.from,
|
|
281
|
+
labels: { ...input.labels, "alchemy.role": "snapshot-build" },
|
|
282
|
+
autoDeleteInterval: 60,
|
|
283
|
+
}), (sandbox) => sandboxes.deleteSandbox({ sandboxIdOrName: sandbox.id }).pipe(Effect.catchTag("SandboxNotFound", () => Effect.void), Effect.ignore));
|
|
284
|
+
const started = yield* waitForState({
|
|
285
|
+
kind: "sandbox",
|
|
286
|
+
id: build.id,
|
|
287
|
+
observe: sandboxes.getSandbox({ sandboxIdOrName: build.id }),
|
|
288
|
+
want: ["started"],
|
|
289
|
+
fail: ["error", "build_failed", "destroyed"],
|
|
290
|
+
reason: (s) => s.errorReason,
|
|
291
|
+
});
|
|
292
|
+
for (const command of input.run) {
|
|
293
|
+
yield* input.note(`Running \`${command}\` in the snapshot build sandbox...`);
|
|
294
|
+
const result = yield* runCommand(started.id, started.toolboxProxyUrl, {
|
|
295
|
+
command,
|
|
296
|
+
timeout: 1800,
|
|
297
|
+
});
|
|
298
|
+
if ((result.exitCode ?? 0) !== 0) {
|
|
299
|
+
return yield* new SnapshotRunFailed({
|
|
300
|
+
command,
|
|
301
|
+
exitCode: result.exitCode ?? -1,
|
|
302
|
+
output: result.result,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
yield* input.note(`Capturing snapshot ${input.name}...`);
|
|
307
|
+
yield* sandboxes.createSandboxSnapshot({ sandboxIdOrName: started.id, name: input.name });
|
|
308
|
+
return yield* waitForSnapshot(input.name);
|
|
309
|
+
}, Effect.scoped);
|
|
310
|
+
/**
|
|
311
|
+
* Build a snapshot named `name` and wait until it is active: pull or
|
|
312
|
+
* build on Daytona's builders, or capture it from a `from` sandbox after
|
|
313
|
+
* running `run`. Shared by the resource and the runtime binding.
|
|
314
|
+
*/
|
|
315
|
+
export const buildSnapshot = Effect.fn(function* (input) {
|
|
316
|
+
const { name, source } = input;
|
|
317
|
+
if (source.from !== undefined) {
|
|
318
|
+
return yield* captureSnapshot({
|
|
319
|
+
labels: input.labels,
|
|
320
|
+
name,
|
|
321
|
+
from: source.from,
|
|
322
|
+
run: source.run ?? [],
|
|
323
|
+
note: input.note,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
if (source.image !== undefined)
|
|
327
|
+
yield* checkImage(source.image);
|
|
328
|
+
yield* input.note(source.dockerfile !== undefined
|
|
329
|
+
? `Building snapshot ${name} on Daytona...`
|
|
330
|
+
: `Pulling ${source.image} into snapshot ${name}...`);
|
|
331
|
+
yield* snapshots
|
|
332
|
+
.createSnapshot({
|
|
333
|
+
name,
|
|
334
|
+
imageName: source.image,
|
|
335
|
+
buildInfo: source.dockerfile !== undefined
|
|
336
|
+
? { dockerfileContent: source.dockerfile, contextHashes: source.contextHashes }
|
|
337
|
+
: undefined,
|
|
338
|
+
entrypoint: source.entrypoint,
|
|
339
|
+
cpu: source.cpu,
|
|
340
|
+
memory: source.memory,
|
|
341
|
+
disk: source.disk,
|
|
342
|
+
gpu: source.gpu,
|
|
343
|
+
gpuType: source.gpuType,
|
|
344
|
+
regionId: source.regionId,
|
|
345
|
+
sandboxClass: source.sandboxClass,
|
|
346
|
+
})
|
|
347
|
+
.pipe(Effect.catchTag("SnapshotAlreadyExists", () => Effect.void));
|
|
348
|
+
return yield* waitForSnapshot(name);
|
|
349
|
+
});
|
|
350
|
+
/**
|
|
351
|
+
* Daytona's transient registry as a push target: a short-lived robot
|
|
352
|
+
* account scoped to the organization's own project, which Daytona pulls
|
|
353
|
+
* snapshots from without a registry entry.
|
|
354
|
+
*/
|
|
355
|
+
const transientRegistry = Effect.fn(function* (name, regionId) {
|
|
356
|
+
const access = yield* dockerRegistry.getTransientPushAccess({ regionId });
|
|
357
|
+
return {
|
|
358
|
+
repositoryUri: Effect.succeed(`${access.registryUrl}/${access.project}/${name}`),
|
|
359
|
+
// Pushes are content-addressed and the registry can't be listed with
|
|
360
|
+
// this account; pushing an existing tag is a no-op upload.
|
|
361
|
+
hasTag: () => Effect.succeed(false),
|
|
362
|
+
credentials: Effect.succeed({
|
|
363
|
+
server: access.registryUrl,
|
|
364
|
+
username: access.username,
|
|
365
|
+
password: access.secret,
|
|
366
|
+
}),
|
|
367
|
+
};
|
|
368
|
+
});
|
|
369
|
+
export const SnapshotProvider = () => Provider.effect(Snapshot, Effect.gen(function* () {
|
|
370
|
+
const images = yield* makeContainerImageSource;
|
|
371
|
+
return {
|
|
372
|
+
stables: ["snapshotId"],
|
|
373
|
+
list: Effect.fn(function* () {
|
|
374
|
+
const all = yield* snapshots.getAllSnapshots.items({}).pipe(Stream.runCollect);
|
|
375
|
+
return Array.from(all)
|
|
376
|
+
.filter((s) => !s.general)
|
|
377
|
+
.map((s) => toSnapshotAttributes(s, ""));
|
|
378
|
+
}),
|
|
379
|
+
diff: Effect.fn(function* ({ id, news, output }) {
|
|
380
|
+
if (!isResolved(news) || output === undefined)
|
|
381
|
+
return undefined;
|
|
382
|
+
const name = yield* resolveName(id, news.name, news.name === undefined ? output.name : undefined);
|
|
383
|
+
const { buildHash } = yield* resolveSource(news);
|
|
384
|
+
if (name !== output.name || buildHash !== output.buildHash) {
|
|
385
|
+
// Sandboxes reference snapshots by name, so a pinned name is freed first.
|
|
386
|
+
return { action: "replace", deleteFirst: name === output.name };
|
|
387
|
+
}
|
|
388
|
+
}),
|
|
389
|
+
lookup: Effect.fn(function* ({ name }) {
|
|
390
|
+
const found = yield* getSnapshot(name);
|
|
391
|
+
return found === undefined ? undefined : toSnapshotAttributes(found, "");
|
|
392
|
+
}),
|
|
393
|
+
read: Effect.fn(function* ({ id, olds, output }) {
|
|
394
|
+
const name = yield* resolveName(id, olds?.name, output?.name);
|
|
395
|
+
const found = (output ? yield* getSnapshot(output.snapshotId) : undefined) ??
|
|
396
|
+
(yield* getSnapshot(name));
|
|
397
|
+
if (found === undefined)
|
|
398
|
+
return undefined;
|
|
399
|
+
const attrs = toSnapshotAttributes(found, output?.buildHash ?? "");
|
|
400
|
+
return (yield* isOwnedName(id, found.name, output !== undefined))
|
|
401
|
+
? attrs
|
|
402
|
+
: Unowned(attrs);
|
|
403
|
+
}),
|
|
404
|
+
reconcile: Effect.fn(function* ({ id, news, output, session }) {
|
|
405
|
+
const name = yield* resolveName(id, news.name, output?.name);
|
|
406
|
+
const { source, plan, local, buildHash } = yield* resolveSource(news);
|
|
407
|
+
// Observe
|
|
408
|
+
const current = yield* getSnapshot(output?.snapshotId ?? name);
|
|
409
|
+
if (current !== undefined && current.name === name) {
|
|
410
|
+
// Ensure usable: reactivate a snapshot Daytona deactivated after
|
|
411
|
+
// two weeks unused, and wait out a build already in flight.
|
|
412
|
+
const ready = current.state === "active" ? current : yield* waitForSnapshot(current.id);
|
|
413
|
+
return toSnapshotAttributes(ready, output?.buildHash ?? buildHash);
|
|
414
|
+
}
|
|
415
|
+
// Ensure — a local build pushes its image to Daytona's registry,
|
|
416
|
+
// which the snapshot then pulls.
|
|
417
|
+
if (local !== undefined) {
|
|
418
|
+
yield* session.note(`Building ${name} with local Docker...`);
|
|
419
|
+
const pushed = yield* images.resolve({ id, source: local, session, platform: "linux/amd64", bootstrap: () => "" }, yield* transientRegistry(name, news.regionId));
|
|
420
|
+
const built = yield* buildSnapshot({
|
|
421
|
+
name,
|
|
422
|
+
source: { ...source, dockerfile: undefined, image: pushed.imageUri },
|
|
423
|
+
labels: yield* createInternalLabels(id),
|
|
424
|
+
note: session.note,
|
|
425
|
+
});
|
|
426
|
+
return toSnapshotAttributes(built, buildHash);
|
|
427
|
+
}
|
|
428
|
+
// Ensure — upload what the Dockerfile copies, then build.
|
|
429
|
+
for (const warning of plan?.warnings ?? [])
|
|
430
|
+
yield* session.note(warning);
|
|
431
|
+
const contextHashes = plan !== undefined && plan.files.length > 0
|
|
432
|
+
? [yield* uploadBuildContext(plan)]
|
|
433
|
+
: undefined;
|
|
434
|
+
const built = yield* buildSnapshot({
|
|
435
|
+
name,
|
|
436
|
+
source: { ...source, contextHashes },
|
|
437
|
+
labels: yield* createInternalLabels(id),
|
|
438
|
+
note: session.note,
|
|
439
|
+
});
|
|
440
|
+
return toSnapshotAttributes(built, buildHash);
|
|
441
|
+
}),
|
|
442
|
+
delete: Effect.fn(function* ({ output }) {
|
|
443
|
+
yield* deleteSnapshot(output.snapshotId);
|
|
444
|
+
}),
|
|
445
|
+
};
|
|
446
|
+
}));
|
|
447
|
+
//# sourceMappingURL=Snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Snapshot.js","sources":["../src/Snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAC;AAE3D,OAAO,KAAK,gBAAgB,MAAM,sCAAsC,CAAC;AACzE,OAAO,EACL,uBAAuB,EACvB,wBAAwB,GAGzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,cAAc,MAAM,0CAA0C,CAAC;AAC3E,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,SAAS,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAA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AI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;gBACzC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;gBACnC,CAAC,CAAC,SAAS,CAAC;YAChB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,aAAa,CAAC;gBACjC,IAAI;gBACJ,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,aAAa,EAAE;gBACpC,MAAM,EAAE,KAAK,CAAC,CAAC,oBAAoB,CAAC,EAAE,CAAC;gBACvC,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC,CAAC;YACH,OAAO,oBAAoB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAChD,CAAC,CAAC;QACF,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE;YACrC,KAAK,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC3C,CAAC,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
package/lib/Volume.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as volumes from "@distilled.cloud/daytona/volumes";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import { Resource } from "alchemy/Resource";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import type { Providers } from "./Providers.ts";
|
|
6
|
+
export interface VolumeProps {
|
|
7
|
+
/**
|
|
8
|
+
* Volume name, unique in the organization. If omitted, a unique name is
|
|
9
|
+
* generated from the stack, stage and logical ID. Changing it replaces
|
|
10
|
+
* the volume (and its files).
|
|
11
|
+
*/
|
|
12
|
+
name?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface VolumeAttributes {
|
|
15
|
+
/** Volume ID. */
|
|
16
|
+
volumeId: string;
|
|
17
|
+
/** Volume name. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Volume state (`ready` once usable). */
|
|
20
|
+
state: volumes.VolumeState;
|
|
21
|
+
/** When the volume was created. */
|
|
22
|
+
createdAt: string;
|
|
23
|
+
}
|
|
24
|
+
export type Volume = Resource<"Daytona.Volume", VolumeProps, VolumeAttributes, never, Providers, VolumeLookup>;
|
|
25
|
+
/**
|
|
26
|
+
* Props for {@link Volume.lookup}: find a volume this stack
|
|
27
|
+
* doesn't manage by its name.
|
|
28
|
+
*/
|
|
29
|
+
export interface VolumeLookup {
|
|
30
|
+
/** Volume name. */
|
|
31
|
+
name: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A Daytona volume: a persistent disk, backed by object storage, that
|
|
35
|
+
* sandboxes mount at a path. Its files outlive every sandbox that mounts
|
|
36
|
+
* it, and several sandboxes can mount it at once.
|
|
37
|
+
*
|
|
38
|
+
* Declare a volume here for data your whole app shares, like a dataset or
|
|
39
|
+
* a package cache. For a volume per user or per session, create it at
|
|
40
|
+
* runtime with {@link CreateVolume}.
|
|
41
|
+
* @see https://www.daytona.io/docs/en/volumes/
|
|
42
|
+
*
|
|
43
|
+
* ### Creating a Volume
|
|
44
|
+
* **Example:** A shared cache volume
|
|
45
|
+
* ```typescript
|
|
46
|
+
* export const Cache = Daytona.Volume("Cache", {});
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* ### Mounting a Volume
|
|
50
|
+
* **Example:** Mount it in a sandbox declared at deploy
|
|
51
|
+
* ```typescript
|
|
52
|
+
* export const DevBox = Daytona.Sandbox("DevBox", {
|
|
53
|
+
* snapshot: Base,
|
|
54
|
+
* mounts: [{ volume: Cache, path: "/cache" }],
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* **Example:** Mount it in sandboxes created at runtime
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const cache = yield* Daytona.MountVolume(Cache, { path: "/cache" });
|
|
61
|
+
* const sandbox = yield* sandboxes.create({ mounts: [cache] });
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* ### Looking up an existing volume
|
|
65
|
+
* `Volume.lookup` references a volume Alchemy doesn't manage (created in
|
|
66
|
+
* the Daytona dashboard or by another stack). It is read during plan/deploy,
|
|
67
|
+
* never created, updated or deleted.
|
|
68
|
+
*
|
|
69
|
+
* **Example:** Mount an existing volume
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const data = Daytona.Volume.lookup({ name: "datasets" });
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @resource
|
|
75
|
+
* @product Volume
|
|
76
|
+
*/
|
|
77
|
+
export declare const Volume: import("alchemy/Resource").ResourceClass<Volume>;
|
|
78
|
+
export declare const toVolumeAttributes: (v: volumes.VolumeDto) => VolumeAttributes;
|
|
79
|
+
export declare const getVolumeByName: (name: string) => Effect.Effect<volumes.VolumeDto | undefined, volumes.DaytonaOpError, volumes.DaytonaOpContext>;
|
|
80
|
+
export declare const getVolumeById: (volumeId: string) => Effect.Effect<volumes.VolumeDto | undefined, volumes.DaytonaOpError, volumes.DaytonaOpContext>;
|
|
81
|
+
export declare const waitForVolume: (volumeId: string) => Effect.Effect<volumes.VolumeDto, import("./internal/Wait.ts").StateFailed | import("./internal/Wait.ts").StateTimeout | volumes.GetVolumeError, volumes.DaytonaOpContext>;
|
|
82
|
+
/**
|
|
83
|
+
* The volume named `name`, created if missing. A create racing another
|
|
84
|
+
* caller (`VolumeAlreadyExists`) re-reads the winner.
|
|
85
|
+
*/
|
|
86
|
+
export declare const ensureVolume: (name: string) => Effect.Effect<volumes.VolumeDto, import("@distilled.cloud/core/errors").BadGateway | import("@distilled.cloud/core/errors").BadRequest | import("@distilled.cloud/core/config").ConfigError | import("@distilled.cloud/core/errors").Conflict | import("@distilled.cloud/daytona/Errors").DaytonaParseError | import("@distilled.cloud/core/errors").Forbidden | import("@distilled.cloud/core/errors").GatewayTimeout | import("effect/http/HttpClientError").HttpClientError | import("@distilled.cloud/core/errors").InternalServerError | import("@distilled.cloud/core/protocol-http").InvalidInput | import("@distilled.cloud/core/errors").Locked | import("@distilled.cloud/core/errors").NotFound | import("@distilled.cloud/core/sdk-error").SdkError | import("@distilled.cloud/core/errors").ServiceUnavailable | import("./internal/Wait.ts").StateFailed | import("./internal/Wait.ts").StateTimeout | import("@distilled.cloud/core/errors").TooManyRequests | import("@distilled.cloud/core/errors").Unauthorized | import("@distilled.cloud/daytona/Errors").UnknownDaytonaError | import("@distilled.cloud/core/errors").UnprocessableEntity | volumes.VolumeNotFound, volumes.DaytonaOpContext>;
|
|
87
|
+
/**
|
|
88
|
+
* Delete a volume. With `wait` (deploy), retry while a sandbox still
|
|
89
|
+
* mounts it and wait until it is gone. At run time `wait` is off: a
|
|
90
|
+
* request fails at once with `VolumeInUse` and returns as soon as Daytona
|
|
91
|
+
* accepts the delete. Daytona releases a volume about a minute after the
|
|
92
|
+
* sandbox that wrote to it is deleted, which is longer than a request
|
|
93
|
+
* should wait.
|
|
94
|
+
*/
|
|
95
|
+
export declare const deleteVolumeById: (volumeId: string, options?: {
|
|
96
|
+
readonly wait: boolean;
|
|
97
|
+
} | undefined) => Effect.Effect<void, import("./internal/Wait.ts").StateTimeout | volumes.VolumeInUse | volumes.VolumeNotReady | volumes.DaytonaOpError, volumes.DaytonaOpContext>;
|
|
98
|
+
export declare const VolumeProvider: () => import("effect/Layer").Layer<Provider.Provider<Volume>, never, import("alchemy/Stack").Stack | import("alchemy/Stage").Stage | volumes.DaytonaOpContext>;
|
|
99
|
+
//# sourceMappingURL=Volume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Volume.d.ts","sources":["../src/Volume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kCAAkC,CAAC;AAG5D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,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