Skip to content

Commit f52092e

Browse files
committed
Deploying AWS Docs
1 parent dc91dfd commit f52092e

File tree

1 file changed

+87
-45
lines changed

1 file changed

+87
-45
lines changed

docs/deploying.md

Lines changed: 87 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,92 @@
1-
# Debugging
1+
# Deployment
22

33
Here you find how to deploy your application to a Server.
44

55
## Amazon AWS (EC2)
66

7-
1 - First you need to have a custom domain name bought (can be bought in AWS)
8-
9-
2 - Go to [Amazon EC2](https://console.aws.amazon.com/ec2/) in the left bar under _Network & Security_ click on Keypairs.
10-
2.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!!
11-
12-
2.2 - Click on instances, launch instances, select ubuntu server 16.04 LTS, Select The instance type you desire and launch.
13-
3 - When it's online, select your created instance and, if you don't selected a security group, there's created a new one.
14-
3.1 - Click on this name and you will be in Security Groups List (There's a link in left panel).
15-
3.2 - Go to Inbound tab, click on edit and Add Rule for your Port Http (80), Https (443) or Custom port (default botpress 3000).
16-
Important: For Security reasons, keep online only the port you configured in your botfile.js
17-
18-
4 - Go to Load Balancers (Left Bar) and create a new Load Balancer, selecting Application Load Balancer and click in next.
19-
4.1 - In Basic Configuration, name-it anyway you like and in listeners, add the same inbound ports then you set in step 3.2
20-
4.2 - Select Availability Zones and click next
21-
4.3 - In step 3, select the same Security group then you're using in your EC2 Instance.
22-
4.4 - Step four, name the target anyway you want, select the port and protocol and next
23-
4.5 - Select the machines you want to put under this load balance (Only One Available in this case, but you can put more later) and create.
24-
25-
5 - 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.
26-
OBS: You may need confirm the domain you using. AWS sends an email to address of the domain owner.
27-
5.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.
28-
5.2 - Click on create record set, Set "alias" to yes (blank name and IPV4 Type)
29-
30-
6 - Remember of .pem file of step 2? Copy this to your .ssh folder (On Windows is C:\Users\wacal\.ssh)
31-
6.1 - Connect on your machine by ssh ```ssh ubuntu@YOUR_AMAZON_AWS_PUBLIC_DNS```
32-
Obs: Go to EC2 -> Instances -> Select your instance and See "Public DNS (IPV4)"
33-
Obs2: If you use windows [Git Bash (Distributed with Git for Windows)](https://git-scm.com/downloads) it's an excellent choice.
34-
35-
7 - Now you connected, run this commands
36-
```cd ~```
37-
```curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh```
38-
```sudo bash nodesource_setup.sh```
39-
7.1 - Then install NodeJs and NPM with
40-
```sudo apt-get install nodejs```
41-
7.2 - Next you need to compile some source files
42-
```sudo apt-get install build-essential```
43-
7.3 - You can run ```npm --version``` and ```node --version``` to check if instalation is ok.
44-
45-
8 - [Install pm2 to manage process](https://github.com/Unitech/pm2)
46-
```npm install -g pm2``
47-
48-
9 - Clone your project inside some server folder (i like to put into /var/app/myapp)
49-
9.1 - ```cd /var/app/myapp``` and run ```npm install```
50-
9.2 - Put your app into production! ```pm2 start npm -- start``` that's all folks!
7+
#### 1 - First you need to have a custom domain name bought (can be bought in AWS)
8+
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.
10+
OBS: You may need confirm the domain you using. AWS sends an email to address of the domain owner.
11+
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.
13+
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.
16+
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.
18+
19+
#### 4 - Go to [Amazon EC2](https://console.aws.amazon.com/ec2/) in the left bar under _Network & Security_ click on Keypairs.
20+
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!!
22+
23+
#### 5 - Click on instances, launch instances, select ubuntu server 16.04 LTS, Select The instance type you desire and launch.
24+
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.
26+
27+
5.2 - Click on this name and you will be in Security Groups List (There's a link in left panel).
28+
29+
5.3 - Go to Inbound tab, click on edit and Add Rule for your Port Http (80) and Https (443).
30+
31+
#### 4 - Go to Load Balancers (Left Bar) and create a new Load Balancer, selecting Application Load Balancer and click in next.
32+
33+
4.1 - In Basic Configuration, name-it default (or anyway you like) and in listeners, add listeners to the ports 80 and 443.
34+
35+
4.2 - Select Desired Availability Zones inside your VPC and click next
36+
37+
4.3 - (Step 2) In Certificate Type, choose an existing certificate then we created in step 3. Click Next.
38+
39+
4.4 - (Step 3) Select the same Security group then you're using in your EC2 Instance.
40+
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.´
42+
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)
44+
45+
4.7 - Select the machines you want to put under this load balance (We created just one for this example) and create.
46+
47+
48+
#### 5 - Back [Route 53](https://console.aws.amazon.com/route53) and enter in your hosted zone (domain)
49+
50+
5.2 - Click on create record set, name it bot, type cname and check "alias" to yes
51+
52+
5.3 - In target name, find your load balance.
53+
54+
5.4 - Let policy simple and Evaluate Target Health No. Click Create
55+
56+
#### 6 - Remember of .pem file of step 4? Find his directory and filename and put in YOUR_KEY_DIRECTORY
57+
58+
6.1 - Connect on your machine by ssh ```ssh YOUR_KEY_DIRECTORY ubuntu@YOUR_AMAZON_AWS_PUBLIC_DNS```
59+
60+
Obs: Go to EC2 -> Instances -> Select your instance and See "Public DNS (IPV4)"
61+
62+
Obs2: If you use windows [Git Bash (Distributed with Git for Windows)](https://git-scm.com/downloads) it's an excellent choice.
63+
64+
#### 7 - Now you connected, run this commands
65+
66+
```cd ~```
67+
68+
```curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh```
69+
70+
```sudo bash nodesource_setup.sh```
71+
72+
7.1 - Then install NodeJs and NPM with
73+
74+
```sudo apt-get install nodejs```
75+
76+
7.2 - Next you need to compile some source files
77+
78+
```sudo apt-get install build-essential```
79+
80+
7.3 - You can run ```npm --version``` and ```node --version``` to check if instalation is ok.
81+
82+
#### 8 - [Install pm2 to manage process](https://github.com/Unitech/pm2)
83+
84+
```npm install -g pm2``
85+
86+
#### 9 - [Setup Nginx and pm2](https://doesnotscale.com/deploying-node-js-with-pm2-and-nginx/)
87+
88+
#### 10 - Clone your project inside some server folder (i like to put into /var/app/myapp)
89+
90+
9.1 - Go to your app folder and run ```npm install```
91+
92+
9.2 - Put your app into production! ```pm2 start npm -- start``` that's all folks!

0 commit comments

Comments
 (0)