Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ To see the pieces working together, start with the examples:
through `env.LOADER`. No container.
- [`examples/think`](examples/think) — an agent that uses the
workspace as its working directory.
- [`examples/tutorial`](examples/tutorial) — the smallest version of
that idea, built up step by step: one endpoint, one file, an agent
that writes markdown on the host and runs `pandoc` on it in the
container.

## Repository layout

Expand Down
12 changes: 12 additions & 0 deletions examples/tutorial/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copy to .env for local development, or set these as secrets in
# production with `wrangler secret put <NAME>`. The generated
# worker-configuration.d.ts picks the names up from this file:
# wrangler types --env-file=.env.example
#
# The R2 binding alone can't mint a presigned URL, so the assets
# client needs R2 S3 credentials. Create an R2 API token scoped to
# the bucket and fill in the values below.

R2_ACCESS_KEY_ID=
R2_SECRET_ACCESS_KEY=
CLOUDFLARE_ACCOUNT_ID=
3 changes: 3 additions & 0 deletions examples/tutorial/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.wrangler/
.env
.dev.vars*
42 changes: 42 additions & 0 deletions examples/tutorial/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Container image for the recipe card tutorial. Same wiring as
# examples/think — pull the wsd binary out of the public GHCR image,
# drop it into a slim debian, and run it as PID 1. The :VERSION tag is
# rewritten in lockstep with the rest of the monorepo by
# script/set-versions.mjs.
#
# wsd mounts the workspace at MOUNT_POINT, so a file the host writes
# through the Workspace is on disk for pandoc to read, and the PDF
# pandoc writes syncs back to the durable object.

FROM ghcr.io/cloudflare/workspace-wsd-linux-x64:0.0.0-alpha.11 AS wsd

FROM debian:stable-slim

ARG PANDOC_VERSION=3.10
ARG TYPST_VERSION=0.15.1

# pandoc converts the agent's markdown; typst is the PDF engine, a
# single 30 MB binary instead of the several hundred megabytes a LaTeX
# install would cost. curl is only the download tool for those two.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
fuse3 libfuse2t64 ca-certificates curl xz-utils \
&& curl -fsSL -o /tmp/pandoc.deb \
"https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-1-amd64.deb" \
&& dpkg -i /tmp/pandoc.deb \
&& curl -fsSL "https://github.com/typst/typst/releases/download/v${TYPST_VERSION}/typst-x86_64-unknown-linux-musl.tar.xz" \
| tar -xJ -C /tmp \
&& mv /tmp/typst-x86_64-unknown-linux-musl/typst /usr/local/bin/typst \
&& rm -rf /tmp/pandoc.deb /tmp/typst-x86_64-unknown-linux-musl /var/lib/apt/lists/*

COPY --from=wsd /usr/local/bin/wsd /usr/local/bin/wsd

ENV PORT=8080
ENV MOUNT_POINT=/workspace
# FUSE_MOUNT=auto uses the real kernel FUSE backend when /dev/fuse is
# reachable (Cloudflare Containers) and falls back to the userspace
# shim otherwise (wrangler dev). One image works in both places.
ENV FUSE_MOUNT=auto
EXPOSE 8080

ENTRYPOINT ["/usr/local/bin/wsd"]
Loading