Sample loopback app which can be deployed to Google Cloud Platform (GCP)
git clone https://github.com/pulkitsinghal/loopback-deploy-to-gcp.git
cd loopback-deploy-to-gcp
gcloud auth login
gcloud config set project loopbackers
- replace loopbackers with you own project-id from GCP
gcloud preview app run app.yaml
gcloud preview app deploy app.yaml
- gcloud preview app deploy app.yaml --project will also work. But if you've already set the project in a previous step, there isn't really any need for it.
- View it at: http://loopbackers.appspot.com/explorer/
- Get gcloud from https://cloud.google.com/sdk/#Quick_Start
- On your terminal run
gcloud auth login
- Get the name and version number of the most recent Bitnami Jenkins image.
gcloud compute images list --project bitnami-launchpad | grep jenkins
- Run the following to create the Jenkins VM (password is what's used for the Jenkins admin console, and feel free to pick a higher config VM based on values defined in https://cloud.google.com/compute/docs/machine-types).
gcloud compute \
instances create bitnami-jenkins \
--project double-platform-92304 \
--image-project bitnami-launchpad \
--image bitnami-jenkins-1-610-0-linux-debian-7-x86-64 \
--zone us-central1-a \
--machine-type n1-standard-4 \
--metadata "bitnami-base-password=gN3wu1X9tLv9" \
"bitnami-default-user=user" \
"bitnami-key=jenkins" \
"bitnami-name=Jenkins" \
"bitnami-url=//bitnami.com/stack/jenkins" \
"bitnami-description=Jenkins." \
"startup-script-url=https://dl.google.com/dl/jenkins/p2dsetup/setup-script.sh" \
--scopes "https://www.googleapis.com/auth/userinfo.email" \
"https://www.googleapis.com/auth/devstorage.full_control" \
"https://www.googleapis.com/auth/projecthosting" \
"https://www.googleapis.com/auth/appengine.admin" \
--tags "bitnami-launchpad"
- Locate the VM under Compute Engine > VM instances in the GCP dashboard. Click on the IP address and allow HTTP and HTTPS traffic. Optionally CloudFlare (or similar service to assign a domain name - for now we have jenkins.shoppinpal.com).
- Go to
http://jenkins.shoppinpal.com/jenkins/manage > manage plugins
and pickGit Plugin, GitHub Authn Plugin, GitHub plugin
. One or more of these maybe already installed which is fine. Pick the option to install without restart. - Login to the Jenkins console and choose 'create new job'. Ignore the tooling env settings, doesn't matter since it just seems to be a way to have separate thread executors based on language.
- Under 'Source Code Management' pick the Git Repo option and give the full URL (the one you'd use for cloning), for e.g.
https://github.com/pulkitsinghal/loopback-deploy-to-gcp.git
. Creds are not needed if its a public repo. - Set the Repo Browser to 'Auto'.
- Build Trigger > select 'when a change is pushed to GitHub'.
- Setup github webhook linking to Jenkins along the lines of Step5 here: http://fourword.fourkitchens.com/article/trigger-jenkins-builds-pushing-github ... and here are some subtle differences to keep in mind:
- Instead of
.../github-webhook/
we used.../jenkins/github-webhook/
because that's where jenkins is actually hosted in the bitnami image on GCP. - For the
Content type
dropdown inWebhooks / Manage webhook
on the github project, we selectedapplication/x-www-form-urlencoded
as the value - We clicked the
Disable SSL Verification
button because while the basic authN should still be secure over https, there is no way for github to validate the server certificate of the generic jenkins image on GCP.