Library can be deployed using many configurations, including Docker, Heroku, and Google App Engine. Note that to deploy to Google App Engine you will need to enable billing on your GCP account.
To deploy to Google App Engine, start by cloning the Library repo locally
git clone https://github.com/nytimes/library.git
Create a new file in the repo you just cloned:
cd library
touch .env
Set your environment variables, including the CUSTOMIZATION_GIT_REPO variable, if using. The link to the customization repository should be the HTTPS cloning URL, not the SSH URL. For example:
APPROVED_DOMAINS=**nytimescom**
DRIVE_ID=**YOUR_DRIVE_ID**
DRIVE_TYPE=**team | folder**
GOOGLE_APPLICATION_JSON='**CONTENTS_OF_AUTH_JSON_HERE**'
GCP_PROJECT_ID=**GCP_PROJECT_FOR_CLOUD_DATASTORE**
GOOGLE_APPLICATION_CREDENTIALS=parse_json
GOOGLE_CLIENT_ID=**OAUTH_CLIENT_ID**
GOOGLE_CLIENT_SECRET=**OAUTH_CLIENT_SECRET**
SESSION_SECRET=**YOUR_PREFERRED_SESSION_SECRET**
CUSTOMIZATION_GIT_REPO=**YOUR_REPO_URL**
PATH_PREFIX=**Optional path prefix for your site. Remove if Library is hosted at the root.**
Note that the values above surrounded by **asterisks** are placeholders and you should replace them with the values specified by the previous setup steps. You can test whether or not your .env file will work by running source .env
in your terminal to confirm that it does not error. If the file is valid, you will not see any output and the environment variables will be available in the current shell. For instance:
Your google application JSON must be on a single line. If you’re still having API authentication issues when trying to boot the app, you may need to wrap it in single quotes.
echo $GCP_PROJECT_ID
would print the value listed in the .env if your file is written correctly.
Before proceeding, you should make sure to enable the Cloud Build API on your GCP project. You can find it under the APIs and Services menu in the GCP console.
After enabling the cloud build api, you should be able to go back to your terminal and run:
gcloud app deploy --project=**your_project_id**
If the deploy succeeds, you’ll see some output ending in:
Setting traffic split for service [default]...done.
Deployed service [default] to [https://**your_project_id**.appspot.com]
You can stream logs from the command line by running:
$ gcloud app logs tail -s default
To view your application in the web browser run:
$ gcloud app browse --project=**your_project_id**
Navigate to your app's url listed above and enjoy your Library app!