Skip to content

Commit

Permalink
updated node article
Browse files Browse the repository at this point in the history
  • Loading branch information
toanms committed May 1, 2020
1 parent 7f65ba6 commit 1968cc8
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions _posts/2020-04-30-run-production-build-on-app-service-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,37 @@ toc_sticky: true
date: 2020-04-30 00:00:00
---

## Overview

When you create production build for your React, Angular, other Node framework the files will either be placed in a `build` or `dist` directory depending on the framework. App Service on Linux uses *Oryx* to detect, build, and start your application. For more information about how this is done, please go to the [Oryx](https://github.com/microsoft/Oryx/blob/master/doc/runtimes/nodejs.md) GitHub page for more info. In order to serve the built content, you can perform either of the following.

## PM2 Serve

1. In the Azure Portal, go to *Configuration*.
1. Select *General* and locate the *Startup Command* box.
1. If all of the items in the `build` directory are in wwwroot, change the path to /home/site/wwwroot.
1. If all of the items in the `build` directory are in `wwwroot`, change the path to `/home/site/wwwroot`.
```bash
pm2 serve /home/site/wwwroot/build --no-daemon
```
1. If the content is under `dist`, make sure to use the following.
```bash
pm2 serve /home/site/wwwroot/dist --no-daemon
```

```bash
pm2 serve /home/site/wwwroot/build --no-daemon
```
1. Press Save.

## Process File

1. Create a process.json, process.yml, etc. In this example, I'm using a process.json file with the following content and add it to the wwwroot directory.
1. Create a process.json or process.yml and place it in `/home/site/wwwroot`.
1. In this example, I'm using a process.json file and my files are under the `build` directory. Make sure to change this to `dist` if your framework is outputing to the `dist` directory.
```bash
{
"script": "serve",
"env": {
"PM2_SERVE_PATH": './build'
}
"args": '--no-daemon'
}
```
```bash
{
"script": "serve",
"env": {
"PM2_SERVE_PATH": './build'
}
"args": '--no-daemon'
}
```
1. In the Azure Portal, go to *Configuration*.
1. Select *General* and locate the *Startup Command* box and enter `process.json`.
1. Press Save.

0 comments on commit 1968cc8

Please sign in to comment.