部署代码

rails代码部署

前端代码部署

mina init
mint setup
mina deploy

config/deploy.rb配置如下:

require 'mina/deploy'
require 'mina/git'

set :domain, 'dream@dev.wikiflyer.cn'
set :deploy_to, '/data/www/pdca_front'
set :repository, 'git@gitlab.wikiflyer.cn:wangjing/pdca_front.git'
set :branch, 'v3'

task :environment do
end

task :setup do
end

desc "Deploys the current version to the server."
task :deploy do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:cleanup'
  end
end

nginx配置

nginx模块开发-upstream模块 nginx的location配置详解 nginx location在配置中的优先级

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}
upstream pdca_v2{
    server unix:///data/www/pdca_v2/shared/tmp/sockets/puma.sock;
}
server {
     listen 80;
     server_name pdca-v2.wikiflyer.cn;
     root /data/www/pdca_v2/current/public;
     location /{
         try_files $uri $uri/index.html $uri.html @pdca_v2;
     }
     location /app/ {
         alias /data/www/pdca_front/current/dist/;
         expires 1y;
         add_header Cache-Control public;
         # Some browsers still send conditional-GET requests if there's a
         add_header Last-Modified "";
         add_header ETag "";
         break;
     }
     location /cable {
         proxy_pass http://pdca_v2/cable;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection $connection_upgrade;
     }
     location @pdca_v2{
       proxy_set_header Host $http_host;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header Client-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_pass http://pdca_v2;
     }
     location ~* ^/assets/ {
       expires 1y;
       add_header Cache-Control public;
       # Some browsers still send conditional-GET requests if there's a
       add_header Last-Modified "";
       add_header ETag "";
       break;
     }
 }
server:nginx的核心模块;
server包含虚拟主机的配置;
可以通过listen指令来指定必须连接到这个server块的所有地址和端口,并且在server_name指令中可以指定所有的域名;

location:nginx中寻找路径的配置,主要用来配置访问的路径;