8000 Merge pull request #93 from shayanb/master · JavaScriptCodes/botpress@c64c93c · GitHub
[go: up one dir, main page]

Skip to content

Commit c64c93c

Browse files
authored
Merge pull request botpress#93 from shayanb/master
Add Heroku support + deployment documentation
2 parents 2360f3d + 282f3fc commit c64c93c

File tree

2 files changed

+116
-49
lines changed

2 files changed

+116
-49
lines changed

docs/deploying.md

Lines changed: 111 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,159 @@
11
# Deployment
22

3-
Here you find how to deploy your application to a Server.
3+
Here you find how to deploy your application.
4+
5+
6+
## Heroku
7+
8+
1. Set up botpress locally with all the dependent modules installed and configured
9+
* (if using messenger module) make sure you disable Ngork before uploading to heroku
10+
11+
2. You need a [free Heroku account](https://signup.heroku.com/dc) and [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) installed
12+
13+
3. Check package.json to be sure all dependencies are included
14+
1. you can add custom dependencies using `npm install <pkg> --save`
15+
2. Add node version to `packages.json`
16+
```javascript
17+
"engines": {
18+
"node": "7.1.0"
19+
},
20+
```
21+
22+
4. Specifying a start script [Procfile](https://devcenter.heroku.com/articles/procfile) or make sure you have the start script in your packages.json
23+
24+
25+
* So your final package.json should look something like this:
26+
27+
```javascript
28+
{
< 8000 code>29+
"name": "AwsomeBot",
30+
"version": "0.0.1",
31+
"description": "botishness",
32+
"main": "index.js",
33+
"dependencies": {
34+
"botpress": "0.x",
35+
"botpress-analytics": "^1.0.7",
36+
"botpress-hitl": "0.0.1",
37+
"botpress-messenger": "^1.0.16",
38+
"botpress-scheduler": "^1.0.1",
39+
"botpress-subscription": "^1.0.2"
40+
},
41+
"scripts": {
42+
"start": "botpress start",
43+
"test": "echo \"Error: no test specified\" && exit 1"
44+
},
45+
"author": "sbeta",
46+
"license": "AGPL-3.0",
47+
"engines": {
48+
"node": ">6.0.0"
49+
}
50+
}
51+
52+
```
53+
54+
55+
5. Try it locally and see if it works: `heroku local web`
56+
57+
6. Go to Heroku dashboard and make a new app and from there you can follow the instruction to get botpress on heruko `Deploy using Heroku Git`
58+
59+
7. Go to Heroku dashboard -> Settings and in the Config Variables section add a password for your dashboard:
60+
```
61+
BOTPRESS_PASSWORD : <YOUR_ST0nG_PasSwoRd>
62+
```
63+
64+
----------------------------------------------------------------------------------------------
465

566
## Amazon AWS (EC2)
667

7-
#### 1 - First you need to have a custom domain name bought (can be bought in AWS)
68+
1. First you need to have a custom domain name bought (can be bought in AWS)
869

9-
#### 2 - Go to [Route 53](https://console.aws.amazon.com/route53) click in hosted zones, created hosted zone and add your custom domain with type Public Hosted Zone.
70+
2. Go to [Route 53](https://console.aws.amazon.com/route53) click in hosted zones, created hosted zone and add your custom domain with type Public Hosted Zone.
1071
OBS: You may need confirm the domain you using. AWS sends an email to address of the domain owner.
1172

12-
2.1 - Click on your domain name and you will see the NS Register. Go to your domain register provider and configure the Name Servers (NS) with these on Hosted Zone.
73+
1. Click on your domain name and you will see the NS Register. Go to your domain register provider and configure the Name Servers (NS) with these on Hosted Zone.
1374

14-
#### 3 - Go to [AWS Certificate Manager](https://console.aws.amazon.com/acm/) click o request a new Certificate
15-
3.1 - In the field domain name, create a wildcard **.yourdomain.com* and click review and request.
75+
3. Go to [AWS Certificate Manager](https://console.aws.amazon.com/acm/) click o request a new Certificate
76+
1. In the field domain name, create a wildcard **.yourdomain.com** and click review and request.
1677

17-
3.2 - Amazon will send an confirmation email to the email linked to the domain, click on link to confirm this domain belongs to you.
78+
2. Amazon will send an confirmation email to the email linked to the domain, click on link to confirm this domain belongs to you.
1879

19-
#### 4 - Go to [Amazon EC2](https://console.aws.amazon.com/ec2/) in the left bar under _Network & Security_ click on Keypairs.
80+
4. Go to [Amazon EC2](https://console.aws.amazon.com/ec2/) in the left bar under _Network & Security_ click on Keypairs.
2081

21-
4.1 - Click on create, name your keypair and will be downloaded automatically. SAVE IT IN A SECURE PLACE OR YOU WILL NOT BE ABLE TO ACESS THIS MACHINE AGAIN!!
82+
1. Click on create, name your keypair and will be downloaded automatically. SAVE IT IN A SECURE PLACE OR YOU WILL NOT BE ABLE TO ACESS THIS MACHINE AGAIN!!
2283

23-
#### 5 - Click on instances, launch instances, select ubuntu server 16.04 LTS, Select The instance type you desire and launch.
84+
5. Click on instances, launch instances, select ubuntu server 16.04 LTS, Select The instance type you desire and launch.
2485

25-
5.1 - When it's online, select your created instance and, if you don't selected a security group, there's created a new one.
86+
1. When it's online, select your created instance and, if you don't selected a security group, there's created a new one.
2687
27-
5.2 - Click on this name and you will be in Security Groups List (There's a link in left panel).
88+
2. Click on this name and you will be in Security Groups List (There's a link in left panel).
2889

29-
5.3 - Go to Inbound tab, click on edit and Add Rule for your Port Http (80) and Https (443).
90+
3. Go to Inbound tab, click on edit and Add Rule for your Port Http (80) and Https (443).
3091

31-
#### 4 - Go to Load Balancers (Left Bar) and create a new Load Balancer, selecting Application Load Balancer and click in next.
92+
6. Go to Load Balancers (Left Bar) and create a new Load Balancer, selecting Application Load Balancer and click in next.
3293

33-
4.1 - In Basic Configuration, name-it default (or anyway you like) and in listeners, add listeners to the ports 80 and 443.
94+
1. In Basic Configuration, name-it default (or anyway you like) and in listeners, add listeners to the ports 80 and 443.
3495

35-
4.2 - Select Desired Availability Zones inside your VPC and click next
96+
2. Select Desired Availability Zones inside your VPC and click next
3697

37-
4.3 - (Step 2) In Certificate Type, choose an existing certificate then we created in step 3. Click Next.
98+
3. (Step 2) In Certificate Type, choose an existing certificate then we created in step 3. Click Next.
3899

39-
4.4 - (Step 3) Select the same Security group then you're using in your EC2 Instance.
100+
4. (Step 3) Select the same Security group then you're using in your EC2 Instance.
40101
41-
4.5 - (Step 4) Select new Target Group, name it as default (or anyway you like), keep protocol http and port 80 in target group.´
102+
5. (Step 4) Select new Target Group, name it as default (or anyway you like), keep protocol http and port 80 in target group.´
42103
43-
4.6 - (Step 4) In health checks select protocol http and put an path to health status. (The aws will ping this url to check if the server is alive)
104+
6. (Step 4) In health checks select protocol http and put an path to health status. (The AWS will ping this url to check if the server is alive)
44105
45-
4.7 - Select the machines you want to put under this load balance (We created just one for this example) and create.
106+
7. Select the machines you want to put under this load balance (We created just one for this example) and create.
46107
47108
48-
#### 5 - Back [Route 53](https://console.aws.amazon.com/route53) and enter in your hosted zone (domain)
109+
7. Back [Route 53](https://console.aws.amazon.com/route53) and enter in your hosted zone (domain)
49110
50-
5.2 - Click on create record set, name it bot, type cname and check "alias" to yes
111+
1. Click on create record set, name it bot, type cname and check "alias" to yes
51112
52-
5.3 - In target name, find your load balance.
113+
2. In target name, find your load balance.
53114
54-
5.4 - Let policy simple and Evaluate Target Health No. Click Create
115+
3. Let policy simple and Evaluate Target Health No. Click Create
55116
56-
#### 6 - Remember of .pem file of step 4? Find his directory and filename and put in YOUR_KEY_DIRECTORY
117+
7. Remember of .pem file of step 4? Find his directory and filename and put in YOUR_KEY_DIRECTORY
57118
58-
6.1 - Connect on your machine by ssh ```ssh YOUR_KEY_DIRECTORY ubuntu@YOUR_AMAZON_AWS_PUBLIC_DNS```
119+
1. Connect on your machine by ssh `ssh YOUR_KEY_DIRECTORY ubuntu@YOUR_AMAZON_AWS_PUBLIC_DNS`
59120
60-
Obs: Go to EC2 -> Instances -> Select your instance and See "Public DNS (IPV4)"
121+
2. Obs: Go to EC2 -> Instances -> Select your instance and See "Public DNS (IPV4)"
61122
62-
Obs2: If you use windows [Git Bash (Distributed with Git for Windows)](https://git-scm.com/downloads) it's an excellent choice.
123+
3.If you use windows [Git Bash (Distributed with Git for Windows)](https://git-scm.com/downloads) it's an excellent choice.
63124

64-
#### 7 - Now you connected, run this commands
125+
8. Now you connected, run this commands
65126

66-
```cd ~```
127+
```Bash
128+
cd ~
67129
68-
```curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh```
130+
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
69131
70-
```sudo bash nodesource_setup.sh```
132+
sudo bash nodesource_setup.sh
133+
```
71134

72-
7.1 - Then install NodeJs and NPM with
135+
1. Then install NodeJs and NPM with
73136

74-
```sudo apt-get install nodejs```
137+
```Bash
138+
sudo apt-get install nodejs
139+
```
75140

76-
7.2 - Next you need to compile some source files
141+
2. Next you need to compile some source files
77142

78-
```sudo apt-get install build-essential```
143+
```Bash
144+
sudo apt-get install build-essential
145+
```
79146

80-
7.3 - You can run ```npm --version``` and ```node --version``` to check if instalation is ok.
147+
3. You can run `npm --version` and `node --version` to check if installation is ok.
81148

82-
#### 8 - [Install pm2 to manage process](https://github.com/Unitech/pm2)
149+
9. Install [pm2](https://github.com/Unitech/pm2) to manage process
83150

84-
```npm install -g pm2``
151+
`npm install -g pm2`
85152

86-
#### 9 - [Setup Nginx and pm2](https://doesnotscale.com/deploying-node-js-with-pm2-and-nginx/)
153+
10. [Setup Nginx and pm2](https://doesnotscale.com/deploying-node-js-with-pm2-and-nginx/)
87154

88-
#### 10 - Clone your project inside some server folder (i like to put into /var/app/myapp)
155+
11. Clone your project inside some server folder (i like to put into /var/app/myapp)
89156

90-
9.1 - Go to your app folder and run ```npm install```
157+
1. Go to your app folder and run `npm install`
91158

92-
9.2 - Put your app into production! ```pm2 start npm -- start``` that's all folks!
159+
2. Put your app into production! `pm2 start npm -- start` that's all folks!

src/cli/templates/init/botfile.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ module.exports = {
55
* where the content is stored
66
* you can access this property from `bp.dataLocation`
77
*/
8-
dataDir: process.env.BOTPRESS_DATA_DIR || "./data",
8+
dataDir: process.env.BOTPRESS_DATA_DIR || './data',
99

10-
modulesConfigDir: process.env.BOTPRESS_CONFIG_DIR || "./modules_config",
10+
modulesConfigDir: process.env.BOTPRESS_CONFIG_DIR || './modules_config',
1111
disableFileLogs: false,
12-
port: process.env.BOTPRESS_PORT || 3000,
12+
port: process.env.BOTPRESS_PORT || process.env.PORT || 3000,
1313
optOutStats: false,
1414
notification: {
1515
file: 'notifications.json',
@@ -25,8 +25,8 @@ module.exports = {
2525
*/
2626
login: {
2727
enabled: process.env.NODE_ENV === 'production',
28-
tokenExpiry: "6 hours",
29-
password: process.env.BOTPRESS_PASSWORD || "password",
28+
tokenExpiry: '6 hours',
29+
password: process.env.BOTPRESS_PASSWORD || 'password',
3030
maxAttempts: 3,
3131
resetAfter: 5 * 60 * 10000 // 5 minutes
3232
}

0 commit comments

Comments
 (0)
0