読者です 読者をやめる 読者になる 読者になる

Fight the Future

何かを始めたら、半分成功したのと同じ

Heroku + Lokkaのセットアップ

ちょっとしたサイトを作りたいから、Heroku + Lokkaにしようと考えた。

インストールメモ。

jyukutyomac:~ jyukutyo$ sudo gem install bundler
Password:
Successfully installed bundler-1.0.12
1 gem installed
Installing ri documentation for bundler-1.0.12...
Installing RDoc documentation for bundler-1.0.12...


jyukutyomac:~ jyukutyo$ cd /Users/jyukutyo/code/


jyukutyomac:code jyukutyo$ git clone git://github.com/komagata/lokka.git
Cloning into lokka...
remote: Counting objects: 2839, done.
remote: Compressing objects: 100% (1548/1548), done.
remote: Total 2839 (delta 1581), reused 2135 (delta 1150)
Receiving objects: 100% (2839/2839), 3.72 MiB | 677 KiB/s, done.
Resolving deltas: 100% (1581/1581), done.
jyukutyomac:code jyukutyo$ cd lokka/


jyukutyomac:lokka jyukutyo$ bundle install --path vendor/bundle --without production test
Fetching source index for http://rubygems.org/
Installing rake (0.8.7) 
Installing abstract (1.0.0) 
Installing activesupport (3.0.0) 
Installing addressable (2.2.5) 
Installing builder (3.0.0) 
Using bundler (1.0.12) 
Installing data_objects (0.10.3) 
Installing extlib (0.9.15) 
Installing dm-core (1.0.2) 
Installing dm-aggregates (1.0.2) 
Installing dm-do-adapter (1.0.2) 
Installing dm-is-searchable (1.0.2) 
Installing dm-is-tree (1.0.2) 
Installing dm-migrations (1.0.2) 
Installing dm-pager (1.1.0) 
Installing do_sqlite3 (0.10.3) with native extensions 
Installing dm-sqlite-adapter (1.0.2) 
Installing dm-tags (1.0.2) 
Installing dm-timestamps (1.0.2) 
Installing fastercsv (1.5.4) 
Installing json_pure (1.5.1) 
Installing stringex (1.1.0) 
Installing uuidtools (2.1.2) 
Installing dm-types (1.0.2) 
Installing dm-validations (1.0.2) 
Installing erubis (2.6.6) 
Installing exceptional (2.0.25) 
Installing haml (3.0.18) 
Installing i18n (0.4.1) 
Installing r18n-core (0.4.9) 
Installing rack (1.2.2) 
Installing rack-flash (0.1.1) 
Installing tilt (1.2.2) 
Installing sinatra (1.2.3) 
Installing sinatra-content-for (0.2) 
Installing sinatra-r18n (0.4.9) 
Installing temple (0.2.0) 
Installing slim (0.9.2) 
Your bundle is complete! It was installed into ./vendor/bundle


jyukutyomac:lokka jyukutyo$ bundle exec rake db:set
(in /Users/jyukutyo/code/lokka)
Upgrading Database...
 ~ (0.001846) PRAGMA table_info("sites")
 ~ (0.000040) SELECT sqlite_version(*)
 ~ (0.003659) CREATE TABLE "sites" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "title" VARCHAR(255), "description" VARCHAR(255), "dashboard" TEXT, "theme" VARCHAR(64), "meta_description" VARCHAR(255), "meta_keywords" VARCHAR(255), "created_at" TIMESTAMP, "updated_at" TIMESTAMP)
 ~ (0.000023) PRAGMA table_info("options")
 ~ (0.002933) CREATE TABLE "options" ("name" VARCHAR(255) NOT NULL, "value" TEXT, "created_at" TIMESTAMP, "updated_at" TIMESTAMP, PRIMARY KEY("name"))
 ~ (0.000021) PRAGMA table_info("users")
 ~ (0.002726) CREATE TABLE "users" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(40), "email" VARCHAR(40), "hashed_password" VARCHAR(50), "salt" VARCHAR(50), "created_at" TIMESTAMP, "updated_at" TIMESTAMP, "permission_level" INTEGER DEFAULT 1)
 ~ (0.033352) CREATE UNIQUE INDEX "unique_users_name" ON "users" ("name")
 ~ (0.003094) CREATE UNIQUE INDEX "unique_users_email" ON "users" ("email")
 ~ (0.000026) PRAGMA table_info("entries")
 ~ (0.003298) CREATE TABLE "entries" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "user_id" INTEGER, "category_id" INTEGER, "slug" VARCHAR(255), "title" VARCHAR(255), "body" TEXT, "type" VARCHAR NOT NULL, "draft" BOOLEAN DEFAULT 'f', "created_at" TIMESTAMP, "updated_at" TIMESTAMP, "frozen_tag_list" TEXT)
 ~ (0.000030) PRAGMA table_info("categories")
 ~ (0.003400) CREATE TABLE "categories" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "slug" VARCHAR(255), "title" VARCHAR(255), "description" TEXT, "type" VARCHAR NOT NULL, "created_at" TIMESTAMP, "updated_at" TIMESTAMP, "parent_id" INTEGER)
 ~ (0.003498) CREATE UNIQUE INDEX "unique_categories_slug" ON "categories" ("slug")
 ~ (0.002580) CREATE UNIQUE INDEX "unique_categories_title" ON "categories" ("title")
 ~ (0.000028) PRAGMA table_info("comments")
 ~ (0.002891) CREATE TABLE "comments" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "entry_id" INTEGER, "status" INTEGER, "name" VARCHAR(50), "homepage" VARCHAR(50), "body" TEXT, "created_at" TIMESTAMP, "updated_at" TIMESTAMP)
 ~ (0.000096) PRAGMA table_info("snippets")
 ~ (0.012297) CREATE TABLE "snippets" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(255), "body" TEXT, "created_at" TIMESTAMP, "updated_at" TIMESTAMP)
 ~ (0.000025) PRAGMA table_info("tags")
 ~ (0.003540) CREATE TABLE "tags" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50) NOT NULL)
 ~ (0.004152) CREATE UNIQUE INDEX "unique_tags_name" ON "tags" ("name")
 ~ (0.000023) PRAGMA table_info("taggings")
 ~ (0.002609) CREATE TABLE "taggings" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "taggable_id" INTEGER NOT NULL, "taggable_type" VARCHAR NOT NULL, "tag_context" VARCHAR(50) NOT NULL, "tag_id" INTEGER NOT NULL)
 ~ (0.005547) CREATE INDEX "index_taggings_tag" ON "taggings" ("tag_id")
Initializing Database...
 ~ (0.014379) INSERT INTO "users" ("id", "name", "hashed_password", "salt", "created_at", "updated_at", "permission_level") VALUES (1, 'test', '6338db2314bba79531444996b780fa7036480733', '2Z4H4DzATC', '2011-01-09T05:39:07+09:00', '2011-01-09T05:39:07+09:00', 1)
 ~ (0.503217) INSERT INTO "sites" ("id", "title", "description", "dashboard", "theme", "created_at", "updated_at") VALUES (1, 'Test Site', 'description...', '<p>Welcome to Lokka!</p><p>To post a new article, choose "<a href="/admin/posts/new">New</a>" under "Posts" on the menu to the left. To change the title of the site, choose "Settings" on the menu to the left. (The words displayed here can be changed anytime through the "<a href="/admin/site/edit">Settings</a>" screen.)</p>', 'jarvi', '2011-01-09T05:39:08+09:00', '2011-01-09T05:39:08+09:00')
 ~ (0.148834) INSERT INTO "entries" ("id", "user_id", "title", "body", "type", "draft", "created_at", "updated_at") VALUES (1, 1, 'Test Post', '<p>Wellcome to Lokka!</p><p><a href="/admin/">Admin login</a> (user / password : test / test)</p>', 'Post', 'f', '2011-01-09T05:39:08+09:00', '2011-01-09T05:39:08+09:00')


jyukutyomac:lokka jyukutyo$ bundle exec ruby lokka.rb
== Sinatra/1.2.3 has taken the stage on 9646 for development with backup from WEBrick
[2011-04-28 23:20:34] INFO  WEBrick 1.3.1
[2011-04-28 23:20:34] INFO  ruby 1.8.7 (2009-06-12) [universal-darwin10.0]
[2011-04-28 23:20:34] INFO  WEBrick::HTTPServer#start: pid=1521 port=9646

http://localhost:9646でTest Siteが出る。


Herokuを使う。

