Skip to content
This repository was archived by the owner on Oct 7, 2019. It is now read-only.

Latest commit

 

History

History
37 lines (30 loc) · 1.35 KB

File metadata and controls

37 lines (30 loc) · 1.35 KB

3. Create your Node.js application

Estimated time: 53 min remaining

The first step is to write the application that we want to deploy to Google Container Engine. Here is a simple Node.js server:

$ nano server.js
var http = require('http');
var handleRequest = function(request, response) {
  response.writeHead(200);
  response.end("Hello World!");
}
var www = http.createServer(handleRequest);
www.listen(8080);

Note: We recommend using the nano editor but vi and emacs are also available in Cloud Shell.

From Cloud Shell simply exit the editor and save the server.js file. Since CloudShell has the node executable installed we can now run this simple command:

$ node server.js

Then use the built-in Web preview feature of CloudShell to open a new browser tab and proxy a request to the instance you just started on port 8080.

web-preview hello-node-preview

Now, more importantly, let’s package this application in a Docker container.

Before we continue, simply stop the running node server by pressing Ctrl-C in CloudShell.