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.
-
Install Node.js.
- Optional: Install Yarn.
-
Install git.
-
Create a Google Cloud Platform project.
-
Install the Google Cloud SDK.
-
After downloading the SDK, initialize it:
gcloud init
-
-
Acquire local credentials for authenticating with Google Cloud Platform services:
gcloud beta auth application-default login
-
Clone the repository:
git clone https://github.com/GoogleCloudPlatform/nodejs-getting-started.git
-
Change directory:
cd nodejs-getting-started/5-logging
-
Create a
config.json
file (copied from theconfig-default.json
file):cp config-default.json config.json
- Set
GCLOUD_PROJECT
inconfig.json
to your Google Cloud Platform project ID. - Set
DATA_BACKEND
inconfig.json
to one of"datastore"
,"cloudsql"
, or"mongodb"
. - Set
CLOUD_BUCKET
inconfig.json
to the name of your Google Cloud Storage bucket. - Set
OAUTH2_CLIENT_ID
inconfig.json
. - Set
OAUTH2_CLIENT_SECRET
inconfig.json
. - Set
TOPIC_NAME
inconfig.json
. - Set
SUBSCRIPTION_NAME
inconfig.json
.
- Set
-
Install dependencies using NPM or Yarn:
-
Using NPM:
npm install
-
Using Yarn:
yarn install
-
-
Configure the backing store:
-
If
DATA_BACKEND
is set to"cloudsql"
:-
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
-
Set
MYSQL_USER
inconfig.json
, e.g."my-cloudsql-username"
. -
Set
MYSQL_PASSWORD
inconfig.json
, e.g."my-cloudsql-password"
. -
Set
INSTANCE_CONNECTION_NAME
inconfig.json
, e.g."YOUR_PROJECT_ID:YOUR_REGION:YOUR_INSTANCE_ID"
. -
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"
:- Set
MONGO_URL
inconfig.json
, e.g."mongodb://username:[email protected]:27017"
.
- Set
-
-
Start the app using NPM or Yarn:
-
Using NPM:
npm start
-
Using Yarn:
yarn start
-
-
View the app at http://localhost:8080.
-
Stop the app by pressing
Ctrl+C
. -
Deploy the app:
See https://cloud.google.com/nodejs/tutorials/bookshelf-on-compute-engine