From d7771f1a60c15aacd060281c8e9160bd74203e39 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Thu, 16 Jun 2016 10:41:49 +0200 Subject: [PATCH] Deployment documentation improved --- README.rdoc | 70 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/README.rdoc b/README.rdoc index 3c30bd4..63a0261 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,6 +1,6 @@ == Installing debshots -=== Prepare PostgreSQL database server and user +=== Prepare PostgreSQL database server and user (ident-based authentication) apt install postgresql @@ -8,7 +8,7 @@ su - postgres createuser -d debshots -createdb -O debshots debshots +createdb -O debshots -E UTF8 -T template0 debshots === Create an application user @@ -53,14 +53,16 @@ bundle install --deployment scp screenshots.debian.net:debshots-screenshots.tar . -mv live/screenshots/approved public/screenshots - -rm -r live +tar -C public/ -xvf debshots-screenshots.tar scp screenshots.debian.net:debshots.sql . psql debshots < debshots.sql +Switch to production environment: + +export RAILS_ENV=production + Migrate database: bundle exec rake db:migrate RAILS_ENV=production @@ -71,6 +73,64 @@ Convert screenshots to new format (paperclip): bundle exec rake debshots:screenshots_to_paperclip RAILS_ENV=production +Remove old screenshots directory structure: + +rm -r public/live + +Render the assets: + +bundle exec rake assets:precompile RAILS_ENV=production + +Test the application: + +bundle exec rails s -b 0.0.0.0 -e production + +http://...:3000/ + +Create a user for moderation: + +bundle exec rails c -e production + +user = User.create(realname: 'Christoph Haas', password: 'foobartest', email: 'email@christoph-haas.de') +user.save! + +Tidy up the screenshot data: + +bundle exec rake debshots:remove_broken_screenshots + +bundle exec rake debshots:remove_duplicate_images + +Import new package information: + +bundle exec rake debshots:list_deb_repos + +bundle exec rake debshots:update_from_deb_repos + +bundle exec debshots:update_longdescription_from_deb_repos + +=== Install passenger to run the application behind nginx + +https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/jessie/install_passenger.html + +Example nginx vhost config: + +server { + listen 85.25.83.22:80 default_server; + passenger_enabled on; + passenger_ruby /home/debshots/.rbenv/versions/2.3.1/bin/ruby; + root /home/debshots/debshots/public; + server_name _; +} + +=== Enable nginx caching + +mkdir /var/cache/nginx + +chown www-data.www-data /var/cache/nginx + +nginx config… + +proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off; == Supported URL paths (aka routes)