Commit 1bdc277a93cd98a3b7cf3e47ce2872e32e36de70
1 parent
9ee4e12f
build: add nginx conf
Showing
2 changed files
with
20 additions
and
11 deletions
deploy/api.luban-h5.conf
0 → 100644
| 1 | +server { | ||
| 2 | + listen 80; | ||
| 3 | + server_name api.luban-h5.your-domain.com; | ||
| 4 | + | ||
| 5 | + # 注意事项:nginx 放宽max-size 限制,否则无法上传 psd(体积限制) | ||
| 6 | + client_max_body_size 200M; | ||
| 7 | + | ||
| 8 | + location ~ / { | ||
| 9 | + proxy_set_header Host $host; | ||
| 10 | + proxy_set_header X-Real-IP $remote_addr; | ||
| 11 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| 12 | + proxy_pass http://localhost:1337; | ||
| 13 | + } | ||
| 14 | +} | ||
| 0 | \ No newline at end of file | 15 | \ No newline at end of file |
flightplan.example.js
| @@ -5,6 +5,7 @@ var plan = require('flightplan'); | @@ -5,6 +5,7 @@ var plan = require('flightplan'); | ||
| 5 | local_dist_dir = './'; // root path for luban-h5 | 5 | local_dist_dir = './'; // root path for luban-h5 |
| 6 | remote_project_dir = '~/codebase/luban/luban-h5'; // root path for luban-h5 on server | 6 | remote_project_dir = '~/codebase/luban/luban-h5'; // root path for luban-h5 on server |
| 7 | remote_project_api_dir = '~/codebase/luban/luban-h5/back-end/h5-api'; // api root path for luban-h5 on server | 7 | remote_project_api_dir = '~/codebase/luban/luban-h5/back-end/h5-api'; // api root path for luban-h5 on server |
| 8 | +remote_nginx_conf_path = `${remote_project_dir}/deploy/api.luban-h5.conf` | ||
| 8 | 9 | ||
| 9 | // production server config | 10 | // production server config |
| 10 | plan.target('production', { | 11 | plan.target('production', { |
| @@ -29,14 +30,12 @@ plan.target('production', { | @@ -29,14 +30,12 @@ plan.target('production', { | ||
| 29 | * | 30 | * |
| 30 | */ | 31 | */ |
| 31 | 32 | ||
| 32 | -// init remove server path | ||
| 33 | -// 在第一步的时候,需要打开这一项:初始化服务器,现在还不完整,需要补充 | 33 | +// // init remove server path |
| 34 | +// // 在第一步的时候,需要打开这一项:初始化服务器,现在还不完整,需要补充 | ||
| 34 | // plan.remote(remote => { | 35 | // plan.remote(remote => { |
| 35 | -// // remove.exec(`mkdir -p ${remote_project_dir}`) | ||
| 36 | -// remove.sudo(`yum install nginx -y`) | 36 | +// remote.sudo(`ln -sfv ${remote_nginx_conf_path} /etc/nginx/conf.d`) |
| 37 | + | ||
| 37 | // remote.with(`mkdir -p ${remote_project_dir}`, () => { | 38 | // remote.with(`mkdir -p ${remote_project_dir}`, () => { |
| 38 | -// // remote.log('Install dependencies'); | ||
| 39 | -// // remote.exec('yarn'); | ||
| 40 | // remote.exec('pwd'); | 39 | // remote.exec('pwd'); |
| 41 | // }); | 40 | // }); |
| 42 | // }); | 41 | // }); |
| @@ -44,10 +43,6 @@ plan.target('production', { | @@ -44,10 +43,6 @@ plan.target('production', { | ||
| 44 | 43 | ||
| 45 | // run commands on localhost | 44 | // run commands on localhost |
| 46 | plan.local(local => { | 45 | plan.local(local => { |
| 47 | - // local.log('=> Run build'); | ||
| 48 | - // local.exec('npm run build'); | ||
| 49 | - // local.log('=> Build finish'); | ||
| 50 | - | ||
| 51 | local.log('=> Copy files to remote hosts'); | 46 | local.log('=> Copy files to remote hosts'); |
| 52 | // TODO reference: https://github.com/pstadler/flightplan/issues/142 | 47 | // TODO reference: https://github.com/pstadler/flightplan/issues/142 |
| 53 | local.with(`cd ${local_dist_dir}`, () => { | 48 | local.with(`cd ${local_dist_dir}`, () => { |
| @@ -56,7 +51,6 @@ plan.local(local => { | @@ -56,7 +51,6 @@ plan.local(local => { | ||
| 56 | 51 | ||
| 57 | local.transfer(filesToCopy, remote_project_dir); | 52 | local.transfer(filesToCopy, remote_project_dir); |
| 58 | local.log('=> Copy finish'); | 53 | local.log('=> Copy finish'); |
| 59 | - | ||
| 60 | }); | 54 | }); |
| 61 | }); | 55 | }); |
| 62 | 56 | ||
| @@ -65,6 +59,7 @@ plan.remote(remote => { | @@ -65,6 +59,7 @@ plan.remote(remote => { | ||
| 65 | remote.with(`cd ${remote_project_api_dir}`, () => { | 59 | remote.with(`cd ${remote_project_api_dir}`, () => { |
| 66 | remote.log('Install dependencies'); | 60 | remote.log('Install dependencies'); |
| 67 | remote.exec('yarn'); | 61 | remote.exec('yarn'); |
| 62 | + // !! 第一次同步的时候,需要执行 npm run build 来构建 admin ui | ||
| 68 | remote.exec('pm2 restart server') | 63 | remote.exec('pm2 restart server') |
| 69 | }); | 64 | }); |
| 70 | }); | 65 | }); |