Commit a42734b03cc8e9edf2293709dfc66d353dca5471

Authored by ly525
Committed by 小小鲁班
1 parent d5142a3a

docs(deployment): update deployment on ecs

README.en.md
@@ -12,6 +12,22 @@ @@ -12,6 +12,22 @@
12 12
13 <img src="https://s2.ax1x.com/2019/10/11/u7WzUx.gif" style="margin: 10px;" width="60%" /> 13 <img src="https://s2.ax1x.com/2019/10/11/u7WzUx.gif" style="margin: 10px;" width="60%" />
14 14
  15 +### let's go through it real quick.
  16 +> in short
  17 +
  18 +```shell
  19 +docker pull ubuntu
  20 +docker run -it -p 1234:80 -p 1235:1337 -v `pwd`:/app ubuntu
  21 +apt update && apt install -y wget git
  22 +wget -qO- https://raw.githubusercontent.com/ly525/luban-h5/dev/deploy/ubuntu-install.sh | bash
  23 +
  24 +# after the installation finished
  25 +# 1. visit :http://localhost:1235/admin, add your admin account
  26 +# 1.2 config the api permissions, see more here:https://ly525.github.io/luban-h5/en/getting-started/quick-start.html#_2-something-important
  27 +
  28 +# 2. front-end
  29 +# 2.1 visit https://localhost:1235 to get the front-end of luban-h5
  30 +```
15 31
16 ## Links 32 ## Links
17 - Documents 33 - Documents
README.md
@@ -28,6 +28,9 @@ Mobile Page Builder&amp;Generator with Drag&amp;Drop @@ -28,6 +28,9 @@ Mobile Page Builder&amp;Generator with Drag&amp;Drop
28 ```shell 28 ```shell
29 docker pull ubuntu 29 docker pull ubuntu
30 docker run -it -p 1234:80 -p 1235:1337 -v `pwd`:/app ubuntu 30 docker run -it -p 1234:80 -p 1235:1337 -v `pwd`:/app ubuntu
  31 +# 使用清华大学 Ubuntu 软件镜像
  32 +sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
  33 +apt update && apt install -y wget git
31 wget -qO- https://raw.githubusercontent.com/ly525/luban-h5/dev/deploy/ubuntu-install.sh | bash 34 wget -qO- https://raw.githubusercontent.com/ly525/luban-h5/dev/deploy/ubuntu-install.sh | bash
32 35
33 # 安装完成之后 36 # 安装完成之后
deploy/ubuntu-install.sh
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 # @Author: ly525 5 # @Author: ly525
6 # @Date: 2019-11-30 13:24:57 6 # @Date: 2019-11-30 13:24:57
7 # @LastEditors : ly525 7 # @LastEditors : ly525
8 - # @LastEditTime : 2020-01-05 21:39:42 8 + # @LastEditTime : 2020-01-11 12:20:31
9 # @FilePath: /luban-h5/deploy/ubuntu-install.sh 9 # @FilePath: /luban-h5/deploy/ubuntu-install.sh
10 # @Github: https://github.com/ly525/luban-h5 10 # @Github: https://github.com/ly525/luban-h5
11 # @Description: 11 # @Description:
@@ -330,16 +330,19 @@ function install_luban-h5 { @@ -330,16 +330,19 @@ function install_luban-h5 {
330 cd ~/ 330 cd ~/
331 git clone https://github.com/ly525/luban-h5 331 git clone https://github.com/ly525/luban-h5
332 332
333 - # 鲁班前端  
334 - cd luban-h5/front-end/h5 && yarn && yarn build # build editor and preview engine 333 + # # 鲁班前端
  334 + # cd luban-h5/front-end/h5 && yarn && yarn build # build editor and preview engine
335 335
336 - cd - 336 + # cd -
337 337
338 - # 鲁班后端  
339 - cd luban-h5/back-end/h5-api/ && yarn && yarn build # build strapi admin  
340 - pm2 start server.js  
341 - pwd  
342 - success luban-h5 338 + # # 鲁班后端
  339 + # cd luban-h5/back-end/h5-api/ && yarn && yarn build # build strapi admin
  340 + # pm2 start server.js
  341 + # pwd
  342 + # success luban-h5
  343 +
  344 + ./luban-h5.sh init
  345 + ./luban-h5.sh start
343 fi 346 fi
344 } 347 }
345 348
@@ -369,7 +372,7 @@ install_yarn @@ -369,7 +372,7 @@ install_yarn
369 set_npm_mirror 372 set_npm_mirror
370 install_strapi 373 install_strapi
371 install_pm2 374 install_pm2
372 -install_nginx 375 +# install_nginx
373 install_luban-h5 376 install_luban-h5
374 exitBanner 377 exitBanner
375 378
docs/en/getting-started/deployment.md
  1 +
