title: How to deploy node.js app on Google App Engine so it loads when user goes to app URL?
body: <p>I'm new to Google App Engine, and have a node.js application that I'm deploying from a GitHub repo. Currently I seem to have to manually enter a number of steps to preview the app, and when I attempt to deploy it with 'gcloud app deploy', the server only throws a 500 error. What I'd like to have happen is have 'gcloud app deploy' actually work. Presumably that means that whether or not I'm logged into Google Cloud Services, going to lucidnodes-dev.appspot.com actually runs the app. </p>
  
  <p>After two days of playing around with dockerfiles, I'm crying uncle. I need help.</p>
  
  <p>The manual steps I'm running are, from inside the Google Cloud Shell:</p>
  
  <pre><code>cd LucidNodes // Enter the directory where the app files live
  node index.js
  </code></pre>
  
  <p>This returns: </p>
  
  <pre><code>LucidNodes listening on port 3000
  </code></pre>
  
  <p>As is expected, and I can see the app running when I run Web Preview on port 3000.</p>
  
  <p>Here is my server code:</p>
  
  <p>server.js file:</p>
  
  <pre><code>const express = require('express');
  const path = require('path');
  const url = require('url');
  
  var init = function( app, prt ){
  
      app.listen( prt, () =&gt; console.log('LucidNodes listening on port ' , prt ));
  };
  
  exports.init = init;
  </code></pre>
  
  <p>and index.js file:</p>
  
  <pre><code>const server = require('./server');
  const fs = require('fs');
  const express = require('express');
  const path = require('path');
  const serveStatic = require('serve-static');
  const serveIndex = require('serve-index');
  const staticPaths = require('./defineStaticPaths');
  const htmlMethods = require('./js/htmlMethods');  // import custom methods for handling HTML
  const app = express();
  const routes = require('./routes');
  
  staticPaths.defineStaticPaths( app );
  app.use( routes );
  
  server.init( app, 8080 );
  </code></pre>
  
  <p>Note that I've changed the port on the local and GitHub instances of the app to 8080. I'm not sure if changing the port number would solve the 500 error problem when deploying and running the app, but I also couldn't get the app instance on GAE to update from the GitHub repo, hence the app is still running on port 3000 on GAE, and hence also the digression to dockerfiles, which so far has been yet another learning curve mess, but one thing at a time I suppose. </p>
  
  <p>So... what I'm trying to do is get the app to actually deploy and run when I call up the lucidnodes-dev.appspot.com. How to do that?</p>
  
  <p>Thanks for the help.</p>