Skip to content

Example of Interval running on an always-on Google Cloud Run instance.

Notifications You must be signed in to change notification settings

interval/interval-google-cloud-run

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

interval-google-cloud-run

Here's an example project with Interval running on Google Cloud Run.


Before you begin

There are two requirements for running Interval on Google Cloud Run:

  • Your instance must use always allocated CPUs with a single allocated instance
  • Your entrypoint must listen for connections on port 8080 (this is how Google knows that your app is online):
// src/index.ts
import "dotenv/config";
import Interval, { io } from "@interval/sdk";

// Google Cloud Run requires a process listening on port 8080
const http = require("http");
const server = http.createServer(() => {});
server.listen(8080);

const interval = new Interval({
  apiKey: process.env.INTERVAL_API_KEY,
  actions: {
    hello_world: async () => {
      const name = await io.input.text("Your name");
      return `Hello, ${name}`;
    },
  },
});

interval.listen();

Installation

Use the following instructions to set up a new instance on Google Cloud Run to run Interval. This guide assumes you'll be setting up continuous deployment from a GitHub repo using a Dockerfile.

For examples of how to set up your project, check out the sample Dockerfile and index.ts.

  1. In Google Cloud Platform, go to the Cloud Run dashboard
  2. Click Create Service
  3. Choose "Continuously deploy new revisions from a source repository", then click the Set Up With Cloud Build button
  4. Pick your repo from GitHub and click Next
  5. Under Build Type, select the Dockerfile option
  6. Under CPU allocation, pick "CPU is always allocated"
  7. Set minimum and maximum number of instances to 1
  8. Under Authentication, choose "Allow unauthenticated invocations"
  9. Click Container, Variables & Secrets, Connections, Security
  10. Under Variables & Secrets > Environment Variables, add your API key as INTERVAL_API_KEY. You can get your API key from the dashboard.
  11. Click Create

That's it! Cloud Build will build and deploy your app to Cloud Run.

About

Example of Interval running on an always-on Google Cloud Run instance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •