| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Setting up Spree

Page history last edited by Jeriel Jan del Prado 13 years, 4 months ago

 

Before I start, I would want to say the reasons why there were difficulties in deploying Spree:

(There's a quick and dirty installation + deployment guide after this, so feel free to skip if you don't want to know care about the details.)


Explanations

There are two guides you were told to look at:

 

Q: I already saw these! Why does my application fail to deploy on Heroku?

A: I can think up of two big reasons why, along with a chain of side-effects.

 

Spree just updated to version 0.30.0. The big change here is that creating a Spree setup has changed drastically. The problem with this is that the change affected about two things in both guides:

  • The spree <your-site-name> command, which you use to create the actual Spree app. (The change made the command obsolete, in favor of a different approach)
  • The spree-heroku extension itself. (The change made it obsolete)

 

The second reason is because of Heroku itself. Heroku seems to have changed certain things over time.

  • You can no longer perform bash / console commands within Heroku, remotely. You have to PAY in order to do so. (You'll need the console commands later on)
  • Heroku's filesystem is read-only. While you can deploy Spree in Heroku, Spree cannot write new data to Heroku, and there's nothing you can do about it.
    • Well, there is a way, and this is where Amazon comes up. You can use an Amazon S3 account as the file storage for Spree, instead of failing to write new data to Heroku.

 

Q: So, how do I solve this?

A: The main answer is to use an older version of Spree. The other answers that follow would have to make-do with a bunch of files and heroku commands to make things work.


 

Setting up Spree

This guide is best done on a Linux operating system. However, everything should work fine enough as long as you have all the prerequisites (Ruby, Rubygems and all necessary gems).

 

Open up a terminal prompt, such as Gnome-terminal.

 

0. Git Installation (if you haven't done it yet)

  1. sudo apt-get install git
  2. Generate RSA key by running this from terminal (just keep the two prompts blank by hitting "enter"): ssh-keygen
  3. Generate DSA key by running this from terminal (just keep the two prompts blank by hitting "enter"): ssh-keygen -t dsa

 

I. Ruby, Rubygems Installation (if you haven't done it yet)

  1. sudo apt-get install ruby
  2. sudo apt-get install rubygems  

 

II. Gem Installation

  1. Install Spree 0.11.0, gem install spree -v0.11.0 <-- THIS IS IMPORTANT.

  2. Try running Spree. Enter spree. You should see Spree's help directions.
    1. if spree is not a recognized command, your PATH might not be configured. If you're using Ubuntu, you have to fix this first with these:
      1. Enter gem env. Take note of what's listed in EXECUTABLE DIRECTORY
      2. Enter $PATH. If the output doesn't have what was listed in the EXECUTABLE DIRECTORY, then the PATH really is the problem.
      3. Fix it by typing PATH=$PATH:(insert your EXECUTABLE DIRECTORY here).
        •  Example: if your Executable Directory is /var/lib/gems/1.8/bin; Enter PATH=$PATH:/var/lib/gems/1.8/bin
      4. Done! Do #2 again. It should work this time.
    2. I did that, it's still not recognized!
      1. Enter gem list
      2. If spree is not listed, or if Spree is not v0.11.0, or you have a lot of spree packages (e.g., spree-core, spree-api), then you have installed the latest version of Spree, which is also the problem.
      3. Try reinstalling using #1. If it's installed already, enter gem uninstall spree 
  3. From this point, we can do Swann's guide......

 

III. Swann's Spree Guide, taken from here

  1. Create the rails app:
              spree your-site-name 
  2. Install extension to make spree work with Heroku:
              cd your-site-name
              script/extension install git://github.com/RSpace/spree-heroku.git
  3. Copy the .gems manifest to the root of your application (this is to work with the Heroku stack we're going to set up later):
              cp vendor/extensions/heroku/.gems ./
  4. Add this gem to the .gems file: aws-s3 -v '0.6.2'
      1. In Ubuntu, enter gedit .gems
      2. If you're in Windows, just open .gems with Notepad
      3. Additional note: Check the version numbers of ruby, rails, and spree. They should match with what you have. Compare it with gem list 
      4. If it looks like this, you should be good to go (this is my .gems file)
      5.  
  5. Install any other needed gems:
                        rake gems:install
  6. Setup your SQLite3 database:
                        rake db:bootstrap
  7. Start your server:
                        script/server
  8. Wait for a few seconds, then check out your site: http://localhost:3000

 

You should finish with no errors.

You should see Spree on your browser once you enter http://localhost:3000

 

Congratulations, you have managed to set up Spree, however, this is only from your computer. Next is the other tricky part: Deploying it to Heroku.

 


 

 

Deploying to Heroku

IV. Setting up your accounts
You will need two things:

  • An Amazon S3 account
  • A verified Heroku account

 

Both accounts WILL ask for your credit / debit card information. Both services are free, but they'll ask you anyway. Don't worry about it.

Your UnionBank card number (NOT the account number) should do the trick, using VISA as your option.

 

Amazon S3

The Amazon S3 account will serve as the file repository for Spree.

 

Once you have an Amazon S3 account, go to the AWS management console, then go to Amazon S3, then create a bucket.

You will need three things from Amazon S3:

  • Your AWS Access Key
  • Your AWS Secret
  • Your AWS S3 Bucket Name

 

You can get your key and secret from your account info. (Go to Account -> Security Credentials) You should have something like this:

 

You can get the bucket name from... well, what you just named the bucket.

 

Verifying Heroku

Verifying Heroku will allow SSL transactions later. You'll need SSL because Spree demands it.

Verify from www.heroku.com/verify, or go to your Account Info.

 

 

V. Deployment!

This is a mix of both Swann's guide and RSpace's spree-heroku instructions.

 

V1. Swann's Guide

  1. Create a new git repository for your app, while inside your Spree directory.
    1. git init
    2. git add .
    3. git commit -m "first commit"
  2. gem install heroku
  3. heroku create your-site-name --stack bamboo-ree-1.8.7
  4. Enable SSL, since Spree uses SSL for administration and payment flow in its standard setup (You'll have to provide account verification for your Heroku account first, but don't worrry this is free as in beer:
              heroku addons:add "Piggyback SSL"
  5. Copy your local database structure to Heroku's Postreges database:
              heroku db:push
  6. Deploy your code: 

               git push heroku master

 

 

V2. RSpace's Guide

 

  1. heroku config:add S3_KEY=[your S3 access key]
  2. heroku config:add S3_SECRET=[your S3 secret]
  3. heroku config:add S3_BUCKET=[your S3 bucket]
    

 

Go to your website now. But if it still fails, rebuild the database again:

  1. rake db:bootstrap
  2. heroku db:push

 

 

VI. Problems!

> I get an error in Heroku!

Enter heroku logs in the terminal so you can get an idea what went wrong. If you can, post it as a comment here.

 

Did your website work? Were you able to finally leave Heroku's stark-white error messages? Do you see Spree? Congratulations! You just deployed Spree on Heroku. Everything should be easy from now on.

 


 

 

Configuring Heroku

You just survived Heroku hell once again. Everything from now on should be easy.

 

The first thing Spree will ask you once you visit your site is an e-mail address and passwords. This will be the administrator account. That's up to you to fill!

 

Now, if you go to your site, you should see near nothingness. This is the default store view.

If you want to add products, categories, manage Spree and everything, just go to http://vertsolspree(yournumber).heroku.com/admin

 

 

 

End

 

 

 

 

 

 

 

 

Comments (1)

Paul Pajo said

at 4:36 pm on Dec 28, 2010

@Jeriel thanks for posting this! Great Job!

You don't have permission to comment on this page.