Now, we can use new JFrog CLI image to build the NPM application Docker image and push it to Artifactory’s Docker repository using Cloud Build Trigger.
Return to your Google Cloud Shell terminal and change directory to gcp-gke-workshop/workshop-app.
Use Google Cloud Build, trigger and the JFrog CLI to build the NPM Docker image. The cloud build trigger uses cloudbuild.yaml. If you look inside this file, you will find it performs following steps:
jfrog config add
configure the JFrog CLI to access our JFrog Platform instance.jfrog npm-install
use JFrog CLI to perform npm install to collect and validate NPM dependencies.jfrog npm-publish
publish the npm all to npm repo in artifactory.jfrog build-publish
use publish the build info.docker build
build docker image of the NPM application.docker push
push the newly created image to Artifactory’s Docker repository.create release
create release in Cloud Deploy which deploys the app from artifactory in GKE.The JFrog CLI is used to collect build information during this process and publish it to Artifactory.
gcloud container clusters get-credentials gcpworkshop --project=$PROJECT_ID --zone=$ZONE
kubectl get nodes
kubectl create secret docker-registry regcred --docker-server=$JFROG_SERVER_NAME --docker-username=$JFROG_USER --docker-password=$JFROG_API_KEY
You have to create this secret in other 2 clusters also: testgcpworkshop and staginggcpworkshop.
Now edit the cloudbuild.yaml in your fork to update versionName for access token secret which we have saved from 4.24 step and commit to trigger cloud build.
If above cloud build passes all steps then it should result in a successful build of docker image which should be pushed to Artifactory.
Also the cloud build should create a release in Cloud Deploy pipeline and Deploy the app to test.
gcloud container clusters get-credentials testgcpworkshop --project=$PROJECT_ID --zone=$ZONE
kubectl get pods
You should see you npm-app pod.
kubectl get services
This will provide the EXTERNAL-IP.
In your browser, go to https://<EXTERNAL-IP> to view your deployed web application.
Click through the self-signed certificate warning. You should see the following web application.