Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Painless deployment with Capistrano

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

Painless deployment with Capistrano

Avatar for Nick Kugaevsky

Nick Kugaevsky

December 11, 2014
Tweet

Other Decks in Programming

Transcript

  1. CAPISTRANO Capistrano is a remote server automation and deployment tool

    written in Ruby. It supports the scripting and execution of arbitrary tasks, and includes a set of sane-default deployment workflows.
  2. INSTALL AND INIT $ c d m y _ p

    e r f e c t _ a p p $ g e m i n s t a l l c a p i s t r a n o $ c a p i n s t a l l
  3. CONFIG # c o n f i g / d

    e p l o y . r b s e t : a p p l i c a t i o n , ' s l i d e s ' s e t : r e p o _ u r l , ' g i t @ g i t h u b . c o m : k u g a e v s k y / s l i d e s . g i t ' # c o n f i g / d e p l o y / s t a g i n g . r b r o l e : a p p , % w { n i c k @ k u g a e v s k y . r u } s e t : d e p l o y _ t o , ' / h o m e / k u g a e v s k y / w w w / s l i d e s . k u g a e v s k y . r u ' s e t : u s e r , ' n i c k '
  4. ANATOMY LOCAL m y _ p e r f e

    c t _ a p p ├ ─ ─ C a p f i l e ├ ─ ─ c o n f i g │ ├ ─ ─ d e p l o y │ │ ├ ─ ─ p r o d u c t i o n . r b │ │ ├ ─ ─ s t a g i n g . r b │ │ └ ─ ─ . . . │ └ ─ ─ d e p l o y . r b └ ─ ─ l i b └ ─ ─ c a p i s t r a n o └ ─ ─ t a s k s
  5. ANATOMY HOST m y _ p e r f e

    c t _ a p p ├ ─ ─ c u r r e n t → . . / r e l e a s e s / 2 0 1 4 1 2 0 9 2 2 2 1 0 3 ├ ─ ─ r e l e a s e s │ ├ ─ ─ 2 0 1 4 1 2 0 9 2 2 0 7 0 3 │ ├ ─ ─ 2 0 1 4 1 2 0 9 2 2 2 1 0 3 │ └ ─ ─ . . . ├ ─ ─ r e p o │ ├ ─ ─ b r a n c h e s │ ├ ─ ─ c o n f i g │ ├ ─ ─ d e s c r i p t i o n │ └ ─ ─ . . . └ ─ ─ s h a r e d ├ ─ ─ n o d e _ m o d u l e s ├ ─ ─ u p l o a d s ├ ─ ─ v e n d o r └ ─ ─ . . .
  6. DEPLOY FLOW d e p l o y : s

    t a r t i n g # s t a r t a d e p l o y m e n t , m a k e s u r e e v e r y t h i n g i s r e a d y d e p l o y : s t a r t e d # s t a r t e d h o o k ( f o r c u s t o m t a s k s ) d e p l o y : u p d a t i n g # u p d a t e s e r v e r ( s ) w i t h a n e w r e l e a s e d e p l o y : u p d a t e d # u p d a t e d h o o k d e p l o y : p u b l i s h i n g # p u b l i s h t h e n e w r e l e a s e d e p l o y : p u b l i s h e d # p u b l i s h e d h o o k d e p l o y : f i n i s h i n g # f i n i s h t h e d e p l o y m e n t , c l e a n u p e v e r y t h i n g d e p l o y : f i n i s h e d # f i n i s h e d h o o k
  7. ROLLBACK FLOW d e p l o y : s

    t a r t i n g d e p l o y : s t a r t e d d e p l o y : r e v e r t i n g # r e v e r t s e r v e r ( s ) t o p r e v i o u s r e l e a s e d e p l o y : r e v e r t e d # r e v e r t e d h o o k d e p l o y : p u b l i s h i n g d e p l o y : p u b l i s h e d d e p l o y : f i n i s h i n g _ r o l l b a c k # f i n i s h t h e r o l l b a c k , c l e a n u p e v e r y t h i n g d e p l o y : f i n i s h e d
  8. PLUGINS! # C a p f i l e r

    e q u i r e ' c a p i s t r a n o / r v m ' r e q u i r e ' c a p i s t r a n o / r b e n v ' r e q u i r e ' c a p i s t r a n o / c h r u b y ' r e q u i r e ' c a p i s t r a n o / b u n d l e r ' r e q u i r e ' c a p i s t r a n o / r a i l s / a s s e t s ' r e q u i r e ' c a p i s t r a n o / r a i l s / m i g r a t i o n s '
  9. REAL WORLD EXAMPLE # c o n f i g

    / d e p l o y . r b d e s c ' C r e a t e s y m l i n k s f o r n p m m o d u l e s ' t a s k : n p m d o o n r o l e s ( : a p p ) d o e x e c u t e " l n - n f s # { s h a r e d _ p a t h } / n o d e _ m o d u l e s # { r e l e a s e _ p a t h } / n o d e _ m o d u l e s " e n d e n d d e s c ' I n s t a l l n p m m o d u l e s ' t a s k : n p m d o o n r o l e s ( : a p p ) d o e x e c u t e " c d # { r e l e a s e _ p a t h } & & n p m i n s t a l l " e n d e n d d e s c ' C o m p i l e a s s e t s ' t a s k : c o m p i l e _ a s s e t s d o o n r o l e s ( : a p p ) d o e x e c u t e " c d # { r e l e a s e _ p a t h } & & # { s h a r e d _ p a t h } / n o d e _ m o d u l e s / . b i n / g u l p c o m p i l e : p r o d u c t i o e n d e n d
  10. СПАСИБО ВЫКЛАДКА БЕЗ БОЛИ С CAPISTRANO PAINLESS DEPLOYMENT WITH CAPISTRANO

    для http://slides.kugaevsky.ru/ Николай Кугаевский rannts#3