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.jsonfile (copied from theconfig-default.jsonfile):cp config-default.json config.json- Set
GCLOUD_PROJECTinconfig.jsonto your Google Cloud Platform project ID. - Set
DATA_BACKENDinconfig.jsonto one of"datastore","cloudsql", or"mongodb". - Set
CLOUD_BUCKETinconfig.jsonto the name of your Google Cloud Storage bucket. - Set
OAUTH2_CLIENT_IDinconfig.json. - Set
OAUTH2_CLIENT_SECRETinconfig.json. - Set
TOPIC_NAMEinconfig.json. - Set
SUBSCRIPTION_NAMEinconfig.json.
- Set
-
Install dependencies using NPM or Yarn:
-
Using NPM:
npm install -
Using Yarn:
yarn install
-
-
Configure the backing store:
-
If
DATA_BACKENDis 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_USERinconfig.json, e.g."my-cloudsql-username". -
Set
MYSQL_PASSWORDinconfig.json, e.g."my-cloudsql-password". -
Set
INSTANCE_CONNECTION_NAMEinconfig.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_BACKENDis set to"mongodb":- Set
MONGO_URLinconfig.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