Documentation

Deploying to Google App Engine

Requirements

Deploying Project Mulla to Google App Engine is fast and easy but there are a few requirements you’ll need to make sure have done to carry on with the deployment.

  1. You have a free Google App Engine account
  2. You have Node.js and npm installed locally.
  3. You have installed the Google Cloud SDK

Add deployment configurations in app.yaml

In the Configurations step, I stated only add the block of code below in your app.yaml config file if you plan to deploy the application to Google App Engine.

# Your specific app environment variables
...

runtime: nodejs
vm: true

skip_files:
  - ^(.*/)?.*/node_modules/.*$

Your final app.yaml file should look something similar to this:

env_variables:
  PAYBILL_NUMBER: '898998'
  PASSKEY: 'a8eac82d7ac1461ba0348b0cb24d3f8140d3afb9be864e56a10d7e8026eaed66'
  MERCHANT_ENDPOINT: 'http://merchant-endpoint.com/mpesa/payment/complete'

runtime: nodejs
vm: true

skip_files:
  - ^(.*/)?.*/node_modules/.*$

Testing locally

Google App Engine deploys and runs your application inside a docker container environment. It is expected to perform as similar as running your application in a unix system. You may 1st ensure everything is okay by running the tests.

# ensure everything is works as expected
$ npm test
# serve up the application one more time
$ npm start

> project-mulla@0.1.1 start ../project-mulla
> node index.js

Your secret session key is: 5f06b1f1-1bff-470d-8198-9ca2f18919c5
Express server listening on 8080, in development mode

Deploy to Google App Engine

Once you have ensured all the tests have passed, your app.yaml file has the required configurations variables and the app is running smoothly locally, deploy to App Engine using the following command:

$ gcloud preview app deploy

Yes! It’s that easy.