Skip to content

Latest commit

 

History

History
58 lines (43 loc) · 1.51 KB

DEVELOPMENT.md

File metadata and controls

58 lines (43 loc) · 1.51 KB

Development

Deploy Cloud Run site using Terraform

Prerequisites

  • Install Terraform
  • Install ko
  • Set the KO_DOCKER_REPO env var to the GCR repository you'd like to deploy to (e.g., KO_DOCKER_REPO=gcr.io/gcping-devrel)
  • Install the current version of Node.js (>= v16).
  • Ensure your credentials are fresh with:
$ gcloud auth login                      # Used by ko
$ gcloud auth application-default login  # Used by Terraform
  • Run terraform -chdir=tools/terraform/ init to fetch the Terraform state, etc.
  • In Cloud Shell, if you see errors about IPv6 addresses not resolving, run ./bin/prefer-ipv4.sh

Build the frontend

$ cd web
$ npm install
$ npm run build  # generate the frontend

Deploy

$ export KO_DOCKER_REPO=gcr.io/gcping-devrel # prod only, use other repo for dev
$ terraform -chdir=tools/terraform/ apply -var image=$(ko publish -P ./cmd/ping/)

This deploys the ping service to all Cloud Run regions and configures a global HTTPS Load Balancer with Google-managed SSL certificate for global.gcping.com.

Run frontend locally

First, start the Ping server with:

# starts a server on localhost:8080
go run ./cmd/ping/main.go

Next, within the web directory, run:

# starts a frontend server at localhost:1234
npm start

The frontend server when run locally is configured to proxy all API requests to localhost:8080.