diff --git a/community/samples/serving/helloworld-deno/Dockerfile b/community/samples/serving/helloworld-deno/Dockerfile index fd387f1a5..9d8022576 100644 --- a/community/samples/serving/helloworld-deno/Dockerfile +++ b/community/samples/serving/helloworld-deno/Dockerfile @@ -1,14 +1,8 @@ FROM hayd/alpine-deno:1.0.0-rc2 WORKDIR /app -# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified). -COPY deps.ts ./ -RUN deno fetch deps.ts - # 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 fetch main.ts # Added to ENTRYPOINT of base image. -CMD ["--allow-net", "main.ts"] +CMD ["run", "--allow-env", "--allow-net", "main.ts"] diff --git a/community/samples/serving/helloworld-deno/README.md b/community/samples/serving/helloworld-deno/README.md index 930fbf682..fa1329d75 100644 --- a/community/samples/serving/helloworld-deno/README.md +++ b/community/samples/serving/helloworld-deno/README.md @@ -29,15 +29,16 @@ cd knative-docs/docs/serving/samples/hello-world/helloworld-deno 1. Create a new file named `deps.ts` and paste the following script: ```ts - export { serve } from "https://deno.land/std@v0.38.0/http/server.ts"; + export { serve } from "https://deno.land/std@v1.0.0-rc2/http/server.ts"; ``` 1. Create a new file named `main.ts` and paste the following script: ```ts import { serve } from "./deps.ts"; + import "https://deno.land/x/dotenv/mod.ts"; - const PORT = 8080; + const PORT = Deno.env.get('PORT') || 8080; const s = serve(`0.0.0.0:${PORT}`); const body = new TextEncoder().encode("Hello Deno\n"); @@ -47,29 +48,18 @@ cd knative-docs/docs/serving/samples/hello-world/helloworld-deno } ``` - 1. Create a new file named `Dockerfile` and copy the code block below into it. +1. Create a new file named `Dockerfile` and copy the code block below into it. - ```docker - FROM hayd/alpine-deno:0.38.0 - EXPOSE 8080 - WORKDIR /app + ```docker + FROM hayd/alpine-deno:1.0.0-rc2 + WORKDIR /app - # Prefer not to run as root. - USER deno + # These steps will be re-run upon each file change in your working directory: + COPY . ./ - # Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified). - # Ideally fetch deps.ts will download and compile _all_ external files used in main.ts. - COPY deps.ts . - RUN deno fetch deps.ts - - # These steps will be re-run upon each file change in your working directory: - ADD . . - # Compile the main app so that it doesn't need to be compiled each startup/entry. - RUN deno fetch main.ts - - # Added to ENTRYPOINT of base image. - CMD ["--allow-net", "main.ts"] - ``` + # Added to ENTRYPOINT of base image. + CMD ["run", "--allow-env", "--allow-net", "main.ts"] + ``` 1. Create a new file, `service.yaml` and copy the following service definition into the file. Make sure to replace `{username}` with your Docker Hub diff --git a/community/samples/serving/helloworld-deno/deps.ts b/community/samples/serving/helloworld-deno/deps.ts index bf4d2434c..3005efba3 100644 --- a/community/samples/serving/helloworld-deno/deps.ts +++ b/community/samples/serving/helloworld-deno/deps.ts @@ -1 +1 @@ -export { serve } from "https://deno.land/std@v0.38.0/http/server.ts"; +export { serve } from "https://deno.land/std@v1.0.0-rc2/http/server.ts"; diff --git a/community/samples/serving/helloworld-deno/main.ts b/community/samples/serving/helloworld-deno/main.ts index ca842c8e0..c01c121f2 100644 --- a/community/samples/serving/helloworld-deno/main.ts +++ b/community/samples/serving/helloworld-deno/main.ts @@ -1,7 +1,7 @@ import { serve } from "./deps.ts"; -import "https://deno.land/x/dotenv/load.ts"; +import "https://deno.land/x/dotenv/mod.ts"; -const PORT = Deno.env('PORT') || 8080; +const PORT = Deno.env.get('PORT') || 8080; const s = serve(`0.0.0.0:${PORT}`); const body = new TextEncoder().encode("Hello Deno\n");