Setup Express.js with CI/CD to Google Cloud Run

Serverless servers on Google Cloud Run

thoughtstile
6 min readFeb 15, 2021

Created on: 2021–02–15 11:09:48.

Below is a multistage script with associated files. You can check the contents of each file by following the gist link or by scrolling down below.

After the files below are configured, you can then connect your Github repository to Google Cloud Build to setup auto deployment to a Google Cloud Run Endpoint.

Step 1: Setup

# setup directories
mkdir server &&
mkdir ./server/src &&
cd server &&
# create package.json
curl https://gist.githubusercontent.com/thoughtstile/6d00166e3ae5c92b15d3924da0ab92bf/raw/67cfbdc5303a6f7a1a74a39d5ea2703dcaeee093/package.json -o package.json
# install dependencies
npm install express &&
npm install cors &&
npm install dotenv &&
npm install nodemon --save-dev &&
# create .env
curl https://gist.githubusercontent.com/thoughtstile/26a993e1f4eee25d0ee034977c09196e/raw/9a4ff1a22ab1b8492925bff2975bed2fd29d9b05/.env -o .env
# create index.js
curl https://gist.githubusercontent.com/thoughtstile/5832de7fe5c7024e368c37101dcd11cb/raw/16b28bf6b22075758612bd3e2848a63fcdea8a7a/index.js -o index.js
# create app.js
curl https://gist.githubusercontent.com/thoughtstile/2f77d60edba2739cbe5bde6989e6411f/raw/6a016f5f32d7ae6408a06f74c10e95017156ed97/app.js -o ./src/app.js
# create .gitignore .dockerignore .gcloudignore
curl…

--

--