From f0f20733ead452eb4bdc623ad6c0d8b2b3a974ac Mon Sep 17 00:00:00 2001 From: foobarto Date: Tue, 27 Oct 2015 11:39:35 +0000 Subject: [PATCH 1/2] Adding Dockerfile and start_sidekiq.rb needed to create Docker Image with asciinema --- .dockerignore | 1 + Dockerfile | 103 +++++++++++++++++++++++++++++++++++++++++++++++ start_sidekiq.rb | 2 + 3 files changed, 106 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 start_sidekiq.rb diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c6721b4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,103 @@ +FROM ubuntu:14.04 +MAINTAINER Bartosz Ptaszynski + +# A quickstart: +# +# docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=mypass --name=postgres postgres +# docker run -d -p 6379:6379 --name=redis redis +# docker run --rm -e DATABASE_URL="postgresql://postgres:mypass@172.17.42.1/asciinema" foobarto/asciinema.org bundle exec rake db:setup +# # starting sidekiq using the provided start_sidekiq.rb file will also start sendmail service if you don't want to use SMTP +# # otherwise start sidekiq by starting: bundle exec sidekiq +# docker run -d -e DATABASE_URL="postgresql://postgres:mypass@172.17.42.1/asciinema" foobarto/asciinema.org ruby start_sidekiq.rb +# docker run -d -e DATABASE_URL="postgresql://postgres:mypass@172.17.42.1/asciinema" -p 3000:3000 foobarto/asciinema.org +# +# You can override the address/port that is sent in email with login token by passing HOST="host:port" environment variable when starting the web server. +# +# Assuming you are running Docker Toolbox and VirtualBox: go to http://192.168.99.100:3000/ and enjoy. + +ENV RUBY_VERSION 2.1.7 +EXPOSE 3000 + +# get ruby in the house +RUN mkdir /app && \ + apt-get update && \ + apt-get install -y \ + autoconf \ + build-essential \ + curl \ + git-core \ + libcurl4-openssl-dev \ + libffi-dev \ + libpq-dev \ + libreadline-dev \ + libsqlite3-dev \ + libssl-dev \ + libtool \ + libxml2-dev \ + libxslt1-dev \ + libyaml-dev \ + pkg-config \ + postgresql \ + python-software-properties \ + sendmail \ + software-properties-common \ + sqlite3 \ + zlib1g-dev + +ENV PATH /usr/local/rbenv/bin:/usr/local/rbenv/plugins/ruby-build/bin:$PATH + +# install ruby +RUN mkdir /usr/local/rbenv && \ + git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv && \ + git clone git://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build && \ + git clone https://github.com/sstephenson/rbenv-gem-rehash.git /usr/local/rbenv/plugins/rbenv-gem-rehash && \ + rbenv install $RUBY_VERSION && \ + rbenv global $RUBY_VERSION && \ + rbenv rehash + +# get asciinema dependencies +RUN curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash - && \ + add-apt-repository ppa:tanguy-patte/phantomjs && \ + apt-get update && \ + apt-get install -y phantomjs nodejs && \ + rbenv exec gem install bundler + +# get libtsm +RUN git clone git://people.freedesktop.org/~dvdhrm/libtsm /tmp/libtsm && \ + cd /tmp/libtsm && \ + git checkout libtsm-3 && \ + test -f ./configure || NOCONFIGURE=1 ./autogen.sh && \ + ./configure --prefix=/usr/local && \ + make && \ + sudo make install && \ + sudo ldconfig + +# install asciinema +ADD . /app +WORKDIR /app + +RUN rbenv local $RUBY_VERSION && \ + cd /app/src && \ + eval "$(rbenv init -)" && \ + make && \ + cd /app && \ + rm -f log/* && \ + bundle install && \ + mkdir -p tmp && \ + touch tmp/restart.txt + +VOLUME ["/app/config", "/app/log"] + +# 172.17.42.1 is the docker0 address +ENV DATABASE_URL "postgresql://postgres:mypass@172.17.42.1/asciinema" +ENV REDIS_URL "redis://172.17.42.1:6379" +ENV RAILS_ENV "development" +# when using Docker Toolbox/Virtualbox this is going to be your address +# set to whatever FQDN/address you want asciinema to advertise itself as +# for ex. asciinema.example.com +ENV HOST "192.168.99.100:3000" + +ENTRYPOINT ["rbenv", "exec"] +CMD ["bundle", "exec", "rails", "server"] +# bundle exec rake db:setup +# budnle exec sidekiq OR ruby start_sidekiq.rb (to start sidekiq with sendmail) diff --git a/start_sidekiq.rb b/start_sidekiq.rb new file mode 100644 index 0000000..d6efc1d --- /dev/null +++ b/start_sidekiq.rb @@ -0,0 +1,2 @@ +system "service sendmail start" +exec "bundle exec sidekiq" From 0092afed5ffda9031d5a56d56d473e4c1bb486cc Mon Sep 17 00:00:00 2001 From: foobarto Date: Wed, 28 Oct 2015 20:38:07 +0000 Subject: [PATCH 2/2] Adding Docker howto to README --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 86f80c8..c4f0479 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,24 @@ This is the source code of asciinema.org website. If you're looking for asciinema's terminal recorder go here: [asciinema/asciinema](https://github.com/asciinema/asciinema) -## Setup instructions +## Using Docker + +```bash +$ docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=mypass --name=postgres postgres +$ docker run -d -p 6379:6379 --name=redis redis +$ docker run --rm -e DATABASE_URL="postgresql://postgres:mypass@172.17.42.1/asciinema" foobarto/asciinema.org bundle exec rake db:setup +# starting sidekiq using the provided start_sidekiq.rb file will also start sendmail service if you don't want to use SMTP +# otherwise start sidekiq by starting: bundle exec sidekiq +$ docker run -d -e DATABASE_URL="postgresql://postgres:mypass@172.17.42.1/asciinema" foobarto/asciinema.org ruby start_sidekiq.rb +$ docker run -d -e DATABASE_URL="postgresql://postgres:mypass@172.17.42.1/asciinema" -p 3000:3000 foobarto/asciinema.org +``` + +You can override the address/port that is sent in email with login token by passing HOST="host:port" environment variable when starting the web server. + +Assuming you are running Docker Toolbox and VirtualBox: go to http://192.168.99.100:3000/ and enjoy. + + +## Manual Setup instructions Below you'll find setup instructions in case you want to contribute, play with it on your local machine, or setup your own instance for private use or for