Extends gcloud-function-boilerplate with Selenium.
WARNING The maximum allowable memory for a gcloud function is 2GB. Deploying this example with only 1GB memory crashed. GCloud function also only allow a maximum of 9 minutes for your function to run. So be aware of these constraints before you build something on top of this!
- Signup for Google Cloud
- Create a new project project.
- Install the
gcloud
cli tool.brew cask install google-cloud-sdk
- Login
gcloud auth login
- Find the project id you just created and set it as the current project.
gcloud projects list gcloud config set project selenium-258105
- (optional) If you want to use gcloud services, you'll need to create some credentials.
gcloud iam service-accounts create chet-dev
- Add an owner policy
gcloud projects add-iam-policy-binding selenium-258105 --member "serviceAccount:chet-dev@selenium-258105.iam.gserviceaccount.com" --role "roles/owner"
- Create the credentials file.
gcloud iam service-accounts keys create credentials.json --iam-account chet-dev@selenium-258105.iam.gserviceaccount.com
- Start the development server (you may have to build the first bundle
npm run build
before you do this.)npm start
- Test that its working
curl http://localhost:8080/
-
Build the TypeScript files:
npm run build
-
Edit the package.json deploy script to reference the name of the function you want to deploy. Currently, it's called
selenium
. -
Deploy
npm run deploy
-
The deployment should log an endpoint url that you can test.
curl https://us-central1-selenium-258105.cloudfunctions.net/selenium
NOTE you can modify the memory allocation and timeout of the function in the deploy script. Current defaults are maxed out at
--memory=2048MB --timeout=540s
.