jyukutyomac:lokka jyukutyo$ sudo gem install heroku
Password:
Fetching: term-ansicolor-1.0.5.gem (100%)
Fetching: mime-types-1.16.gem (100%)
Fetching: rest-client-1.6.1.gem (100%)
Fetching: configuration-1.2.0.gem (100%)
Fetching: launchy-0.4.0.gem (100%)
Fetching: heroku-2.0.2.gem (100%)
Successfully installed term-ansicolor-1.0.5
Successfully installed mime-types-1.16
Successfully installed rest-client-1.6.1
Successfully installed configuration-1.2.0
Successfully installed launchy-0.4.0
Successfully installed heroku-2.0.2
6 gems installed
Installing ri documentation for term-ansicolor-1.0.5...
Installing ri documentation for mime-types-1.16...
Installing ri documentation for rest-client-1.6.1...
Installing ri documentation for configuration-1.2.0...
Installing ri documentation for launchy-0.4.0...
Installing ri documentation for heroku-2.0.2...
Installing RDoc documentation for term-ansicolor-1.0.5...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for rest-client-1.6.1...
Installing RDoc documentation for configuration-1.2.0...
Installing RDoc documentation for launchy-0.4.0...
Installing RDoc documentation for heroku-2.0.2...


jyukutyomac:lokka jyukutyo$ heroku create
Enter your Heroku credentials.
Email: 
Password: 
Found existing public key: 
Would you like to associate it with your Heroku account? [Yn] Y
Uploading ssh public key 
Creating blazing-sword-151... done
http://blazing-sword-151.heroku.com/ | git@heroku.com:blazing-sword-151.git
Git remote heroku added


jyukutyomac:lokka jyukutyo$ heroku create xxxxxxxxxx
Creating xxxxxxxxxx... done
http://xxxxxxxxxx.heroku.com/ | git@heroku.com:xxxxxxxxxx.git
Git remote heroku added
jyukutyomac:lokka jyukutyo$ git push heroku master
Counting objects: 2839, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (1117/1117), done.
Writing objects: 100% (2839/2839), 3.74 MiB | 215 KiB/s, done.
Total 2839 (delta 1581), reused 2839 (delta 1581)

-----> Heroku receiving push
-----> Rack app detected
-----> Gemfile detected, running Bundler version 1.0.7
       Unresolved dependencies detected; Installing...
       Using --without development:test
       Fetching source index for http://rubygems.org/
       Installing rake (0.8.7) 
       Installing abstract (1.0.0) 
       Installing activesupport (3.0.0) 
       Installing addressable (2.2.5) 
       Installing builder (3.0.0) 
       Installing data_objects (0.10.3) 
       Installing extlib (0.9.15) 
       Installing dm-core (1.0.2) 
       Installing dm-aggregates (1.0.2) 
       Installing dm-do-adapter (1.0.2) 
       Installing dm-is-searchable (1.0.2) 
       Installing dm-is-tree (1.0.2) 
       Installing dm-migrations (1.0.2) 
       Installing dm-pager (1.1.0) 
       Installing do_postgres (0.10.3) with native extensions 
       Installing dm-postgres-adapter (1.0.0) 
       Installing dm-tags (1.0.2) 
       Installing dm-timestamps (1.0.2) 
       Installing fastercsv (1.5.4) 
       Installing json_pure (1.5.1) 
       Installing stringex (1.1.0) 
       Installing uuidtools (2.1.2) 
       Installing dm-types (1.0.2) 
       Installing dm-validations (1.0.2) 
       Installing erubis (2.6.6) 
       Installing exceptional (2.0.25) 
       Installing haml (3.0.18) 
       Installing i18n (0.4.1) 
       Installing r18n-core (0.4.9) 
       Installing rack (1.2.2) 
       Installing rack-flash (0.1.1) 
       Installing tilt (1.2.2) 
       Installing sinatra (1.2.3) 
       Installing sinatra-content-for (0.2) 
       Installing sinatra-r18n (0.4.9) 
       Installing temple (0.2.0) 
       Installing slim (0.9.2) 
       Using bundler (1.0.7) 
       Your bundle is complete! It was installed into ./.bundle/gems/
       Compiled slug size is 5.9MB
-----> Launching... done
       http://xxxxxxxxxx.heroku.com deployed to Heroku

To git@heroku.com:xxxxxxxxxx.git
 * [new branch]      master -> master
jyukutyomac:lokka jyukutyo$ heroku open

これでHerokuでLokkaが動くよ。