Skip to content

Instantly share code, notes, and snippets.

View grant's full-sized avatar
Coding daily!

Grant Timmerman grant

Coding daily!
View GitHub Profile
@grant
grant / deploy.sh
Last active June 8, 2020 23:52
Deploy a .NET container to Cloud Run
GCP_PROJECT=$(gcloud config list --format 'value(core.project)')
gcloud builds submit --tag gcr.io/$GCP_PROJECT/hellodotnet
gcloud run deploy hellodotnet \
--image gcr.io/$GCP_PROJECT/hellodotnet \
--platform managed \
--no-allow-unauthenticated
@grant
grant / install.sh
Created June 8, 2020 20:31
Install the .NET FF
dotnet new -i Google.Cloud.Functions.Templates::1.0.0-alpha07
@grant
grant / setup.sh
Created June 8, 2020 20:30
Setup a .NET function with the Functions Framework
mkdir HelloFunctions
cd HelloFunctions
dotnet new gcf-http
@grant
grant / run.sh
Created April 21, 2020 20:59
Ruby FF Run
# Deploy your container to Cloud Run
gcloud run deploy helloruby --image gcr.io/$GCP_PROJECT/helloruby \
--platform managed \
--allow-unauthenticated
@grant
grant / build.sh
Created April 21, 2020 20:58
Ruby FF Build
# Set env var "GCP_PROJECT" to our project name
GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null)
# Build and upload your image in Google Container Registry
gcloud builds submit --tag gcr.io/$GCP_PROJECT/helloruby
@grant
grant / Dockerfile
Last active April 21, 2020 20:58
Ruby FF Dockerfile
FROM ruby:2.7
WORKDIR /app
COPY . .
RUN gem install --no-document bundler \
&& bundle config --local frozen true \
&& bundle config --local without "development test" \
&& bundle install
ENTRYPOINT ["bundle", "exec", "functions-framework", "--target=hello"]
@grant
grant / localhost.sh
Created April 21, 2020 20:56
Ruby FF Localhost
# Install the functions_framework gem and other dependencies
bundle install
# Start the web server in the foreground
bundle exec functions-framework --target hello
@grant
grant / app.rb
Created April 21, 2020 20:55
Ruby FF App
require "functions_framework"
FunctionsFramework.http("hello") do |request|
"Hello, world!\n"
end
@grant
grant / Dockerfile
Last active May 13, 2020 17:49
Deno Dockerfile
FROM hayd/alpine-deno:1.0.0-rc2
WORKDIR /app
# These steps will be re-run upon each file change in your working directory:
COPY . ./
# Added to ENTRYPOINT of base image.
CMD ["run", "--allow-env", "--allow-net", "main.ts"]
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import "https://deno.land/x/dotenv/mod.ts";
const PORT = Deno.env.get('PORT') || 8080;
const s = serve(`0.0.0.0:${PORT}`);
const body = new TextEncoder().encode("Hello, Deno\n");
console.log(`Server started on port ${PORT}`);
for await (const req of s) {
req.respond({ body });