Introduction
In this tutorial, you'll deploy a sample Node.js application to Google AppBy the end, you'll have learned how to:
- Configure Deployments
Learn how to edit a YAML file to edit a deployment’s configuration - Deploy apps with Google Cloud Shell
Deploy with Cloud Shell, a web-based command line tool
Using Google Cloud Shell
Cloud Shell is a built-in command line tool for the console. We're going to use Cloud Shell to deploy our app.- Open Google Cloud Shell
- Clone the sample codeUse Cloud Shell to clone and navigate to the "Hello World" code. The sample code is cloned from your project repository to the Cloud Shell.
In Cloud Shell enter:
Clone a sample repository:
TUTORIALDIR=src/crawler-20180523/nodejs_mvms_quickstart-2018-05-23-14-42
git clone https://github.com/GoogleCloudPlatform/nodejs-getting-started.git $TUTORIALDIR
cd $TUTORIALDIR/1-hello-world
Configuring your deployment
You are now in the main directory for the sample code. We'll look at the files that configure your application.The
app.js file contains the JavaScript code to start a server and respond to requests.The following code responds to requests from web clients by displaying the
Hello World message, via a server that runs on port 8080.Google App Engine uses YAML files to specify a deployment's configuration.
app.yaml files contain information about your application, like the runtime environment, URL handlers, and more.Testing your app
- Test your app on Cloud ShellCloud Shell lets you test your app before deploying to make sure it's running as intended, just like debugging on your local machine.
To test your app enter:
export PORT=8080 npm start - Preview your app with "Web preview"Your app is now running on Cloud Shell. You can access the app by using "Web preview" to connect to port 8080.
- Terminating the preview instanceTerminate the instance of the application by pressing Ctrl+C in the Cloud Shell.
Last steps
Ensuring Compute Engine is initializedCompute Engine needs a few moments to initialize. The tutorial will continue automatically once it's ready.Deploying with Cloud ShellYou can use Cloud Shell to deploy your app. To deploy your app enter:
gcloud app deploy --project crawler-20180523Visit your appCongratulations! Your app has been deployed. The default URL of your app is crawler-20180523.appspot.com Click the URL to visit it.
- You can check in on your app by monitoring its status on the App Engine dashboard.
Open the menu on the left side of the console.
Then, select the App Engine section.
Congratulations
You have successfully deployed an App Engine application! Here are some next steps:
Use MongoDB
Deploy MongoDB on Compute Engine or use a managed, MongoDB service.Learn to use Cloud Storage
Cloud Storage is a powerful and simple object storage service. -
Install npm packages
We will install the npm packages on Cloud Shell in order to test run the Node.js app.
To install npm packages, enter:
To install npm packages, enter:
npm install
No comments:
Post a Comment