Skip to content

Commit e4879c8

Browse files
authored
misc fixups - add changeset and more readme additions (#94)
* More readme improvements * Add changeset for #77
1 parent 514285e commit e4879c8

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

.changeset/tricky-poems-juggle.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@cloudflare/containers': patch
3+
---
4+
5+
Miscellaneous minor fixes and improvements to starting containers and port checking.
6+
7+
- When calling `startAndWaitForPorts`, check for port-readiness even if the container is started.
8+
9+
- Add `waitForPort()` method.
10+
11+
- Add options to configure timeout and polling interval to `start`, similar to what `cancellationOptions` on `startAndWaitForPorts`. `start` does not check for port readiness but still polls for available and starting container.
12+
13+
- Respect `waitInterval` if passed in via `start` or `startAndWaitForPorts` when polling container for readiness.

README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Container, getContainer, getRandom } from '@cloudflare/containers';
2424
export class MyContainer extends Container {
2525
// Configure default port for the container
2626
defaultPort = 8080;
27+
// After 1 minute of no new activity, shutdown the container
2728
sleepAfter = '1m';
2829
}
2930

@@ -57,12 +58,35 @@ The `Container` class that extends a container-enbled Durable Object to provide
5758

5859
#### Properties
5960

60-
- `defaultPort?`: Optional default port to use when communicating with the container. If not set, you must specify port like `fetch(switchPort(req, 8080))` or `containerFetch(req, 8080)`.
61-
- `requiredPorts?`: Array of ports that should be checked for availability during container startup. Used by `startAndWaitForPorts` when no specific ports are provided.
62-
- `sleepAfter`: How long to keep the container alive without activity (format: number for seconds, or string like "5m", "30s", "1h")
63-
- `env`: Environment variables to pass to the container (Record<string, string>) when starting up. These are the defaults but can be overriden on a per-instance basis when starting.
64-
- `entrypoint?`: Custom entrypoint to override container default (string[]). These are the defaults but can be overriden on a per-instance basis when starting.
65-
- `enableInternet`: Whether to enable internet access for the container (boolean, default: `true`). These are the defaults but can be overriden on a per-instance basis when starting.
61+
- `defaultPort?`
62+
63+
Optional default port to use when communicating with the container. If this is not set, or you want to target a specific port on your container, you can specify the port with `fetch(switchPort(req, 8080))` or `containerFetch(req, 8080)`.
64+
65+
- `requiredPorts?`
66+
67+
Array of ports that should be checked for availability during container startup. Used by `startAndWaitForPorts` when no specific ports are provided.
68+
69+
- `sleepAfter`
70+
71+
How long to keep the container alive without activity (format: number for seconds, or string like "5m", "30s", "1h").
72+
73+
Defaults to "10m", meaning that after the Container class Durable Object receives no requests for 10 minutes, it will shut down the container.
74+
75+
The following properties are used to set defaults when starting the container, but can be overriden on a per-instance basis by passing in values to `startAndWaitForPorts()` or `start()`.
76+
77+
- `env?: Record<string, string>`
78+
79+
Environment variables to pass to the container when starting up.
80+
81+
- `entrypoint?: string[]`
82+
83+
Specify an entrypoint to override image default.
84+
85+
- `enableInternet: boolean`
86+
87+
Whether to enable internet access for the container.
88+
89+
Defaults to `true`.
6690

6791
#### Methods
6892

0 commit comments

Comments
 (0)