Kunstmaan / kStrano

kStrano (KumaStrano) is a Capistrano deployment “recipe” for Kunstmaan specific applications to make our job of deploying a lot easier. It integrates with Airbrake, Jenkins and Campfire.
MIT License
13 stars 0 forks source link

Introducing kStrano

Capistrano is an open source tool for running scripts on multiple servers. It’s primary use is for easily deploying applications. kStrano (KumaStrano) is a deployment “recipe” to work with Kunstmaan specific applications to make your job a lot easier.

Prerequisites

Installing kStrano

Before you install make sure you have no older versions of kStrano or Capifony:

gem uninstall kstrano

You can install kStrano using rubyGems:

gem install kstrano
gem cleanup railsless-deply, capifony, capistrano

Or you can download the source and install it manually:

gem build kstrano.gemspec
gem install kstrano-<version>.gem

Configuring your project

cd to/your/project/path
kumafy .

You can also do a force install, which will update all the files:

cd to/your/project/path
kumafy . --force

Available kStrano commands

PHP recipe

The PHP recipe is based on Capifony, and it adds a few things to make it work with our hosting platform at Kunstmaan.

by default the configuration files are made for Symfony version > 2.1, and they use composer. To make it work with a version without composer change

set :use_composer, true
set :update_vendors, false

to

set :use_composer, false
set :vendors_mode, "install"
set :update_vendors, true

in your deploy.rb

Minimal setup

From now on you should be able to run cap:deploy to deploy the project...

Configuration

kStrano specific configuration options

set :force_schema, false     # when true, schema:update will be run (see gem deploy:schema:update)
set :force_migrations, false # when true, migrations will be run (see gem deploy:migrations)

set :bundler_install, true   # when true, bundler will run an install
set :npm_install, true       # when true, npm install will be run after composer install
set :bower_install, true     # when true, bower install will be run after npm install
set :grunt_build, true      # when true, grunt build will be run after bower install
set :gulp_build, false        # when true, gulp build will be run after bower install

These options are on by default, you can overwrite these in your deploy.rb or by running your cap deploy with -s (ex. cap deploy -s force_schema=true)

The following defaults of Capifony are set in kStrano:

set :copy_vendors, true                 # when true, vendors will be copied from a previous release

set :dump_assetic_assets, true          # when true, use the assetic bundle
set :interactive_mode, false            # when false, it will never ask for confirmations (migrations task for instance)
set :clear_controllers, true            # when true, removes the app_*.php files from web/

set (:symfony_env_prod) {"#{env}"}      # the symfony environment variable is set to what's configured in env

set :uploaded_files_path, 'web/uploads' # the path where your files are uploaded

For further configuration options see Capifony.

Custom commands for PHP next to the one capifony makes available:

Placing the site in Maintenance mode

To place the site in maintenance mode, we first need to edit the htaccess file to redirect users to the maintenance page. Place the following snippet in your htaccess file.

ErrorDocument 503 /maintenance.html
RewriteBase /
RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png|js)$
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteCond %{REMOTE_ADDR} !^#Place the allowed ip addresses here (e.g. 127\.0\.0\.1)
RewriteRule ^.*$ - [R=503,L]

This will present the maintenance page to the user if the maintenance.html file is present and the user's IP is not allowed. To place the site in maintenance mode, issue the next command. This command will create a maintenance.html file in your data/releases/*/web directory

cap deploy:web:disable

In order to place the site out of maintenance mode, issue the next command. This command will remove the created maintenance.html file that was created by the previous command.

cap deploy:web:enable

Play recipe

The play recipe is a very simple recipe which is based on railsless-deploy and adds tasks to package the app, start and stop the server.

If you want newrelic support, make sure you put the jar in newrelic/newrelic.jar.

Available commands

Drupal recipe

Magento recipe

Customizing the maintenance.html

The standard maintenance.html page just states that the site is in maintenance and will be back shortly. In order to have a custom maintenance page, you need to set the maintenance_template_path in your deploy.rb.

set :maintenance_template_path, "location of your custom template"

Now you will see your own custom maintenance page. Note that the deploy:web:disable command copies the content from the template to the maintenance.html file. So you can not use relative paths in your custom template if you want to show images, custom css etc.

Changelog

Analytics