Diffinery

homeflare/celldpublic

36 lines · 1.3 KBRaw History
1# Container
2
3A Durable Object that supervises a container. The object extends the
4`Container` class from `@cloudflare/containers`, and the image is the
5`Dockerfile` beside it: a small Python HTTP server on port 8080.
6
7Install the dependency, then run the example. `celld dev` builds the image
8with the Docker or Podman CLI on your `PATH` and starts the container the
9first time a request reaches the object:
10
11```sh
12npm install
13celld dev
14curl http://127.0.0.1:9876/container/alpha
15curl http://127.0.0.1:9876/container/beta
16curl http://127.0.0.1:9876/lb
17```
18
19Each path under `/container/` is one object, and each object runs one
20container. The response carries the container's hostname, so two paths show
21two containers. `/lb` spreads requests over three containers.
22
23Deploy to a fleet from this directory. `celld deploy` saves the image to the
24bucket, and each node loads it the first time a cell of the class starts:
25
26```sh
27celld deploy . --bucket s3://my-cells-bucket
28```
29
30Every node that serves the class needs a container engine: a Docker or
31Podman daemon on its default socket, or the socket named by `DOCKER_HOST`.
32
33The class declares `instance_type: "basic"`, a quarter of a CPU and 1 GiB.
34Without a type a container gets Cloudflare's `dev` type, a sixteenth of a
35CPU, and this server takes about four seconds to start on it instead of
36under one.