minimal-typescript-express
Starter repo for Node.js (with typescript) applications with Express. This template repo can also be used to accelerate deployment of PoC to GCP.
yarn
yarn run dev
Dockerize
docker build --platform=linux/amd64 -t minimal-typescript-express .
docker run -p 3000:3000 minimal-typescript-express
Deploy to GCP Cloud Run
-
Google Cloud CLI
Install -
Setup Artifact Registry for docker images in GCP
./gcp_setup_docker_repo.sh --name minimal-typescript-express --project_id your-gcp-project-id
-
Deploy to GCP Cloud Run. Creates an accessible instance.
./gcp_deploy.sh --name minimal-typescript-express --project_id your-gcp-project-id
-
Setup Load balancing and Static IP
./gcp_setup_loadbalancing.sh --name minimal-typescript-express --project_id your-gcp-project-id
-
www.example.com and example.com
List your created Static IP. You should be able to access Cloud Run service on the IP address within 10 minutes. Create A records for your domain
gcloud compute addresses list
and setup A records on your domain registrar
www A 30.90.80.100
@ A 30.90.80.100
-
Cleaning up
Delete all created resources
./gcp_cleanup.sh --name minimal-typescript-express --project_id your-gcp-project-id
Manual deploy
- Auth to gcp
gcloud auth login
- Set active gcp project
PROJECT_ID=my_gcp_project_id
gcloud config set project $PROJECT_ID
- Tag docker image and push to gcp repo.
docker tag $APP_NAME eu.gcr.io/$PROJECT_ID/minimal-typescript-express
docker push eu.gcr.io/$PROJECT_ID/minimal-typescript-express
- Deploy to Cloud Run
gcloud run deploy minimal-typescript-express --image eu.gcr.io/$PROJECT_ID/minimal-typescript-express \
--platform managed \
--region europe-north1 \
--allow-unauthenticated
gcloud run services list
Deleting cloud run service
gcloud run services delete minimal-typescript-express