Skip to content
This repository has been archived by the owner on Sep 4, 2018. It is now read-only.

Latest commit

 

History

History
93 lines (53 loc) · 3.42 KB

deploying_your_application.textile

File metadata and controls

93 lines (53 loc) · 3.42 KB

Deploying Your Application

This article will walk you through configuring and deploying your Spree application to an environment configured with the Deployment Service.

endprologue.

INFO: This guide presumes you are running a Spree version of 0.60.x or later, and that your servers have be built using the Spree Deployment Service

Spree Deployment Dependencies

In order to deploy your application to the standard Deployment Service configuration you will need to add the following to your Gemfile:

group :production do
gem ‘unicorn’
gem ‘mysql2’
gem ‘foreman’
gem ‘therubyracer’ #only required for 0.70.x or later
end

group :development do
gem ‘capistrano’
end

Once you saved the Gemfile, run bundle install and commit and push your changes to your remote git repository.

NOTE: Please note it’s important to ensure you’ve committed your Gemfile.lock file also.

Configuring Capistrano

Capistrano is the easiest way to deploy your application to your hosting environment, however you can use any system you prefer.

The Deployment Service will automatically generate a custom recipe for your environment, specific for your Spree version and including your server(s) and git repository details.

To add the basic Capistrano files to your application run the following command:

capify .

This will create the config/deploy.rb file that will contain the details about your server(s), application repository, etc. You can download your Capistrano deploy.rb for each of your configured environments from deployment edit page.

NOTE: The recipe is only available to environment that have chosen “My own custom Spree application”, and not the automatic demo store deployment.

Once you’ve downloaded the automatically generated recipe, replace the contents of your applications config/deploy.rb with it.

Configuring authentication for the spree user

The Deployment Service does not automatically set any authentication settings on your servers so you will need to this before continuing, there are two options available:

1. Manually set the spree user’s password by running the following command (when logged in as root):

passwd spree

2. Avoid password prompt altogether by adding your SSH public key to spree user’s authorized_keys file, which can be found here:

/home/spree/.ssh/authorized_keys

Deploying for the first time

Once you’ve completed all the changes above you’re ready to deploy your application.

Check everything is configured correctly:

cap deploy:check

Do a cold deploy, which checks out the application and migrates the database:

cap deploy:cold

If everything worked correctly you should now have your application deployed and database migrated.

INFO: You might want to restore a database dump to configure your data / users / etc.

Troubleshooting

If you’re having trouble deploying or starting your application for the first time here’s a couple of things to try:

  • Review the following log files for indications of the problem:
    1. /data/spree/current/log/unicorn.stderr.log
    2. /data/spree/current/log/production.log
    3. /var/log/nginx/error.log
    4. /var/log/spree/web-1.log
  • When deploying from private repositories it vital that you have ssh-agent running and your keys added, normally done by executing the following before running `cap`:
ssh-agent ssh-add