Skip to content

Instantly share code, notes, and snippets.

@jimmont
Created February 19, 2021 05:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmont/5b26aebf8b9865cec35a92ffc1c39d5a to your computer and use it in GitHub Desktop.
Save jimmont/5b26aebf8b9865cec35a92ffc1c39d5a to your computer and use it in GitHub Desktop.
Deno on Cloud Run
# TODO cleanup
log/
logs/
**/log/
**/logs/
**/*.log
secrets.txt
.git
.gitignore
.cache
*.vim
**/*.vim
// 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" });
}
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