A reference project to build, and deploy a TypeScript Node Express service to GCP Cloud Run
- Please ensure you have Google Cloud SDK installed locally
- Create a
.env
file at project root directory, and populate with following:
PORT=<PORT-NUMBER>
JWT_KEY=<A-SECRET-JWT-TOKEN>
MONGO_DB_CONNECTION_STRING=<YOUR-MONGO-DB-CONNECTION-STRING>
- Then, run the following commands:
npm i # installs Node dependencies
npm run dev` # app listening at http://localhost:8080
gcloud builds submit --tag gcr.io/<PROJECT-ID>/ts-node
-
Create two secrets on Secrets Manager named
jwt-key
, andmongo-db-connection-string
-
Deploy to Cloud Run by running:
gcloud run deploy --image gcr.io/<PROJECT-ID>/ts-node --platform managed
- Allow Cloud Run service access to the secrets as secret environment variables. See GCP Cloud Run documentation here
- Make a
GET
request at<CLOUD-RUN-SERVICE-URL>/ping
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.