1 # Deployment 2 # Deployment
2 3
3 4
4 ## Aliyun/Tencent Cloud/Digital Ocean 5 ## Aliyun/Tencent Cloud/Digital Ocean
5 6
6 -#### 1. on your server(centos)  
7 -First of all, you need to install some basic software packages, please install them yourself (refer to its official website documents for details)  
8 -  
9 -1. Node  
10 -1. Npm  
11 -1. Nginx  
12 -1. Yarn  
13 -1. Pm2  
14 -  
15 -> The following scripts are just for your information 7 +1. Preinstall
  8 + > First of all, you need to install some basic software on your server(centos), please install them yourself (refer to its official website documents for details)
16 9
  10 + > `node、npm、yarn、pm2`
17 11
  12 +The following scripts are just for your information
18 ```bash 13 ```bash
19 # install yarn 14 # install yarn
20 curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo 15 curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
@@ -29,135 +24,23 @@ npm install pm2 -g @@ -29,135 +24,23 @@ npm install pm2 -g
29 # pm2 stop server 24 # pm2 stop server
30 # pm2 restart server 25 # pm2 restart server
31 # pm2 stop all 26 # pm2 stop all
32 -  
33 ``` 27 ```
34 28
35 -Nginx profile demo  
36 -  
37 -```nginx  
38 -server {  
39 - listen 443;  
40 - server_name your_domain;  
41 -  
42 - client_body_buffer_size 20M;  
43 - client_max_body_size 20M;  
44 - proxy_buffer_size 20M;  
45 - proxy_buffers 32 20M;  
46 - proxy_busy_buffers_size 20M;  
47 -  
48 - # https ssl config  
49 - ssl on;  
50 - ssl_certificate cert/your-https.pem;  
51 - ssl_certificate_key cert/your-https.key;  
52 - ssl_session_timeout 5s;  
53 - ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  
54 - ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  
55 - ssl_prefer_server_ciphers on;  
56 -  
57 - gzip on;  
58 - gzip_min_length 1k;  
59 - gzip_buffers 4 16k;  
60 - gzip_disable "MSIE [1-6]\.";  
61 - gzip_comp_level 3;  
62 - gzip_types image/png application/json text/plain application/x-javascript text/css application/xml text/javascript application/javascript;  
63 -  
64 -  
65 - location ~ ^/(upload|content-manager|users-permissions|works|admin|psd-files|workforms|third-libs|engine-assets) {  
66 - proxy_set_header Host $host;  
67 - proxy_set_header X-Real-IP $remote_addr;  
68 - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
69 - proxy_pass http://localhost:1337;  
70 - }  
71 - location / {  
72 -  
73 - root /home/centos/luban-h5-dist/front-end/;  
74 - #try_files $uri $uri/ /index.html;  
75 - }  
76 -  
77 -}  
78 -```  
79 -  
80 -#### 2. on local machine  
81 -Do the following in the root path of the project: 29 +2. Run the code on the server
82 30
83 ```bash 31 ```bash
84 -yarn add flightplan  
85 -npm run deploy:ecs // Elastic Compute Service  
86 -```  
87 -  
88 -Local deployment script  
89 -  
90 -```javascript  
91 -var os = require('os');  
92 -var plan = require('flightplan');  
93 -  
94 -// configuration  
95 -local_dist_dir = './'; // root path for luban-h5  
96 -remote_project_dir = '~/codebase/luban/luban-h5'; // root path for luban-h5 on server  
97 -remote_project_api_dir = '~/codebase/luban/luban-h5/back-end/h5-api'; // api root path for luban-h5 on server  
98 -  
99 -// production server config  
100 -plan.target('production', {  
101 - host: 'your host ip', // your server ip  
102 - username: 'centos', // your server username  
103 - // privateKey should be absolute path  
104 - privateKey: `${os.homedir}/.ssh/id_rsa` // your privateKey to rsync files  
105 -});  
106 -  
107 -/**  
108 - * 1. setup folders  
109 - * 2. sync files  
110 - * 3. install dependencies  
111 - * 4. (re)start api service  
112 - * 5. soft link nginx conf  
113 - *  
114 - */  
115 -  
116 -// init remove server path  
117 -// plan.remote(remote => {  
118 -// // remove.exec(`mkdir -p ${remote_project_dir}`)  
119 -// remove.sudo(`yum install nginx -y`)  
120 -// remote.with(`mkdir -p ${remote_project_dir}`, () => {  
121 -// // remote.log('Install dependencies');  
122 -// // remote.exec('yarn');  
123 -// remote.exec('pwd');  
124 -// });  
125 -// });  
126 -  
127 -  
128 -// run commands on localhost  
129 -plan.local(local => {  
130 - // local.log('=> Run build');  
131 - // local.exec('npm run build');  
132 - // local.log('=> Build finish');  
133 -  
134 - local.log('=> Copy files to remote hosts');  
135 - // reference: https://github.com/pstadler/flightplan/issues/142  
136 - local.with(`cd ${local_dist_dir}`, () => {  
137 - // const filesToCopy = local.exec('find . -type f', { silent: true })  
138 - const filesToCopy = local.git('ls-files', {silent: true}) // get list of files under version control  
139 -  
140 - local.transfer(filesToCopy, remote_project_dir);  
141 - local.log('=> Copy finish');  
142 -  
143 - });  
144 -});  
145 -  
146 -// run commands on the target's remote hosts  
147 -plan.remote(remote => {  
148 - remote.with(`cd ${remote_project_api_dir}`, () => {  
149 - remote.log('Install dependencies');  
150 - remote.exec('yarn');  
151 - remote.exec('pm2 restart server')  
152 - });  
153 -}); 32 +# just run the following code on the server
  33 +git clone https://github.com/ly525/luban-h5.git
  34 +./luban-h5.sh init # installation dependency, build front-end and back-end
  35 +./luban-h5.sh start # just start the service
  36 +./luban-h5.sh stop # stop the service
