Mina: ๋ฒˆ๋“ค๋Ÿฌ์šฉ ์บ์‹œ ์—†์Œ

์— ๋งŒ๋“  2016๋…„ 09์›” 24์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: mina-deploy/mina

์ด ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค(mina 0.3์—์„œ ์—…๊ทธ๋ ˆ์ด๋“œ๋จ).

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'

set :shared_dirs, %w(log public/uploads node_modules)
set :current_path, 'current'
set :term_mode, nil

task :environment do
  invoke :'rbenv:load'
end

task setup: :environment do
  command %[mkdir -p "#{fetch(:shared_path)}/log"]
  command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/log"]

  command %[mkdir -p "#{fetch(:shared_path)}/public/uploads"]
  command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/public/uploads"]
  command %[mkdir -p "#{fetch(:shared_path)}/node_modules"]
  command %[chmod g+rx,u+rwx "#{fetch(:shared_path)}/node_modules"]
end

desc 'Deploys the current version to the server.'
task deploy: :environment do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'npm_install'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    on :launch do
      command "mkdir -p #{fetch(:current_path)}/tmp/"
      command "touch #{fetch(:current_path)}/tmp/restart.txt"
    end
  end
end

task :restart do
  command "touch #{fetch(:current_path)}/tmp/restart.txt"
end

task :logs do
  command 'echo "Contents of the log file are as follows:"'
  command "tail -f #{fetch(:current_path)}/log/#{fetch(:rails_env)}.log"
end

task :npm_install do
  command 'npm install --production'
end

๋ฌธ์ œ๋Š” - bundle install ๊ฐ€ ๋ฐฐํฌ๊ฐ€ ์™„๋ฃŒ๋  ๋•Œ๋งˆ๋‹ค ์ฒ˜์Œ๋ถ€ํ„ฐ ๋ชจ๋“  gem์„ ๋‹ค์šด๋กœ๋“œํ•œ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ฒ„์ „ 0.3์—์„œ ์ž˜ ์ž‘๋™ํ–ˆ์Šต๋‹ˆ๋‹ค.

๋‚ด๊ฐ€ ๋ญ˜ ์ž˜๋ชปํ•˜๊ณ  ์žˆ๋Š”์ง€ ์–ด๋–ค ์ƒ๊ฐ?

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ข‹์•„, ๋ฌด์—‡์ด ๋ฌธ์ œ์ธ์ง€ ์•Œ์•„๋ƒˆ๋‹ค. ๋ฒ„์ „ 1์—์„œ๋Š” ์ „์ฒด ํ…Œ์ด๋ธ”์„ ๋งŒ๋“œ๋Š” ๋Œ€์‹  shared_dirs์— ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋‚ด๊ฐ€ ํ•œ :

set :shared_dirs, fetch(:shared_dirs, []).push('log').push('public/uploads').push('node_modules')

๊ทธ๋ฆฌ๊ณ  ์ง€๊ธˆ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค

๋ชจ๋“  3 ๋Œ“๊ธ€

์ข‹์•„, ๋ฌด์—‡์ด ๋ฌธ์ œ์ธ์ง€ ์•Œ์•„๋ƒˆ๋‹ค. ๋ฒ„์ „ 1์—์„œ๋Š” ์ „์ฒด ํ…Œ์ด๋ธ”์„ ๋งŒ๋“œ๋Š” ๋Œ€์‹  shared_dirs์— ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋‚ด๊ฐ€ ํ•œ :

set :shared_dirs, fetch(:shared_dirs, []).push('log').push('public/uploads').push('node_modules')

๊ทธ๋ฆฌ๊ณ  ์ง€๊ธˆ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค

๊ฐ์‚ฌ ํ•ด์š”! ๋‚˜๋Š” ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋‹ค!

๋‹ซํžŒ ์Šค๋ ˆ๋“œ์— ๊ณ ์ •ํ•˜๋ ค๋Š” ๊ฒƒ์€ ์•„๋‹ˆ์ง€๋งŒ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

shared_dires = %w{log public/uploads node_modules}
set :shared_dirs, fetch(:shared_dirs, []).push(*shared_dirs)
์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