Deploying Rails applications with Moonshine

  • 4,077 views
Uploaded on

Deploy your Rails apps and keep your server configuration in version control with Moonshine!

Deploy your Rails apps and keep your server configuration in version control with Moonshine!

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
4,077
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
11

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 1 Moonshine 190 Proof Deployment Jarin Udom, Robot Mode LLC http://robotmo.de
  • 2. 2 Introduction
  • 3. 3 Deployment Sucks! Install Ubuntu Update packages Configure SSH Configure iptables Build and install Apache, MySQL/Postgres, Ruby Enterprise Edition, RubyGems, Passenger, ImageMagick, PostFix, Cron, logrotate, NTP, Rails, gems, git, etc. etc.… Finally deploy!
  • 4. 4 What Moonshine does Update packages Configure SSH Configure iptables Build and install Apache, MySQL/Postgres, Ruby Enterprise Edition, RubyGems, Passenger, ImageMagick, PostFix, cron, logrotate, NTP, Rails, gems, git, etc. etc.… Deploy! Manage! …and more!
  • 5. 5 What Moonshine is built on Made by Rails Machine Puppet ShadowPuppet (extracted from Moonshine) Capistrano
  • 6. 6 Moonshine Plugins ar_mailer Local and Amazon S3 backups god iptables memcached sphinx ssh Wordpress (?!)
  • 7. 7 Getting Started
  • 8. 8 What you need A server running Ubuntu 8.10 A user on the server who can sudo and access your Git repository A beer (optional)
  • 9. 9 Install Plugins script/plugin install git://github.com/railsmachine/moonshine.git script/plugin install git://github.com/railsmachine/moonshine_ssh.git script/plugin install git://github.com/railsmachine/ moonshine_iptables.git Install any other Moonshine plugins you want script/generate moonshine Generates config/moonshine.yml and app/manifests/
  • 10. 10 Gems Make sure all of your gems are declared in environment.rb rake moonshine:gems Generates gems.yml You need to do this any time you add/remove/change the gems
  • 11. 11 Edit moonshine.yml :ruby: ree :application: ultranetweb :user: rails :time_zone: UTC :deploy_to: /srv/ultranetweb :domain: ultranetweb.com :domain_aliases: - www.ultranetweb.com - assets1.ultranetweb.com # The entries in shared_children are created in #{application}/shared :shared_children: - system - log - pids - config :repository: git@github.com:robotmode/ultranetweb.git
  • 12. 12 Edit moonshine.yml :local_config: - config/database.yml :ssh :port: 9022 :allow_users: - jarin - rails :apt_gems: :paperclip: - imagemagick :passenger: :max_pool_size: 3 :use_global_queue: true :mysql: :innodb_buffer_pool_size: 128M
  • 13. 13 Edit application_manifest.rb Located in app/manifests/ # Installs Rails, Apache, Passenger, the database from database.yml, Postfix, # Cron, logrotate and NTP. recipe :default_stack plugin :ssh recipe :ssh plugin :iptables recipe :iptables
  • 14. 14 Edit application_manifest.rb Located in app/manifests/ def application_packages send_weekly_emails = "/usr/bin/rake -f #{configuration[:deploy_to]}/ current/Rakefile mailer:send_weekly_emails RAILS_ENV=#{ENV['RAILS_ENV']}" cron 'notifications:send_weekly_emails', :command => send_weekly_emails, :user => configuration[:user], :minute => 0, :hour => 3, :weekday => 1 # Only run the following on the 'staging' stage using capistrano-ext. on_stage 'staging' do file '/etc/motd', :ensure => :file, :content => "!!! STAGING SERVER !!!" end end
  • 15. 15 Capify and go! capify . config/deploy.rb: server "ultranetweb.com", :app, :web, :db, :primary => true Add to git git add . && git commit -am "added moonshine" && git push Bootstrap! cap deploy:setup Deploy! cap deploy
  • 16. 16 Now, cap deploy will… Verify your system config on each deploy Run migrations Install gems …and their system dependencies! Pull down submodules Keep your system configuration in version control!
  • 17. 17 But what about other servers? You can have per-server manifests for your app servers, database servers, memcache, etc. set :moonshine_manifest, 'memcached_manifest' By default, Moonshine sets your database auto-increment to 10 to allow for easier database sharding later Check the Moonshine Google Group for more info
  • 18. 18 Resources Source/wiki: http://github.com/railsmachine/moonshine Docs: http://railsmachine.github.com/moonshine/ Mailing list: http://groups.google.com/group/railsmachine- moonshine Slides will be up at http://jarinheit.com in the next couple of days
  • 19. 19 Questions?