@lunora/container 0.0.0 → 1.0.0-alpha.10

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,266 @@
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
+ /**
56
+ * An application-level readiness probe that gates request proxying. Layered on
57
+ * top of the platform's own port/`pingEndpoint` health wait, it lets you hold
58
+ * traffic back until the app inside the container is *functionally* ready —
59
+ * migrations applied, caches warmed — which an open-port check can't see.
60
+ *
61
+ * Declarative on purpose: a `defineContainer` value stays pure data (no handler
62
+ * functions), so codegen and the config layer can read it without evaluating
63
+ * code. (Upstream cloudflare/containers#188 expresses the same idea as handler
64
+ * functions; the Lunora config is data-only, so it's modelled as descriptors.)
65
+ */
66
+ interface ContainerReadinessCheck {
67
+ /** HTTP path probed on the container, e.g. `"/ready"` (a leading slash is optional). */
68
+ path: string;
69
+ /** Port to probe. Defaults to {@link ContainerConfig.defaultPort}. */
70
+ port?: number;
71
+ /** HTTP status that means "ready". Defaults to `200`. */
72
+ status?: number;
73
+ }
74
+ interface ContainerConfig {
75
+ /**
76
+ * Hostnames the container may reach **even when {@link ContainerConfig.enableInternet}
77
+ * is `false`** — an egress allow-list (Cloudflare's `allowedHosts`). Glob
78
+ * patterns like `*.stripe.com` are supported. Pair with `enableInternet:
79
+ * false` to deny all egress except these hosts (the firewall pattern
80
+ * upstream issue cloudflare/containers#30 asked for). The interception path
81
+ * needs the `ContainerProxy` worker entrypoint, which codegen re-exports
82
+ * from the generated container file automatically; the named-instance
83
+ * handle's `egress` controls adjust the lists at runtime.
84
+ */
85
+ allowedHosts?: ReadonlyArray<string>;
86
+ /**
87
+ * Build-time variables for a Dockerfile/Railpack image — wrangler's
88
+ * `image_vars` (equivalent to `docker build --build-arg`). For *runtime*
89
+ * values use {@link ContainerConfig.env} / {@link ContainerConfig.secrets}.
90
+ * Ignored for a pre-built `{ registry }` image.
91
+ */
92
+ buildArgs?: Readonly<Record<string, string>>;
93
+ /**
94
+ * The port the container listens on. Worker → container requests target
95
+ * this port. Locally the Dockerfile must also `EXPOSE` it. For a
96
+ * multi-port container also declare {@link ContainerConfig.requiredPorts}
97
+ * and route per request with the handle's `.port(n)`.
98
+ */
99
+ defaultPort?: number;
100
+ /**
101
+ * Hostnames the container may **never** reach — an egress deny-list
102
+ * (Cloudflare's `deniedHosts`). Overrides everything else, including
103
+ * `enableInternet: true` and {@link ContainerConfig.allowedHosts}. Glob
104
+ * patterns like `*.evil.com` are supported.
105
+ */
106
+ deniedHosts?: ReadonlyArray<string>;
107
+ /**
108
+ * Whether the container may open outbound internet connections. Defaults
109
+ * to `true` — the platform default. Note that container egress is billed
110
+ * per GB by Cloudflare. Combine with {@link ContainerConfig.allowedHosts} /
111
+ * {@link ContainerConfig.deniedHosts} for a precise egress firewall.
112
+ */
113
+ enableInternet?: boolean;
114
+ /**
115
+ * Default command to run inside the container, overriding the image's
116
+ * `ENTRYPOINT`/`CMD` (Cloudflare's `entrypoint`). A per-start override is
117
+ * still available via the named-instance handle's `start({ entrypoint })`.
118
+ */
119
+ entrypoint?: ReadonlyArray<string>;
120
+ /**
121
+ * Static environment variables passed to the container on every start.
122
+ * For secret values use {@link ContainerConfig.secrets} instead so they
123
+ * flow through Worker Secrets rather than source code.
124
+ */
125
+ env?: Readonly<Record<string, string>>;
126
+ /**
127
+ * Hard cap on how long an instance may run, measured from start regardless
128
+ * of activity — a runaway-cost backstop on top of the idle
129
+ * {@link ContainerConfig.sleepAfter}. Same grammar as `sleepAfter`
130
+ * (`"30s"`, `"5m"`, `"1h"`, or a plain number of seconds). When it elapses,
131
+ * the `LunoraContainer.onHardTimeoutExpired` hook runs (default: `stop()`).
132
+ * (Upstream cloudflare/containers#85.)
133
+ */
134
+ hardTimeout?: number | string;
135
+ /** Image source — a local Dockerfile path/directory or a registry reference. */
136
+ image: ContainerImageSource;
137
+ /**
138
+ * Resource class for each instance: a named Cloudflare instance type or a
139
+ * custom `{ vcpu, memoryMib, diskMb }` object.
140
+ */
141
+ instanceType?: ContainerInstanceType;
142
+ /**
143
+ * Intercept the container's outbound **HTTPS** traffic so the egress
144
+ * allow/deny lists apply to TLS connections too (Cloudflare's
145
+ * `interceptHttps`). Requires the image to trust the Cloudflare CA at
146
+ * `/etc/cloudflare/certs/cloudflare-containers-ca.crt`. Defaults to `false`
147
+ * (HTTP egress is gated regardless).
148
+ */
149
+ interceptHttps?: boolean;
150
+ /**
151
+ * Key-value metadata attached to every instance for metrics/observability
152
+ * (Cloudflare's container `labels`), e.g. `{ tenant: "acme", env: "prod" }`.
153
+ * A per-start override is available via the named-instance handle's
154
+ * `start({ labels })`.
155
+ */
156
+ labels?: Readonly<Record<string, string>>;
157
+ /**
158
+ * Maximum number of concurrently *running* instances. Stopped (slept)
159
+ * containers don't count. Also the default pool size for `.any()`.
160
+ */
161
+ maxInstances?: number;
162
+ /**
163
+ * Override for the wrangler `containers[].name` identifier. Defaults to
164
+ * wrangler's own default (worker name + class name + environment).
165
+ */
166
+ name?: string;
167
+ /**
168
+ * HTTP path Cloudflare polls to decide an instance is healthy
169
+ * (Cloudflare's `pingEndpoint`). Defaults to upstream's slash-less `"ping"`;
170
+ * either `"ping"` or `"/healthz"`-style paths are accepted. Set this when
171
+ * the container exposes its readiness check under a different route.
172
+ */
173
+ pingEndpoint?: string;
174
+ /**
175
+ * Application-level readiness probes that gate request proxying: a
176
+ * `ctx.containers.&lt;name>` fetch waits until every probe responds with its
177
+ * expected status before the request reaches the container — on top of the
178
+ * platform's port/`pingEndpoint` health wait. All probes run in parallel.
179
+ * Use these for readiness an open-port check can't see (migrations applied,
180
+ * caches warm). (Upstream cloudflare/containers#188.)
181
+ */
182
+ readyOn?: ReadonlyArray<ContainerReadinessCheck>;
183
+ /**
184
+ * Ports the container must be listening on before it's considered ready
185
+ * (Cloudflare's `requiredPorts`) — for multi-port containers. Start-up
186
+ * waits for every listed port, and the handle's `.port(n)` routes a request
187
+ * to any of them; {@link ContainerConfig.defaultPort} is the target when a
188
+ * request doesn't pick one.
189
+ */
190
+ requiredPorts?: ReadonlyArray<number>;
191
+ /**
192
+ * Rolling-deploy tuning. `stepPercentage` is the share of instances updated
193
+ * per rollout step (wrangler `rollout_step_percentage`); `gracePeriodSeconds`
194
+ * is how long an active instance is left running before it's eligible for
195
+ * update (wrangler `rollout_active_grace_period`).
196
+ */
197
+ rollout?: ContainerRollout;
198
+ /**
199
+ * Names of Worker secrets (from `wrangler secret` / `.dev.vars`) forwarded
200
+ * into the container's environment at instance start. Each declared name
201
+ * must exist on the Worker `env` — a missing one fails fast with a
202
+ * directed error instead of starting the container without it.
203
+ */
204
+ secrets?: ReadonlyArray<string>;
205
+ /**
206
+ * Cloudflare **Secrets Store** secrets forwarded into the container's
207
+ * environment, as a map of *container env-var name → Worker Secrets Store
208
+ * binding name*. Each binding is resolved with its async `.get()` the first
209
+ * time the instance starts, then injected as that env var — e.g.
210
+ * `{ STRIPE_KEY: "STRIPE_SECRET" }` runs `env.STRIPE_SECRET.get()` and sets
211
+ * `STRIPE_KEY` inside the container. Unlike {@link ContainerConfig.secrets}
212
+ * (plain Worker text secrets), this pulls from a `secrets_store_secrets`
213
+ * binding. A name already used by `env`/`secrets` is rejected at authoring
214
+ * time; a missing binding or unreadable value fails the start. Applies
215
+ * to the default start (the `ctx.containers` proxy path and a bare
216
+ * `start()`); a per-instance `start({ envVars })` replaces the env set
217
+ * wholesale, as it does for `env`/`secrets`. (Upstream
218
+ * cloudflare/containers#96.)
219
+ */
220
+ secretsStore?: Readonly<Record<string, string>>;
221
+ /**
222
+ * Idle timeout after which the instance is put to sleep, e.g. `"5m"`,
223
+ * `"30s"`, or a number of seconds. Cloudflare's default is `"10m"`.
224
+ */
225
+ sleepAfter?: number | string;
226
+ }
227
+ /**
228
+ * The value `defineContainer` returns: the validated config plus a brand the
229
+ * codegen discovery and the generated Container DO class key on.
230
+ */
231
+ interface ContainerDefinition extends ContainerConfig {
232
+ /** Brand marking a value as a Lunora container definition. */
233
+ readonly isLunoraContainer: true;
234
+ }
235
+ /** A normalized image source, as written into `wrangler.jsonc`. */
236
+ type NormalizedContainerImage = {
237
+ /** Build context directory (wrangler `image_build_context`). */
238
+ buildContext: string;
239
+ /** Path to the Dockerfile (wrangler `image`). */
240
+ dockerfilePath: string;
241
+ kind: "dockerfile";
242
+ } | {
243
+ /** Railpack source directory built + pushed at deploy time. */
244
+ buildDir: string;
245
+ kind: "build";
246
+ } | {
247
+ kind: "registry"; /** Fully-qualified image reference (wrangler `image`). */
248
+ reference: string;
249
+ };
250
+ /**
251
+ * Cloudflare Durable Object data-residency jurisdiction. Widening union —
252
+ * Cloudflare adds values over time.
253
+ * @see https://developers.cloudflare.com/durable-objects/reference/data-location/
254
+ */
255
+ type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
256
+ /**
257
+ * Return a jurisdiction-restricted view of `namespace`, or `namespace`
258
+ * unchanged when no jurisdiction is configured. Fail-closed when the binding
259
+ * lacks `.jurisdiction()` so a residency constraint is never silently dropped.
260
+ *
261
+ * Generic over the namespace shape so both the `ctx.containers` client
262
+ * (`ContainerNamespaceLike`) and the lifecycle reporter (`ShardNamespaceLike`)
263
+ * share one implementation — the only requirement is an optional
264
+ * `.jurisdiction()` that returns the same namespace type.
265
+ */
266
+ export { BuildImageSource as B, ContainerConfig as C, DurableObjectJurisdiction as D, NormalizedContainerImage as N, RegistryImageSource as R, ContainerDefinition as a, ContainerImageSource as b, ContainerInstanceType as c, ContainerReadinessCheck as d, ContainerRollout as e, CustomContainerInstanceType as f, NamedContainerInstanceType as g };
@@ -0,0 +1,266 @@
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
+ * `&lt;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
+ /**
56
+ * An application-level readiness probe that gates request proxying. Layered on
57
+ * top of the platform's own port/`pingEndpoint` health wait, it lets you hold
58
+ * traffic back until the app inside the container is *functionally* ready —
59
+ * migrations applied, caches warmed — which an open-port check can't see.
60
+ *
61
+ * Declarative on purpose: a `defineContainer` value stays pure data (no handler
62
+ * functions), so codegen and the config layer can read it without evaluating
63
+ * code. (Upstream cloudflare/containers#188 expresses the same idea as handler
64
+ * functions; the Lunora config is data-only, so it's modelled as descriptors.)
65
+ */
66
+ interface ContainerReadinessCheck {
67
+ /** HTTP path probed on the container, e.g. `"/ready"` (a leading slash is optional). */
68
+ path: string;
69
+ /** Port to probe. Defaults to {@link ContainerConfig.defaultPort}. */
70
+ port?: number;
71
+ /** HTTP status that means "ready". Defaults to `200`. */
72
+ status?: number;
73
+ }
74
+ interface ContainerConfig {
75
+ /**
76
+ * Hostnames the container may reach **even when {@link ContainerConfig.enableInternet}
77
+ * is `false`** — an egress allow-list (Cloudflare's `allowedHosts`). Glob
78
+ * patterns like `*.stripe.com` are supported. Pair with `enableInternet:
79
+ * false` to deny all egress except these hosts (the firewall pattern
80
+ * upstream issue cloudflare/containers#30 asked for). The interception path
81
+ * needs the `ContainerProxy` worker entrypoint, which codegen re-exports
82
+ * from the generated container file automatically; the named-instance
83
+ * handle's `egress` controls adjust the lists at runtime.
84
+ */
85
+ allowedHosts?: ReadonlyArray<string>;
86
+ /**
87
+ * Build-time variables for a Dockerfile/Railpack image — wrangler's
88
+ * `image_vars` (equivalent to `docker build --build-arg`). For *runtime*
89
+ * values use {@link ContainerConfig.env} / {@link ContainerConfig.secrets}.
90
+ * Ignored for a pre-built `{ registry }` image.
91
+ */
92
+ buildArgs?: Readonly<Record<string, string>>;
93
+ /**
94
+ * The port the container listens on. Worker → container requests target
95
+ * this port. Locally the Dockerfile must also `EXPOSE` it. For a
96
+ * multi-port container also declare {@link ContainerConfig.requiredPorts}
97
+ * and route per request with the handle's `.port(n)`.
98
+ */
99
+ defaultPort?: number;
100
+ /**
101
+ * Hostnames the container may **never** reach — an egress deny-list
102
+ * (Cloudflare's `deniedHosts`). Overrides everything else, including
103
+ * `enableInternet: true` and {@link ContainerConfig.allowedHosts}. Glob
104
+ * patterns like `*.evil.com` are supported.
105
+ */
106
+ deniedHosts?: ReadonlyArray<string>;
107
+ /**
108
+ * Whether the container may open outbound internet connections. Defaults
109
+ * to `true` — the platform default. Note that container egress is billed
110
+ * per GB by Cloudflare. Combine with {@link ContainerConfig.allowedHosts} /
111
+ * {@link ContainerConfig.deniedHosts} for a precise egress firewall.
112
+ */
113
+ enableInternet?: boolean;
114
+ /**
115
+ * Default command to run inside the container, overriding the image's
116
+ * `ENTRYPOINT`/`CMD` (Cloudflare's `entrypoint`). A per-start override is
117
+ * still available via the named-instance handle's `start({ entrypoint })`.
118
+ */
119
+ entrypoint?: ReadonlyArray<string>;
120
+ /**
121
+ * Static environment variables passed to the container on every start.
122
+ * For secret values use {@link ContainerConfig.secrets} instead so they
123
+ * flow through Worker Secrets rather than source code.
124
+ */
125
+ env?: Readonly<Record<string, string>>;
126
+ /**
127
+ * Hard cap on how long an instance may run, measured from start regardless
128
+ * of activity — a runaway-cost backstop on top of the idle
129
+ * {@link ContainerConfig.sleepAfter}. Same grammar as `sleepAfter`
130
+ * (`"30s"`, `"5m"`, `"1h"`, or a plain number of seconds). When it elapses,
131
+ * the `LunoraContainer.onHardTimeoutExpired` hook runs (default: `stop()`).
132
+ * (Upstream cloudflare/containers#85.)
133
+ */
134
+ hardTimeout?: number | string;
135
+ /** Image source — a local Dockerfile path/directory or a registry reference. */
136
+ image: ContainerImageSource;
137
+ /**
138
+ * Resource class for each instance: a named Cloudflare instance type or a
139
+ * custom `{ vcpu, memoryMib, diskMb }` object.
140
+ */
141
+ instanceType?: ContainerInstanceType;
142
+ /**
143
+ * Intercept the container's outbound **HTTPS** traffic so the egress
144
+ * allow/deny lists apply to TLS connections too (Cloudflare's
145
+ * `interceptHttps`). Requires the image to trust the Cloudflare CA at
146
+ * `/etc/cloudflare/certs/cloudflare-containers-ca.crt`. Defaults to `false`
147
+ * (HTTP egress is gated regardless).
148
+ */
149
+ interceptHttps?: boolean;
150
+ /**
151
+ * Key-value metadata attached to every instance for metrics/observability
152
+ * (Cloudflare's container `labels`), e.g. `{ tenant: "acme", env: "prod" }`.
153
+ * A per-start override is available via the named-instance handle's
154
+ * `start({ labels })`.
155
+ */
156
+ labels?: Readonly<Record<string, string>>;
157
+ /**
158
+ * Maximum number of concurrently *running* instances. Stopped (slept)
159
+ * containers don't count. Also the default pool size for `.any()`.
160
+ */
161
+ maxInstances?: number;
162
+ /**
163
+ * Override for the wrangler `containers[].name` identifier. Defaults to
164
+ * wrangler's own default (worker name + class name + environment).
165
+ */
166
+ name?: string;
167
+ /**
168
+ * HTTP path Cloudflare polls to decide an instance is healthy
169
+ * (Cloudflare's `pingEndpoint`). Defaults to upstream's slash-less `"ping"`;
170
+ * either `"ping"` or `"/healthz"`-style paths are accepted. Set this when
171
+ * the container exposes its readiness check under a different route.
172
+ */
173
+ pingEndpoint?: string;
174
+ /**
175
+ * Application-level readiness probes that gate request proxying: a
176
+ * `ctx.containers.&lt;name>` fetch waits until every probe responds with its
177
+ * expected status before the request reaches the container — on top of the
178
+ * platform's port/`pingEndpoint` health wait. All probes run in parallel.
179
+ * Use these for readiness an open-port check can't see (migrations applied,
180
+ * caches warm). (Upstream cloudflare/containers#188.)
181
+ */
182
+ readyOn?: ReadonlyArray<ContainerReadinessCheck>;
183
+ /**
184
+ * Ports the container must be listening on before it's considered ready
185
+ * (Cloudflare's `requiredPorts`) — for multi-port containers. Start-up
186
+ * waits for every listed port, and the handle's `.port(n)` routes a request
187
+ * to any of them; {@link ContainerConfig.defaultPort} is the target when a
188
+ * request doesn't pick one.
189
+ */
190
+ requiredPorts?: ReadonlyArray<number>;
191
+ /**
192
+ * Rolling-deploy tuning. `stepPercentage` is the share of instances updated
193
+ * per rollout step (wrangler `rollout_step_percentage`); `gracePeriodSeconds`
194
+ * is how long an active instance is left running before it's eligible for
195
+ * update (wrangler `rollout_active_grace_period`).
196
+ */
197
+ rollout?: ContainerRollout;
198
+ /**
199
+ * Names of Worker secrets (from `wrangler secret` / `.dev.vars`) forwarded
200
+ * into the container's environment at instance start. Each declared name
201
+ * must exist on the Worker `env` — a missing one fails fast with a
202
+ * directed error instead of starting the container without it.
203
+ */
204
+ secrets?: ReadonlyArray<string>;
205
+ /**
206
+ * Cloudflare **Secrets Store** secrets forwarded into the container's
207
+ * environment, as a map of *container env-var name → Worker Secrets Store
208
+ * binding name*. Each binding is resolved with its async `.get()` the first
209
+ * time the instance starts, then injected as that env var — e.g.
210
+ * `{ STRIPE_KEY: "STRIPE_SECRET" }` runs `env.STRIPE_SECRET.get()` and sets
211
+ * `STRIPE_KEY` inside the container. Unlike {@link ContainerConfig.secrets}
212
+ * (plain Worker text secrets), this pulls from a `secrets_store_secrets`
213
+ * binding. A name already used by `env`/`secrets` is rejected at authoring
214
+ * time; a missing binding or unreadable value fails the start. Applies
215
+ * to the default start (the `ctx.containers` proxy path and a bare
216
+ * `start()`); a per-instance `start({ envVars })` replaces the env set
217
+ * wholesale, as it does for `env`/`secrets`. (Upstream
218
+ * cloudflare/containers#96.)
219
+ */
220
+ secretsStore?: Readonly<Record<string, string>>;
221
+ /**
222
+ * Idle timeout after which the instance is put to sleep, e.g. `"5m"`,
223
+ * `"30s"`, or a number of seconds. Cloudflare's default is `"10m"`.
224
+ */
225
+ sleepAfter?: number | string;
226
+ }
227
+ /**
228
+ * The value `defineContainer` returns: the validated config plus a brand the
229
+ * codegen discovery and the generated Container DO class key on.
230
+ */
231
+ interface ContainerDefinition extends ContainerConfig {
232
+ /** Brand marking a value as a Lunora container definition. */
233
+ readonly isLunoraContainer: true;
234
+ }
235
+ /** A normalized image source, as written into `wrangler.jsonc`. */
236
+ type NormalizedContainerImage = {
237
+ /** Build context directory (wrangler `image_build_context`). */
238
+ buildContext: string;
239
+ /** Path to the Dockerfile (wrangler `image`). */
240
+ dockerfilePath: string;
241
+ kind: "dockerfile";
242
+ } | {
243
+ /** Railpack source directory built + pushed at deploy time. */
244
+ buildDir: string;
245
+ kind: "build";
246
+ } | {
247
+ kind: "registry"; /** Fully-qualified image reference (wrangler `image`). */
248
+ reference: string;
249
+ };
250
+ /**
251
+ * Cloudflare Durable Object data-residency jurisdiction. Widening union —
252
+ * Cloudflare adds values over time.
253
+ * @see https://developers.cloudflare.com/durable-objects/reference/data-location/
254
+ */
255
+ type DurableObjectJurisdiction = "eu" | "fedramp" | "us";
256
+ /**
257
+ * Return a jurisdiction-restricted view of `namespace`, or `namespace`
258
+ * unchanged when no jurisdiction is configured. Fail-closed when the binding
259
+ * lacks `.jurisdiction()` so a residency constraint is never silently dropped.
260
+ *
261
+ * Generic over the namespace shape so both the `ctx.containers` client
262
+ * (`ContainerNamespaceLike`) and the lifecycle reporter (`ShardNamespaceLike`)
263
+ * share one implementation — the only requirement is an optional
264
+ * `.jurisdiction()` that returns the same namespace type.
265
+ */
266
+ export { BuildImageSource as B, ContainerConfig as C, DurableObjectJurisdiction as D, NormalizedContainerImage as N, RegistryImageSource as R, ContainerDefinition as a, ContainerImageSource as b, ContainerInstanceType as c, ContainerReadinessCheck as d, ContainerRollout as e, CustomContainerInstanceType as f, NamedContainerInstanceType as g };
package/package.json CHANGED
@@ -1,29 +1,64 @@
1
1
  {
2
2
  "name": "@lunora/container",
3
- "version": "0.0.0",
3
+ "version": "1.0.0-alpha.10",
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
+ "./otel": {
50
+ "types": "./dist/otel.d.ts",
51
+ "import": "./dist/otel.mjs"
52
+ },
53
+ "./package.json": "./package.json"
54
+ },
23
55
  "publishConfig": {
24
56
  "access": "public"
25
57
  },
26
- "files": [
27
- "README.md"
28
- ]
58
+ "dependencies": {
59
+ "@lunora/errors": "1.0.0-alpha.4"
60
+ },
61
+ "engines": {
62
+ "node": "^22.15.0 || >=24.11.0"
63
+ }
29
64
  }