154 ``` 37 ```
155 38
156 -#### Some problems that may be encountered in the middle:  
157 -  
158 -1. `Cannot parse privateKey: Unsupported key format` <br />For solutions, please refer: [Cannot parse privateKey: Unsupported key format](https://stackoverflow.com/questions/53400628/cannot-parse-privatekey-unsupported-key-format)  
159 -  
160 - 39 +3. How to access
  40 + 1. configure the firewall security group and add port `1337`.
  41 + 2. visit `http://ServerIP:1337/admin` to get the admin panel for luban-h5
  42 + 3. config the API permissions, see more [here](https://ly525.github.io/luban-h5/en/getting-started/quick-start.html#_2-something-important)
  43 + 4. visit `http://ServerIP:1337` to get the app
161 44
162 ## Docker deployment 45 ## Docker deployment
163 > TODO 46 > TODO
docs/zh/getting-started/deployment.md
@@ -4,16 +4,8 @@ @@ -4,16 +4,8 @@
4 ## 阿里云/腾讯云/Digital Ocean 4 ## 阿里云/腾讯云/Digital Ocean
5 > 以 Centos 为例,Ubuntu等其它发行版,请自行调整 5 > 以 Centos 为例,Ubuntu等其它发行版,请自行调整
6 6
7 -1. 预安装:  
8 -  
9 - - 首先需要安装一些基础的软件包,请自行安装(具体参照其官网文档)  
10 - - node  
11 - - npm  
12 - - nginx  
13 - - yarn  
14 - - pm2  
15 -  
16 - - 1.2 以下脚本仅供参考 7 +1. 首先需要安装一些基础的软件包,请自行安装(具体参照其官网文档)
  8 +> `node、npm、yarn、pm2`
17 9
18 ```bash 10 ```bash
19 # install yarn 11 # install yarn
@@ -31,144 +23,18 @@ @@ -31,144 +23,18 @@
31 # pm2 stop all 23 # pm2 stop all
32 ``` 24 ```
33 25
34 -nginx 配置文件 demo  
35 -  
36 -```nginx  
37 -server {  
38 - listen 443;  
39 - server_name your_domain;  
40 -  
41 - client_body_buffer_size 20M;  
42 - client_max_body_size 20M;  
43 - proxy_buffer_size 20M;  
44 - proxy_buffers 32 20M;  
45 - proxy_busy_buffers_size 20M;  
46 -  
47 - ssl on;  
48 - ssl_certificate cert/your-https.pem;  
49 - ssl_certificate_key cert/your-https.key;  
50 - ssl_session_timeout 5s;  
51 - ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  
52 - ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  
53 - ssl_prefer_server_ciphers on;  
54 -  
55 - gzip on;  
56 - gzip_min_length 1k;  
57 - gzip_buffers 4 16k;  
58 - gzip_disable "MSIE [1-6]\.";  
59 - gzip_comp_level 3;  
60 - gzip_types image/png application/json text/plain application/x-javascript text/css application/xml text/javascript application/javascript;  
61 -  
62 - # TODO 这边的 psd-files、engine-assets、third-libs 开发的时候,可以走 proxy_pass  
63 - # 生产环境的时候,最好走另外的 location,直接让 nginx 访问静态文件  
64 - location ~ ^/(upload|content-manager|users-permissions|works|admin|psd-files|workforms|third-libs|engine-assets) {  
65 - proxy_set_header Host $host;  
66 - proxy_set_header X-Real-IP $remote_addr;  
67 - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
68 - proxy_pass http://localhost:1337;  
69 - }  
70 -  
71 - location / {  
72 - root /home/centos/codebase/luban/luban-h5-dist/front-end/;  
73 - #try_files $uri $uri/ /index.html;  
74 - }  
75 -  
76 -}  
77 -```  
78 -  
79 -#### 本地执行:  
80 -请先提前调研:flightplan  
81 -在项目根目录作如下操作: 26 +2. 在服务器上执行如下代码即可
82 27
83 ```bash 28 ```bash
84 -yarn add flightplan // 部署脚本,官方链接  
85 -npm run deploy:ecs // 云服务器 (Elastic Compute Service, 简称 ECS)  
86 -```  
87 -  
88 -本地部署脚本  
89 -  
90 -```javascript  
91 -var os = require('os');  
92 -var plan = require('flightplan');  
93 -  
94 -// configuration  
95 -local_dist_dir = './'; // root path for luban-h5  
96 -remote_project_dir = '~/codebase/luban/luban-h5'; // root path for luban-h5 on server  
97 -remote_project_api_dir = '~/codebase/luban/luban-h5/back-end/h5-api'; // api root path for luban-h5 on server  
98 -  
99 -// production server config  
100 -plan.target('production', {  
101 - host: 'your host ip', // your server ip  
102 - username: 'centos', // your server username  
103 - // 更新为绝对路径  
104 - privateKey: `${os.homedir}/.ssh/id_rsa` // your privateKey to rsync files  
105 -});  
106 -  
107 -/**  
108 - * 1. setup folders  
109 - * 2. sync files  
110 - * 3. install dependencies  
111 - * 4. (re)start api service  
112 - * 5. soft link nginx conf  
113 - *  
114 - * 1. 创建同步文件件  
115 - * 2. 同步本地在 git 中的文件(你也可以在服务器端git clone)  
116 - * 3. 在 h5-api 目录安装依赖  
117 - * 4. 使用pm2 重启服务  
118 - * 5. 给 nginx 文件做一个软件链接  
119 - *  
120 - */  
121 -  
122 -// init remove server path  
123 -// 在第一步的时候,需要打开这一项:初始化服务器,现在还不完整,需要补充  
124 -// plan.remote(remote => {  
125 -// // remove.exec(`mkdir -p ${remote_project_dir}`)  
126 -// remove.sudo(`yum install nginx -y`)  
127 -// remote.with(`mkdir -p ${remote_project_dir}`, () => {  
128 -// // remote.log('Install dependencies');  
129 -// // remote.exec('yarn');  
130 -// remote.exec('pwd');  
131 -// });  
132 -// });  
133 -  
134 -  
135 -// run commands on localhost  
136 -plan.local(local => {  
137 - // local.log('=> Run build');  
138 - // local.exec('npm run build');  
139 - // local.log('=> Build finish');  
140 -  
141 - local.log('=> Copy files to remote hosts');  
142 - // TODO reference: https://github.com/pstadler/flightplan/issues/142  
143 - local.with(`cd ${local_dist_dir}`, () => {  
144 - // const filesToCopy = local.exec('find . -type f', { silent: true })  
145 - const filesToCopy = local.git('ls-files', {silent: true}) // get list of files under version control  
146 -  
147 - local.transfer(filesToCopy, remote_project_dir);  
148 - local.log('=> Copy finish');  
149 -  
150 - });  
151 -});  
152 -  
153 -// run commands on the target's remote hosts  
154 -plan.remote(remote => {  
155 - remote.with(`cd ${remote_project_api_dir}`, () => {  
156 - remote.log('Install dependencies');  
157 - remote.exec('yarn');  
158 - remote.exec('pm2 restart server')  
159 - });  
160 -});  
161 -  
162 - 29 +git clone https://github.com/ly525/luban-h5.git
  30 +./luban-h5.sh init # 安装依赖,构建前后端
  31 +./luban-h5.sh start # 启动项目即可
  32 +./luban-h5.sh stop # 停止服务
163 ``` 33 ```
164 34
165 -  
166 -  
167 -#### 中间可能遇到的一些问题:  
168 -  
169 -1. `Cannot parse privateKey: Unsupported key format`   
170 -  
171 - 解决方案请参照:[Cannot parse privateKey: Unsupported key format](https://stackoverflow.com/questions/53400628/cannot-parse-privatekey-unsupported-key-format) 35 +3. 如何访问:
  36 + 1. 配置防火墙安全组,添加 1337 端口,通过 `http://服务器IP:1337` 访问即可访问
  37 + 2. `http://服务器IP:1337/admin` 为鲁班的管理后台
172 38
173 39
174 ## Docker 部署 40 ## Docker 部署