Skip to content

Commit cf56b75

Browse files
committed
pr feedback and fixups
1 parent 3ff3d87 commit cf56b75

File tree

6 files changed

+31
-30
lines changed

6 files changed

+31
-30
lines changed

src/content/docs/containers/examples/container-backend.mdx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ For a full example, see the [Static Frontend + Container Backend Template](https
3232
{
3333
"class_name": "Backend",
3434
"image": "./Dockerfile",
35+
"max_instances": 3
3536
}
3637
],
3738
"durable_objects": {
@@ -175,6 +176,7 @@ Your container should be able to handle requests to `/api/widgets`.
175176
In this case, we'll use a simple Golang backend that returns a hard-coded list of widgets.
176177

177178
<Details header="server.go">
179+
178180
```go
179181
package main
180182

@@ -185,23 +187,23 @@ import (
185187
)
186188

187189
func handler(w http.ResponseWriter, r \*http.Request) {
188-
widgets := []map[string]interface{}{
189-
{"id": 1, "name": "Widget A"},
190-
{"id": 2, "name": "Sprocket B"},
191-
{"id": 3, "name": "Gear C"},
192-
}
190+
widgets := []map[string]interface{}{
191+
{"id": 1, "name": "Widget A"},
192+
{"id": 2, "name": "Sprocket B"},
193+
{"id": 3, "name": "Gear C"},
194+
}
193195

194-
w.Header().Set("Content-Type", "application/json")
195-
w.Header().Set("Access-Control-Allow-Origin", "*")
196-
json.NewEncoder(w).Encode(widgets)
196+
w.Header().Set("Content-Type", "application/json")
197+
w.Header().Set("Access-Control-Allow-Origin", "*")
198+
json.NewEncoder(w).Encode(widgets)
197199

198200
}
199201

200202
func main() {
201-
http.HandleFunc("/api/widgets", handler)
202-
log.Fatal(http.ListenAndServe(":8080", nil))
203+
http.HandleFunc("/api/widgets", handler)
204+
log.Fatal(http.ListenAndServe(":8080", nil))
203205
}
204206

205207
```
208+
206209
</Details>
207-
```

src/content/docs/containers/examples/status-hooks.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
summary: Execute Workers code in reaction to Container status changes
43
pcx_content_type: example
54
title: Status Hooks
@@ -9,7 +8,7 @@ description: Execute Workers code in reaction to Container status changes
98
---
109

1110
When a Container starts, stops, and errors, it can trigger code execution in a Worker
12-
that has defined status hooks on the `Container` class.
11+
that has defined status hooks on the `Container` class. Refer to the [Container package docs](https://github.com/cloudflare/containers/blob/main/README.md#lifecycle-hooks) for more details.
1312

1413
```js
1514
import { Container } from '@cloudflare/containers';

src/content/docs/containers/examples/websocket.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
summary: Forwarding a Websocket request to a Container
43
pcx_content_type: example
54
title: Websocket to Container
@@ -8,11 +7,11 @@ sidebar:
87
description: Forwarding a Websocket request to a Container
98
---
109

11-
WebSocket requests are automatically forwarded to a container using the default`fetch`
10+
WebSocket requests are automatically forwarded to a container using the default `fetch`
1211
method on the `Container` class:
1312

1413
```js
15-
import { Container, getContainer } from "@cloudflare/workers-types";
14+
import { Container, getContainer } from "@cloudflare/containers";
1615

1716
export class MyContainer extends Container {
1817
defaultPort = 8080;
@@ -27,6 +26,5 @@ export default {
2726
};
2827
```
2928

30-
Additionally, the `containerFetch` method can be used to forward WebSocket requests as well.
31-
29+
View a full example in the [Container class repository](https://github.com/cloudflare/containers/tree/main/examples/websocket).
3230
{/* TODO: Add more advanced examples - like kicking off a WS request then passing messages to container from the WS */}

src/content/docs/containers/platform-details/architecture.mdx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ by a datacenter in a location with the best latency between itself and the reque
2525
A different datacenter may be selected to optimize overall latency, if [Smart Placement](/workers/configuration/smart-placement/)
2626
is on, or if the nearest location is under heavy load.
2727

28-
Because all Container requests are passed through a Worker, end-users cannot make TCP or
28+
Because all Container requests are passed through a Worker, end-users cannot make non-HTTP TCP or
2929
UDP requests to a Container instance. If you have a use case that requires inbound TCP
3030
or UDP from an end-user, please [let us know](https://forms.gle/AGSq54VvUje6kmKu8).
3131

@@ -81,25 +81,29 @@ This location will again be the nearest location to the originating request with
8181
Each container instance runs inside its own VM, which provides strong
8282
isolation from other workloads running on Cloudflare's network. Containers
8383
should be built for the `linux/amd64` architecture, and should stay within
84-
[size limits](/containers/platform-details/limits). [Logging](/containers/faq/#how-do-container-logs-work), metrics collection, and
85-
networking are automatically set up on each container, if configured by the developer.
84+
[size limits](/containers/platform-details/limits).
8685

87-
### After a request
86+
[Logging](/containers/faq/#how-do-container-logs-work), metrics collection, and
87+
[networking](/containers/faq/#how-do-i-allow-or-disallow-egress-from-my-container) are automatically set up on each container, as configured by the developer.
88+
89+
### Container shutdown
8890

8991
Cloudflare will not actively shut off a container instance after a specific amount of
90-
time. If you do not set `sleepAfter` on your Container class, or stop the instance
92+
time. If you do not set [`sleepAfter`](https://github.com/cloudflare/containers/blob/main/README.md#properties) on your Container class, or stop the instance
9193
manually, it will continue to run unless its host server is restarted. This
9294
happens on an irregular cadence, but frequently enough where Cloudflare does not
9395
guarantee that any instance will run for any set period of time.
9496

97+
You can manually shutdown a container instance by calling `stop()` or `destroy()` on it - refer to the [Container package docs](https://github.com/cloudflare/containers/blob/main/README.md#container-methods) for more details.
98+
9599
When a container instance is going to be shut down, it is sent a `SIGTERM` signal,
96100
and then a `SIGKILL` signal after 15 minutes. You should perform any necessary
97-
cleanup to ensure a graceful shutdown in this time. The container instance
98-
will be rebooted elsewhere shortly after this.
101+
cleanup to ensure a graceful shutdown in this time.
102+
103+
#### Persistent disk
99104

100105
All disk is ephemeral. When a Container instance goes to sleep, the next time
101106
it is started, it will have a fresh disk as defined by its container image.
102-
103107
Persistent disk is something the Cloudflare team is exploring in the future, but
104108
is not slated for the near term.
105109

src/content/docs/containers/platform-details/environment-variables.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ The container runtime automatically sets the following variables:
1313

1414
- `CLOUDFLARE_APPLICATION_ID` - the ID of the Containers application
1515
- `CLOUDFLARE_COUNTRY_A2` - the [ISO 3166-1 Alpha 2 code](https://www.iso.org/obp/ui/#search/code/) of a country the container is placed in
16-
- `CLOUDFLARE_DEPLOYMENT_ID` - the ID of the container instance
1716
- `CLOUDFLARE_LOCATION` - a name of a location the container is placed in
18-
- `CLOUDFLARE_PLACEMENT_ID` - a placement ID
1917
- `CLOUDFLARE_REGION` - a region name
20-
- `CLOUDFLARE_DURABLE_OBJECT_ID` - the ID of the Durable Object that the container is bound to
18+
- `CLOUDFLARE_DURABLE_OBJECT_ID` - the ID of the Durable Object instance that the container is bound to
2119

2220
## User-defined environment variables
2321

src/content/docs/containers/platform-details/image-management.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ This will output an image registry URI that you can then use in your Wrangler co
8080
```json
8181
{
8282
"containers": {
83-
"image": "registry.cloudflare.com/your-image:tag"
83+
"image": "registry.cloudflare.com/your-account-id/your-image:tag"
8484
// ...rest of config...
8585
}
8686
}

0 commit comments

Comments
 (0)