Runs a simple nest.js api in Google Cloud Run
All git branches are merged into master
- rock/run-in-cloud - the basic nest app running with a default controller and a process.env dump
- rock/set-env-from-deploy - set NODE_ENV to develop for local development and set it to production on Cloud Run
- rock/firestore - add firebase usable from development environment and from Cloud Run
$ gcloud builds submit --tag gcr.io/[PROJECT-ID]/nest-cloud-run
$ gcloud beta run deploy --image gcr.io/[PROJECT-ID]/nest-cloud-run --platform managed
- To set environment variables during deployment:
$ gcloud beta run deploy --image gcr.io/[PROJECT-ID]/nest-cloud-run --platform managed -update-env-vars NODE_ENV=production
- Create service account
$ gcloud iam service-accounts create [username]
- Set new account as owner
$ gcloud projects add-iam-policy-binding [PROJECT_ID] --member "serviceAccount:[NAME]@[PROJECT_ID].iam.gserviceaccount.com" --role "roles/owner"
- Generate a key file:
$ gcloud iam service-accounts keys create [somefilename].json --iam-account [email protected]
The config service is updated to use the key file as specified in the .env file if the service is running in development. When this is deployed in cloud run, the key file and the .env file is not deployed, based on the .dockerignore file.
Added a firestore service that initializes the firestore store and create objects in firestore. Create a contoller for users (could be any CRUD type) that on POST will create an object in firestore.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov