deployment on davidchua https://dchua.com/tags/deployment/ Recent content in deployment on davidchua Hugo -- gohugo.io en-us Mon, 17 Oct 2016 00:00:00 +0000 How to get Kubernetes and Deis onto Azure https://dchua.com/posts/2016-10-17-how-to-get-kubernetes-and-deis-onto-azure/ Mon, 17 Oct 2016 00:00:00 +0000 https://dchua.com/posts/2016-10-17-how-to-get-kubernetes-and-deis-onto-azure/ With Kubernetes Anywhere, setting up a Kubernetes cluster on Microsoft’s Azure isn’t as painful as it used to be. Prerequisite Docker is setup gcc is setup kubectl is setup Azure Subscription ID is prepared Kubernetes Prepare your environment Deploy $ git clone https://github.com/kubernetes/kubernetes-anywhere $ cd kubernetes-anywhere Starting the development process $ make docker-dev $ make deploy You’ll be prompted to fill up the required fields. Please skip the following fields by leaving them blank. Tail Rails Production Logs from Capistrano https://dchua.com/posts/2013-08-21-tail-rails-production-logs-from-capistrano/ Wed, 21 Aug 2013 00:00:00 +0000 https://dchua.com/posts/2013-08-21-tail-rails-production-logs-from-capistrano/ Found this nifty snippet today which would allow you to tail your production logs without leaving your local terminal. # capistrano desc "tail production log files" task :tail_logs, :roles => :app do trap("INT") { puts 'Interupted'; exit 0; } run "tail -f #{shared_path}/log/production.log" do |channel, stream, data| puts # for an extra line break before the host name puts "#{channel[:host]}: #{data}" break if stream == :err end end I put mine in the ‘rails’ namespace, so all I have to do is a nice: Capistrano - Setup log directories and database.yml https://dchua.com/posts/2013-08-17-capistrano-setup-log-directories-and-database-yml/ Sat, 17 Aug 2013 00:00:00 +0000 https://dchua.com/posts/2013-08-17-capistrano-setup-log-directories-and-database-yml/ Updated my deploy.rb gist. Created a new setup_config task that should be run the first time you setup your server. This fixes the missing database.yml file, and setups the missing log directories in your Rails app. Also creates a helper method that checks if a remote_file exists. # config/deploy.rb before 'deploy:db:symlink_db', 'deploy:setup_config' def remote_file_exists?(full_path) 'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip end namespace :deploy do task :setup_config do run " How to Redis from Source to Daemon https://dchua.com/posts/2013-07-23-how-to-redis-from-source-to-daemon/ Tue, 23 Jul 2013 00:00:00 +0000 https://dchua.com/posts/2013-07-23-how-to-redis-from-source-to-daemon/ Make sure you have a server. I’d recommend spinning up an Amazon EC2 instance. Grab the latest redis. At this point of writing, it is: $ wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz $ tar xzf redis-2.6.14.tar.gz $ cd redis-2.6.14 You can do this in any directory, I recommend making a tmp/ directory in your home directory. Run a make and make test! $ make && make test Copy the redis/* content into a accessible folder. Whenever - Easy Cronnable Rake Tasks! With Capistrano! https://dchua.com/posts/2013-07-17-whenever-easy-cronnable-rake-tasks-with-capistrano/ Wed, 17 Jul 2013 00:00:00 +0000 https://dchua.com/posts/2013-07-17-whenever-easy-cronnable-rake-tasks-with-capistrano/ We all have this problem before. Attempting to write a crontab that runs a rake task is almost a painful endeavor. Especially if you’re running a ruby version manager like RVM. Luckily, this crontab DSL gem, “Whenever”, created by Javan, helps make things so much easier. To get started, make sure you have whenever in your Gemfile: #Gemfile gem 'whenever' Then, run wheneverize: /home/myapp$ wheneverize . This will create your config/scheduler. Taps. An easy way to quickly migrate data to remote databases https://dchua.com/posts/2013-07-16-taps-an-easy-way-to-quickly-migrate-data-to-remote-databases/ Tue, 16 Jul 2013 00:00:00 +0000 https://dchua.com/posts/2013-07-16-taps-an-easy-way-to-quickly-migrate-data-to-remote-databases/ If you’ve been using Heroku, you probably have already seen taps at work. $ heroku db:pull $ heroku db:push Looks familar? Well that’s basically runs on taps. An open-source implementation for database migration that Heroku released to the open-source community. 8 May 2014 Update: Theres an updated gem called taps-taps which fixes a couple of bugs migrating from MySQL to SQLite3 after the original gem was abandoned by the developers. Loading 'deploy/assets' in Capistrano, automatically precompiles:assets https://dchua.com/posts/2013-07-14-loading-deployassets-in-capistrano-automatically-precompilesassets/ Sun, 14 Jul 2013 00:00:00 +0000 https://dchua.com/posts/2013-07-14-loading-deployassets-in-capistrano-automatically-precompilesassets/ Something that I’ve just figured out after tinkering for a couple of hours. Hope this will save someone else some trouble. So I’m running my own custom Capistrano script that on fresh deploy setup a symlink of database.yml on the app instance, so that you don’t need to check in your database.yml file. So in my config/deploy.rb, I have something like: after 'deploy:update_code', 'deploy:symlink_db', 'deploy:assets:precompile' . . . . desc " Deploying Node.JS on Nginx with Capistrano/Capper https://dchua.com/posts/2013-05-28-deploying-node-js-on-nginx-with-capistranocapper/ Tue, 28 May 2013 00:00:00 +0000 https://dchua.com/posts/2013-05-28-deploying-node-js-on-nginx-with-capistranocapper/ The other day on a single-day internal hackathon, together with Ernest and the rest of the One Cent Movement guys, we decided to do up an internal check-in mobile webapp where we can see where each of us were at anytime of the day. This is a simple guide to deploy your node.js app onto a production server. Which in my case is an Amazon EC2 m1.small instance. Pre-requsite: NPM is assumed to be the defacto package manager. Ubuntu 12.10 Nginx/Passenger/Rails https://dchua.com/posts/2013-03-23-ubuntu-12-10-nginxpassengerrails/ Sat, 23 Mar 2013 00:00:00 +0000 https://dchua.com/posts/2013-03-23-ubuntu-12-10-nginxpassengerrails/ Created a new AMI image. Click away. It runs: RVM Ruby 1.9.2 Nginx (/opt/nginx) Passenger Its comes with an 8GB Elastic Block Storage (EBS) instance. So if you’re planning to run a ruby/rails webserver, I hope this saves you time! Note Please ensure your Kernel ID is set to aki-fe1354ac Speed up assets:precompile in Capistrano https://dchua.com/posts/2013-03-02-assets-precompile-passenger/ Sat, 02 Mar 2013 00:00:00 +0000 https://dchua.com/posts/2013-03-02-assets-precompile-passenger/ Note to self. In order to speed up assets:precompile on passenger production, add the following to config/deploy.rb: namespace :deploy do namespace :assets do task :precompile, :roles => :web, :except => { :no_release => true } do from = source.next_revision(current_revision) if capture("cd #{latest_release}&& #{source.local.log(from)}vendor/assets/ app/assets/ | wc -l").to_i > 0 run %Q{cd #{latest_release}&& #{rake}RAILS_ENV=#{rails_env}#{asset_env}assets:precompile} else logger.info "Skipping asset pre-compilation because there were no asset changes" end end end end Alt: set :max_asset_age, 2 ## Set asset age in minutes to test modified date against. Some tips to deploying Rubber-powered EC2 Rails Apps https://dchua.com/posts/2012-01-07-some-tips-to-deploying-rubber-powered-ec2-rails-apps/ Sat, 07 Jan 2012 00:00:00 +0000 https://dchua.com/posts/2012-01-07-some-tips-to-deploying-rubber-powered-ec2-rails-apps/ I’ve been playing around with Rubber, the EC2 deployment script for Rails lately and I’ve spent a huge amount of time trying to get it to work. Here are some of my notes: To setup: # Put this into Gemfile gem rubber Vulcanize! (Create the deployment scripts according to your specifications) On Rails 3.x, in your Rails application’s root directory davidc@davidc:~/my/awesome/app> vulcanize <option> # with option being any one of the following minimal_nodb, redis, passenger_nginx, complete_passenger_nginx, cruise, postgresql, resque, apache, sphinx, monit, minimal_passenger_nginx, mysql_cluster, complete_passenger_postgresql, cassandra, mongodb, complete_mongrel_mysql, complete_passenger_nginx_postgresql, base, memcached, minimal_mysql, complete_passenger_mysql, complete_passenger_nginx_mysql, munin, mysql_proxy, complete_passenger, mysql, nginx, jetty, passenger, haproxy, mongrel Edit /config/rubber/rubber.