diff --git a/README.md b/README.md index 0eeb1e22..f81f9760 100644 --- a/README.md +++ b/README.md @@ -51,17 +51,17 @@ WORKDIR /app # Prefer not to run as root. USER deno -# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified). -# Ideally cache deps.ts will download and compile _all_ external files used in main.ts. -COPY deps.ts . -RUN deno install --entrypoint deps.ts +# Cache the dependencies as a layer (the following two steps are re-run only when deno.json is modified). +# Ideally cache deno.json will download and compile _all_ external files used in main.ts. +COPY deno.json . +RUN deno install # These steps will be re-run upon each file change in your working directory: COPY . . # Compile the main app so that it doesn't need to be compiled each startup/entry. RUN deno cache main.ts -CMD ["run", "--allow-net", "main.ts"] +CMD ["serve", "--port", "1993", "main.ts"] ``` and build and run this locally: diff --git a/example/Dockerfile b/example/Dockerfile index fa7b5cf6..410a3504 100644 --- a/example/Dockerfile +++ b/example/Dockerfile @@ -8,14 +8,14 @@ WORKDIR /app # Prefer not to run as root. USER deno -# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified). -# Ideally cache deps.ts will download and compile _all_ external files used in main.ts. -COPY deps.ts . -RUN deno install --entrypoint deps.ts +# Cache the dependencies as a layer (the following two steps are re-run only when deno.json is modified). +# Ideally cache deno.json will download and compile _all_ external files used in main.ts. +COPY deno.json . +RUN deno install # These steps will be re-run upon each file change in your working directory: COPY . . # Compile the main app so that it doesn't need to be compiled each startup/entry. RUN deno cache main.ts -CMD ["run", "--allow-net", "main.ts"] +CMD ["serve", "--port", "1993", "main.ts"] diff --git a/example/deno.json b/example/deno.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/example/deno.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/example/deps.ts b/example/deps.ts deleted file mode 100644 index b7b9f5dd..00000000 --- a/example/deps.ts +++ /dev/null @@ -1 +0,0 @@ -export { serve } from "https://deno.land/std@0.77.0/http/server.ts"; diff --git a/example/main.ts b/example/main.ts index 612f8a3e..1bcc4828 100644 --- a/example/main.ts +++ b/example/main.ts @@ -1,10 +1,6 @@ -import { serve } from "./deps.ts"; +export default { + async fetch(request) { + return new Response("Hello world!"); + }, +}; -const PORT = 1993; -const s = serve(`0.0.0.0:${PORT}`); -const body = new TextEncoder().encode("Hello World\n"); - -console.log(`Server started on port ${PORT}`); -for await (const req of s) { - req.respond({ body }); -}