Created
February 19, 2021 05:17
-
-
Save jimmont/5b26aebf8b9865cec35a92ffc1c39d5a to your computer and use it in GitHub Desktop.
Deno on Cloud Run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO cleanup | |
log/ | |
logs/ | |
**/log/ | |
**/logs/ | |
**/*.log | |
secrets.txt | |
.git | |
.gitignore | |
.cache | |
*.vim | |
**/*.vim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deno run --allow-env --allow-net app.js | |
import { serve } from "https://deno.land/std/http/server.ts"; | |
const port = Number(Deno.env.get("PORT") || 8901); | |
const s = serve({ port }); | |
console.log(`open http://localhost:${port}/`); | |
for await (const req of s) { | |
req.respond({ body: "hi Mom\n" }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
#NOTE alpine:latest DOES NOT WORK as-is with Deno when this was written | |
# install gcloud sdk https://cloud.google.com/sdk/docs/install | |
# create a project https://console.cloud.google.com/home/dashboard | |
# substitute `project-name` below | |
# gcloud builds submit --tag gcr.io/project-name/project-name | |
# gcloud beta run deploy project-name --image gcr.io/project-name/project-name --platform=managed | |
RUN apt-get update \ | |
&& apt-get install -y curl unzip \ | |
&& mkdir -p /usr/src/project-name \ | |
&& curl -fsSL https://deno.land/x/install/install.sh | sh | |
ENV DENO_INSTALL="/root/.deno" | |
ENV PATH="$DENO_INSTALL/bin:$PATH" | |
# assumes the current working directory | |
WORKDIR /usr/src/project-name | |
COPY . /usr/src/project-name | |
EXPOSE $PORT | |
CMD ["deno", "run", "--allow-net", "--allow-env", "app.js"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment