|
| 1 | + |
| 2 | +The following are the instructions to deploy the angular-fullstack app to Google Cloud App Engine Standard Environment |
| 3 | + |
| 4 | +# Prequsites |
| 5 | + ## 1. Google Cloud SDK |
| 6 | + Download and install [Google Cloud SDK](https://cloud.google.com/sdk/) |
| 7 | + ## 2. Create GCP Project |
| 8 | + ```bash |
| 9 | + gcloud projects create [PROJECT_ID] |
| 10 | + ``` |
| 11 | + ```[PROJECT_ID]``` ID for the project you want to create. |
| 12 | + |
| 13 | + ## 3. Enable Billing |
| 14 | + You need to enable billing for your project before you begin using App Engine |
| 15 | + ```bash |
| 16 | + gcloud alpha billing projects link my-project \ |
| 17 | + --billing-account 0X0X0X-0X0X0X-0X0X0X |
| 18 | + ``` |
| 19 | + [gcloud alpha billing projects link](https://cloud.google.com/sdk/gcloud/reference/alpha/billing/projects/link) |
| 20 | + |
| 21 | + ## 4. Create a MongoDB database |
| 22 | + Create a MongoDB instance and obtain the uri and credentials. There are multiple options for creating a new MongoDB database. |
| 23 | + - Create a Google Compute Engine virtual machine with [MongoDB pre-installed](https://cloud.google.com/launcher/?q=mongodb). |
| 24 | + - Create a MongoDB instance with [MongoDB Atlas on GCP](https://www.mongodb.com/cloud/atlas/mongodb-google-cloud). |
| 25 | + - Use [mLab](https://mlab.com/google) to create a free MongoDB deployment on Google Cloud Platform. |
| 26 | + |
| 27 | + |
| 28 | +# Deployment Setup |
| 29 | + ## 1. Set Node / NPM versions |
| 30 | + GCloud App Engine supports only the newest version of Node.js 8 |
| 31 | + ```javascript |
| 32 | + "engines": { |
| 33 | + "node": ">=8.0", |
| 34 | + "npm": "^5.1.1" |
| 35 | + }, |
| 36 | + ``` |
| 37 | + |
| 38 | + ## 2. Create Application configuration file (app.yaml) |
| 39 | + A Node.js app in App Engine is configured through a file named app.yaml, that contains runtime, handlers, |
| 40 | + scaling, and other general settings including environment variables. |
| 41 | + |
| 42 | + 2.1 create a 'app.yaml' file with the following contents |
| 43 | + |
| 44 | + ```yaml |
| 45 | + |
| 46 | + env: standard |
| 47 | + |
| 48 | + runtime: nodejs8 |
| 49 | + |
| 50 | + env_variables: |
| 51 | + MONGODB_URI: "mongodb://<dbuser :<dbpassword @<environment_URI/deployment_name" |
| 52 | + |
| 53 | + ``` |
| 54 | + |
| 55 | + 2.2 Add app.yaml to .gitignore |
| 56 | + |
| 57 | +# Deployment Steps |
| 58 | + ## 1. Build the app |
| 59 | + ```bash |
| 60 | + gulp build |
| 61 | + ``` |
| 62 | + ## 2. Copy app.yaml to dist |
| 63 | + ```bash |
| 64 | + cp app.yaml dist |
| 65 | + ``` |
| 66 | + ## 3. Change to build directory |
| 67 | + ```bash |
| 68 | + cd dist |
| 69 | + ``` |
| 70 | + ## 4. Deploy |
| 71 | + ```bash |
| 72 | + gcloud app deploy |
| 73 | + ``` |
0 commit comments