@lunora/container 0.0.0 → 1.0.0-alpha.1

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.
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Public configuration types for `@lunora/container`.
3
+ *
4
+ * Everything in this module is pure data — no Cloudflare runtime imports — so
5
+ * it is safe to import from Node tooling (codegen, the config layer) as well
6
+ * as from worker code.
7
+ */
8
+ /** Named instance types Cloudflare Containers provides. */
9
+ type NamedContainerInstanceType = "basic" | "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4";
10
+ /**
11
+ * A custom instance type. Cloudflare's bounds at the time of writing: up to
12
+ * 4 vCPU, 12 GiB memory, 20 GB disk, ≥ 3 GiB memory per vCPU and ≤ 2 GB disk
13
+ * per GiB memory. The config-layer validator enforces the documented ranges.
14
+ */
15
+ interface CustomContainerInstanceType {
16
+ /** Disk in MB. Cloudflare's default is 2000 (2 GB). */
17
+ diskMb?: number;
18
+ /** Memory in MiB. Cloudflare's default is 256. */
19
+ memoryMib?: number;
20
+ /** vCPU count. Cloudflare's default is 0.0625 (1/16 vCPU). */
21
+ vcpu?: number;
22
+ }
23
+ type ContainerInstanceType = CustomContainerInstanceType | NamedContainerInstanceType;
24
+ /** Rolling-deploy tuning for a container. */
25
+ interface ContainerRollout {
26
+ /** Seconds an active instance runs before it's eligible for update (wrangler `rollout_active_grace_period`). */
27
+ gracePeriodSeconds?: number;
28
+ /** Percentage of instances updated per rollout step, 1–100 (wrangler `rollout_step_percentage`). */
29
+ stepPercentage?: number;
30
+ }
31
+ /**
32
+ * A pre-built image pulled from a registry — the Cloudflare Registry, Docker
33
+ * Hub, or Amazon ECR (the registries `wrangler deploy` supports). The
34
+ * reference must be fully qualified, e.g. `docker.io/acme/transcoder:1.4`.
35
+ */
36
+ interface RegistryImageSource {
37
+ registry: string;
38
+ }
39
+ /**
40
+ * A Dockerfile-less build via [Railpack](https://railpack.com): point at a
41
+ * source directory and `lunora deploy` builds an OCI image with Railpack
42
+ * (needs a BuildKit instance) and pushes it to the Cloudflare Registry before
43
+ * wrangler runs. Opt-in — the Dockerfile path is the zero-extra-deps default.
44
+ */
45
+ interface BuildImageSource {
46
+ build: string;
47
+ }
48
+ /**
49
+ * Where the container image comes from. A `string` is a **local path** —
50
+ * either a directory containing a `Dockerfile` (normalized to
51
+ * `<dir>/Dockerfile` with the directory as the build context) or a path to
52
+ * the Dockerfile itself — while `{ registry }` is a pre-built image reference.
53
+ */
54
+ type ContainerImageSource = BuildImageSource | RegistryImageSource | string;
55
+ interface ContainerConfig {
56
+ /**
57
+ * Build-time variables for a Dockerfile/Railpack image — wrangler's
58
+ * `image_vars` (equivalent to `docker build --build-arg`). For *runtime*
59
+ * values use {@link ContainerConfig.env} / {@link ContainerConfig.secrets}.
60
+ * Ignored for a pre-built `{ registry }` image.
61
+ */
62
+ buildArgs?: Readonly<Record<string, string>>;
63
+ /**
64
+ * The port the container listens on. Worker → container requests target
65
+ * this port. Locally the Dockerfile must also `EXPOSE` it.
66
+ */
67
+ defaultPort?: number;
68
+ /**
69
+ * Whether the container may open outbound internet connections. Defaults
70
+ * to `true` — the platform default. Note that container egress is billed
71
+ * per GB by Cloudflare.
72
+ */
73
+ enableInternet?: boolean;
74
+ /**
75
+ * Static environment variables passed to the container on every start.
76
+ * For secret values use {@link ContainerConfig.secrets} instead so they
77
+ * flow through Worker Secrets rather than source code.
78
+ */
79
+ env?: Readonly<Record<string, string>>;
80
+ /** Image source — a local Dockerfile path/directory or a registry reference. */
81
+ image: ContainerImageSource;
82
+ /**
83
+ * Resource class for each instance: a named Cloudflare instance type or a
84
+ * custom `{ vcpu, memoryMib, diskMb }` object.
85
+ */
86
+ instanceType?: ContainerInstanceType;
87
+ /**
88
+ * Maximum number of concurrently *running* instances. Stopped (slept)
89
+ * containers don't count. Also the default pool size for `.any()`.
90
+ */
91
+ maxInstances?: number;
92
+ /**
93
+ * Override for the wrangler `containers[].name` identifier. Defaults to
94
+ * wrangler's own default (worker name + class name + environment).
95
+ */
96
+ name?: string;
97
+ /**
98
+ * Rolling-deploy tuning. `stepPercentage` is the share of instances updated
99
+ * per rollout step (wrangler `rollout_step_percentage`); `gracePeriodSeconds`
100
+ * is how long an active instance is left running before it's eligible for
101
+ * update (wrangler `rollout_active_grace_period`).
102
+ */
103
+ rollout?: ContainerRollout;
104
+ /**
105
+ * Names of Worker secrets (from `wrangler secret` / `.dev.vars`) forwarded
106
+ * into the container's environment at instance start. Each declared name
107
+ * must exist on the Worker `env` — a missing one fails fast with a
108
+ * directed error instead of starting the container without it.
109
+ */
110
+ secrets?: ReadonlyArray<string>;
111
+ /**
112
+ * Idle timeout after which the instance is put to sleep, e.g. `"5m"`,
113
+ * `"30s"`, or a number of seconds. Cloudflare's default is `"10m"`.
114
+ */
115
+ sleepAfter?: number | string;
116
+ }
117
+ /**
118
+ * The value `defineContainer` returns: the validated config plus a brand the
119
+ * codegen discovery and the generated Container DO class key on.
120
+ */
121
+ interface ContainerDefinition extends ContainerConfig {
122
+ /** Brand marking a value as a Lunora container definition. */
123
+ readonly isLunoraContainer: true;
124
+ }
125
+ /** A normalized image source, as written into `wrangler.jsonc`. */
126
+ type NormalizedContainerImage = {
127
+ /** Build context directory (wrangler `image_build_context`). */
128
+ buildContext: string;
129
+ /** Path to the Dockerfile (wrangler `image`). */
130
+ dockerfilePath: string;
131
+ kind: "dockerfile";
132
+ } | {
133
+ /** Railpack source directory built + pushed at deploy time. */
134
+ buildDir: string;
135
+ kind: "build";
136
+ } | {
137
+ kind: "registry"; /** Fully-qualified image reference (wrangler `image`). */
138
+ reference: string;
139
+ };
140
+ export { BuildImageSource as B, ContainerDefinition as C, NormalizedContainerImage as N, RegistryImageSource as R, ContainerConfig as a, ContainerImageSource as b, ContainerInstanceType as c, ContainerRollout as d, CustomContainerInstanceType as e, NamedContainerInstanceType as f };
package/package.json CHANGED
@@ -1,29 +1,60 @@
1
1
  {
2
2
  "name": "@lunora/container",
3
- "version": "0.0.0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "Cloudflare Containers for Lunora: defineContainer, generated Container DO classes, and the ctx.containers action surface",
5
- "license": "FSL-1.1-Apache-2.0",
5
+ "keywords": [
6
+ "cloudflare",
7
+ "containers",
8
+ "docker",
9
+ "durable-objects",
10
+ "lunora",
11
+ "workers"
12
+ ],
6
13
  "homepage": "https://lunora.sh",
14
+ "bugs": "https://github.com/anolilab/lunora/issues",
15
+ "license": "FSL-1.1-Apache-2.0",
16
+ "author": {
17
+ "name": "Daniel Bannert",
18
+ "email": "d.bannert@anolilab.de"
19
+ },
7
20
  "repository": {
8
21
  "type": "git",
9
22
  "url": "git+https://github.com/anolilab/lunora.git",
10
23
  "directory": "packages/container"
11
24
  },
12
- "bugs": {
13
- "url": "https://github.com/anolilab/lunora/issues"
14
- },
15
- "keywords": [
16
- "lunora",
17
- "cloudflare",
18
- "workers",
19
- "containers",
20
- "docker",
21
- "durable-objects"
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "LICENSE.md",
29
+ "__assets__"
22
30
  ],
31
+ "type": "module",
32
+ "sideEffects": false,
33
+ "main": "./dist/index.mjs",
34
+ "module": "./dist/index.mjs",
35
+ "types": "./dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.mjs"
40
+ },
41
+ "./do": {
42
+ "types": "./dist/do/index.d.ts",
43
+ "import": "./dist/do/index.mjs"
44
+ },
45
+ "./bridge": {
46
+ "types": "./dist/bridge.d.ts",
47
+ "import": "./dist/bridge.mjs"
48
+ },
49
+ "./package.json": "./package.json"
50
+ },
23
51
  "publishConfig": {
24
52
  "access": "public"
25
53
  },
26
- "files": [
27
- "README.md"
28
- ]
54
+ "dependencies": {
55
+ "@cloudflare/containers": "^0.3.7"
56
+ },
57
+ "engines": {
58
+ "node": "^22.15.0 || >=24.11.0"
59
+ }
29
60
  }