How to do it...

With the MongoDB server up and running, we'll make a few configurational changes and deploy the application to the App Engine:

  1. Logging into the Cloud Platform Console, create an App Engine application, select the region where the application will be hosted and enable billing. You can follow along with the interactive tutorial provided by Google to host your first Node.js application to the App Engine.
  1. In the development machine, copy the Chapter01/mysite folder to a new folder called Chapter01/mysite-ae from where we'll push the code to the App Engine:
$ cp mysite/ mysite-ae/ -r 
  1. Navigate to the mysite-ae folder. Open the .env file and update the path for MONGO_URI to point to our VM:
MONGO_URI=mongodb://<External IP>:27017/mysite 
  1. Verify that all the packages are installed and launch the application on the development machine, pointing to the database on the Cloud:
$ npm install
$ npm start  
  1. The application's configurations are governed by a file called app.yaml. Create a new file with the following content:
# Basic configurations for the NodeJS application 
runtime: nodejs 
env: flex
  1. Now, we can deploy the application to the App Engine:
$ gcloud app deploy
  1. Once the application is deployed, the URL to access the application is provided. Fire up your favorite browser and navigate to the appspot URL and verify that the KeystoneJS application is running properly:
  .....
5cbd6acfb] to complete...done. Updating service [default]...done. Deployed service [default] to [https://<project-id>.appspot.com]
  1. You can stream logs from the command line by running:
$ gcloud app logs tail -s default
  1. To view your application in the web browser run:
$ gcloud app browse  
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.207.79