@pbvision/cloud-run-service
v0.0.48
Published
fastify-firestore-service Web Framework on Cloud Run
Readme
Cloud Run Service library
Setup
yarn setup- Install recommended vscode extensions
- Open the Extensions tab in vscode
- In the filter box, type "@recommended" and press enter to search
- Make sure all recommended extensions are installed
Requirements
Must run with a service account named
cr-${process.env.SERVICE}@${process.env.GCLOUD_PROJECT}.iam.gserviceaccount.comwith at least these permissions (along with whatever else your service requires):roles/run.invoker- if the service needs to call other servicescloudtasks.tasks.create- if the service needs to enqueue tasks- roles/iam.serviceAccountUser - if the tasks need to be able to invoke an internal cloud run service (i.e., one which restricts invokers to specific service accounts, to include this service's account)
Environment variables:
- Required:
GCLOUD_PROJECT- the project ID this service is running in; must end in-devor-prodGIT_HASH- the commit from which the current code was generatedK_REVISION- provided by cloud run (the revision ID)- When running a local server, it will be
localhost - When running it unit tests, it should be
unittest- If this is
unittestthenisUnitTestingwill be true.
- If this is
- When running a local server, it will be
NODE_ENV- If this is
localhostthenisLocalhostwill be true. This is always the case when running locally, even if we're connecting to real cloud resources (like Firestore or Task Queue).isCloudis the opposite ofisLocalhost.
- If this is
devthenisDevwill be true. - If this is
prodthenisProdwill be true.
- If this is
REGION- the region this service's cloud run is located inSERVICE- the name of this service
- Optional:
- Emulation (must provide all or none of these) for GCP services:
CLOUD_TASKS_EMULATOR_PORTFIRESTORE_EMULATOR_HOST
CLOUD_RUN_HOSTNAME_SUFFIX- the hostname of our cloud run instances in this region, excluding theSERVICEname portion at the beginning. Only required if using thecallServiceAPI()function.COOKIE_SECRET- used to sign cookie data (cookies are disabled if omitted)PORT- defaults to 8080 if omittedSENTRY_DSN- the Sentry URL to report errors to (not used on localhost)
- Emulation (must provide all or none of these) for GCP services:
- Required:
