diff --git a/.docker/start.sh b/.docker/start.sh new file mode 100644 index 0000000..73da06a --- /dev/null +++ b/.docker/start.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +/etc/init.d/redis-server restart +cd bennett && rake bennett:start + + +#wtf? avoid shell exits after "docker run -d " +cd bennett; tail -f log/* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..caa1937 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,54 @@ +FROM ubuntu:12.04 +MAINTAINER zdkaster "nx2zdk@gmail.com" + +# apt-get deps + +RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list + +RUN apt-get update -y +RUN apt-get install -y -q sudo +RUN apt-get install -y -q git +RUN apt-get install -y -q build-essential +RUN apt-get install -y -q libicu-dev +RUN apt-get install -y -q gcc +RUN apt-get install -y -q make +RUN apt-get install -y -q g++ +RUN apt-get install -y -q libc6-dev +RUN apt-get install -y -q redis-server +RUN apt-get install -y -q curl +RUN apt-get install -y -q libssl-dev +RUN apt-get install -y -q zlib1g-dev +RUN apt-get install -y -q sendmail + +EXPOSE 6379 + +#Install rbenv ruby 1.9.3-p327 and bundler + +RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv +RUN mkdir /usr/local/rbenv/plugins +RUN git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build + +ENV RBENV_ROOT /usr/local/rbenv +ENV PATH /usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + +RUN rbenv install 1.9.3-p327 + +ENV RBENV_VERSION 1.9.3-p327 + +RUN gem install bundler +ENV PATH /usr/local/rbenv/versions/1.9.3-p327/bin:${PATH} + +#Deploy Bennnet + +RUN apt-get install -y -q libsqlite3-dev +RUN apt-get install -y -q nodejs +RUN apt-get install -y -q cron + +RUN git clone https://github.com/zdk/bennett -b deploy-docker +ENV RAILS_ENV production +RUN (cd bennett && bundle install && rake bennett:setup) +EXPOSE 4000 +ADD ./.docker/start.sh ./start.sh +RUN chmod +x ./start.sh +EXPOSE 4000 +CMD ["./start.sh"] diff --git a/README.md b/README.md index d3e8bbb..11bd528 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,23 @@ It is designed to be full-featured yet simple to use, somewhere half-way between ![](http://platypus.belighted.com/bennett/bennett_scr1.png) ![](http://platypus.belighted.com/bennett/bennett_scr2.png) +## Quick Setup using Docker +- Install Docker, check installation details at https://www.docker.io/gettingstarted/#h_installation + +- After docker installed, then pull bennett-docker image + + docker pull zdkaster/bennett-docker + + or + + `git clone git@github.com:belighted/bennett.git -b deploy-docker` + + `docker build -t zdkaster/bennett-docker .` + +- Run a new container using zdkaster/bennett-docker image + + docker run -d -p :4000 zdkaster/bennett-docker + ## Setup #### Redis diff --git a/config/environments/production.rb b/config/environments/production.rb index ea70ac1..13c4369 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -59,7 +59,11 @@ config.active_support.deprecation = :notify config.action_mailer.delivery_method = :sendmail - HOST = "ci.belighted.com" + + config.action_mailer.perform_deliveries = true + config.action_mailer.raise_delivery_errors = true + + HOST = ENV['HOSTNAME'] || "ci.belighted.com" config.action_mailer.default_url_options = { :host => HOST, } diff --git a/config/redis.conf b/config/redis.conf index 7a75663..e26898c 100644 --- a/config/redis.conf +++ b/config/redis.conf @@ -104,7 +104,6 @@ dbfilename redis_dump.rdb # Also the Append Only File will be created inside this directory. # # Note that you must specify a directory here, not a file name. -dir db/ ################################# REPLICATION ################################# @@ -176,7 +175,7 @@ slave-serve-stale-data yes # # maxclients 128 -# Don't use more memory than the specified amount of bytes. +# Don't use more memory than the d amount of bytes. # When the memory limit is reached Redis will try to remove keys with an # EXPIRE set. It will try to start freeing keys that are going to expire # in little time and preserve keys with a longer time to live. @@ -310,8 +309,8 @@ no-appendfsync-on-rewrite no # Specify a precentage of zero in order to disable the automatic AOF # rewrite feature. -auto-aof-rewrite-percentage 100 -auto-aof-rewrite-min-size 64mb +#auto-aof-rewrite-percentage 100 +#auto-aof-rewrite-min-size 64mb ################################## SLOW LOG ################################### @@ -351,7 +350,7 @@ slowlog-max-len 1024 # To enable VM just set 'vm-enabled' to yes, and set the following three # VM parameters accordingly to your needs. -vm-enabled no +#vm-enabled no # vm-enabled yes # This is the path of the Redis swap file. As you can guess, swap files @@ -365,7 +364,7 @@ vm-enabled no # *** WARNING *** if you are using a shared hosting the default of putting # the swap file under /tmp is not secure. Create a dir with access granted # only to Redis user and configure Redis to create the swap file there. -vm-swap-file redis.swap +#vm-swap-file redis.swap # vm-max-memory configures the VM to use at max the specified amount of # RAM. Everything that deos not fit will be swapped on disk *if* possible, that @@ -375,7 +374,7 @@ vm-swap-file redis.swap # default, just specify the max amount of RAM you can in bytes, but it's # better to leave some margin. For instance specify an amount of RAM # that's more or less between 60 and 80% of your free RAM. -vm-max-memory 0 +#vm-max-memory 0 # Redis swap files is split into pages. An object can be saved using multiple # contiguous pages, but pages can't be shared between different objects. @@ -386,7 +385,7 @@ vm-max-memory 0 # If you use a lot of small objects, use a page size of 64 or 32 bytes. # If you use a lot of big objects, use a bigger page size. # If unsure, use the default :) -vm-page-size 32 +#vm-page-size 32 # Number of total memory pages in the swap file. # Given that the page table (a bitmap of free/used pages) is taken in memory, @@ -399,7 +398,7 @@ vm-page-size 32 # # It's better to use the smallest acceptable value for your application, # but the default is large in order to work in most conditions. -vm-pages 134217728 +#vm-pages 134217728 # Max number of VM I/O threads running at the same time. # This threads are used to read/write data from/to swap file, since they @@ -410,7 +409,7 @@ vm-pages 134217728 # # The special value of 0 turn off threaded I/O and enables the blocking # Virtual Memory implementation. -vm-max-threads 4 +#vm-max-threads 4 ############################### ADVANCED CONFIG ############################### @@ -418,27 +417,27 @@ vm-max-threads 4 # have at max a given numer of elements, and the biggest element does not # exceed a given threshold. You can configure this limits with the following # configuration directives. -hash-max-zipmap-entries 512 -hash-max-zipmap-value 64 +#hash-max-zipmap-entries 512 +#hash-max-zipmap-value 64 # Similarly to hashes, small lists are also encoded in a special way in order # to save a lot of space. The special representation is only used when # you are under the following limits: -list-max-ziplist-entries 512 -list-max-ziplist-value 64 +#list-max-ziplist-entries 512 +#list-max-ziplist-value 64 # Sets have a special encoding in just one case: when a set is composed # of just strings that happens to be integers in radix 10 in the range # of 64 bit signed integers. # The following configuration setting sets the limit in the size of the # set in order to use this special memory saving encoding. -set-max-intset-entries 512 +#set-max-intset-entries 512 # Similarly to hashes and lists, sorted sets are also specially encoded in # order to save a lot of space. This encoding is only used when the length and # elements of a sorted set are below the following limits: -zset-max-ziplist-entries 128 -zset-max-ziplist-value 64 +#zset-max-ziplist-entries 128 +#zset-max-ziplist-value 64 # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in # order to help rehashing the main Redis hash table (the one mapping top-level diff --git a/lib/tasks/bennett.rake b/lib/tasks/bennett.rake index 28e0a05..c2dbfc4 100644 --- a/lib/tasks/bennett.rake +++ b/lib/tasks/bennett.rake @@ -4,7 +4,7 @@ namespace :bennett do task :start do Rails.env = ENV['RAILS_ENV'] || 'production' system <<-CMD - redis-server config/redis.conf + redis-server #{Rails.root}/config/redis.conf CMD Rake::Task['workers:restart'].invoke Rake::Task['unicorn:restart'].invoke