Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
books
gce
lib
test
views
.gitignore
README.md
app.js
config.js
package.json
worker.js
worker.yaml

README.md

7 - Deploying to Google Compute Engine

Cloud SQL Build Status Datastore Build Status MongoDB Build Status

This folder contains the sample code for the Deploying to Google Compute Engine tutorial. Please refer to the tutorial for instructions on configuring, running, and deploying this sample.

Simple instructions

  1. Install Node.js.

    • Optional: Install Yarn.
  2. Install git.

  3. Create a Google Cloud Platform project.

  4. Install the Google Cloud SDK.

    • After downloading the SDK, initialize it:

        gcloud init
      
  5. Acquire local credentials for authenticating with Google Cloud Platform services:

    gcloud beta auth application-default login
    
  6. Clone the repository:

    git clone https://github.com/GoogleCloudPlatform/nodejs-getting-started.git
    
  7. Change directory:

    cd nodejs-getting-started/5-logging
    
  8. Create a config.json file (copied from the config-default.json file):

    cp config-default.json config.json
    
    • Set DATA_BACKEND in config.json to one of "datastore", "cloudsql", or "mongodb".
    • Set CLOUD_BUCKET in config.json to the name of your Google Cloud Storage bucket.
    • Set OAUTH2_CLIENT_ID in config.json.
    • Set OAUTH2_CLIENT_SECRET in config.json.
    • Set TOPIC_NAME in config.json.
    • Set SUBSCRIPTION_NAME in config.json.
  9. Install dependencies using NPM or Yarn:

    • Using NPM:

        npm install
      
    • Using Yarn:

        yarn install
      
  10. Configure the backing store:

    • If DATA_BACKEND is set to "cloudsql":

      1. Create a Cloud SQL instance, and download and start the Cloud SQL proxy:

        Instructions for doing so: https://cloud.google.com/nodejs/getting-started/using-cloud-sql#creating_a_cloud_sql_instance

      2. Set MYSQL_USER in config.json, e.g. "my-cloudsql-username".

      3. Set MYSQL_PASSWORD in config.json, e.g. "my-cloudsql-password".

      4. Set INSTANCE_CONNECTION_NAME in config.json, e.g. "YOUR_PROJECT_ID:YOUR_REGION:YOUR_INSTANCE_ID".

      5. Run the script to setup the table:

        • Using NPM:

            npm run init-cloudsql
          
        • Using Yarn:

            yarn run init-cloudsql
          
    • If DATA_BACKEND is set to "mongodb":

      1. Set MONGO_URL in config.json, e.g. "mongodb://username:password@123.45.67.890:27017".
  11. Start the app using NPM or Yarn:

    • Using NPM:

        npm start
      
    • Using Yarn:

        yarn start
      
  12. View the app at http://localhost:8080.

  13. Stop the app by pressing Ctrl+C.

  14. Deploy the app:

    See https://cloud.google.com/nodejs/tutorials/bookshelf-on-compute-engine

You can’t perform that action at this time.