commit
e545bbbf90
@ -1 +1,16 @@
|
|||||||
.git
|
.git
|
||||||
|
.stuff
|
||||||
|
.bundle
|
||||||
|
tmp/*
|
||||||
|
log/*
|
||||||
|
target
|
||||||
|
uploads/*
|
||||||
|
coverage
|
||||||
|
Dockerfile
|
||||||
|
a2png/main.js
|
||||||
|
a2png/page/page.js
|
||||||
|
a2png/target
|
||||||
|
a2png/node_modules
|
||||||
|
a2png/target
|
||||||
|
config/asciinema.yml
|
||||||
|
config/database.yml
|
||||||
|
@ -1,105 +1,132 @@
|
|||||||
FROM ubuntu:14.04
|
FROM ubuntu:16.04
|
||||||
MAINTAINER Bartosz Ptaszynski <foobarto@gmail.com>
|
MAINTAINER Bartosz Ptaszynski <foobarto@gmail.com>
|
||||||
|
MAINTAINER Marcin Kulik <support@asciinema.org>
|
||||||
|
|
||||||
# A quickstart:
|
# A quickstart:
|
||||||
#
|
#
|
||||||
# docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=mypass --name=postgres postgres
|
# docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=mypass --name=postgres postgres
|
||||||
# docker run -d -p 6379:6379 --name=redis redis
|
# 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
|
# docker run --rm -e DATABASE_URL="postgresql://postgres:mypass@postgres/asciinema" asciinema/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
|
# # 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
|
# # 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@postgres/asciinema" asciinema/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
|
# docker run -d -e DATABASE_URL="postgresql://postgres:mypass@postgres/asciinema" -p 3000:80 asciinema/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.
|
# 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
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
EXPOSE 3000
|
ARG NODE_VERSION=node_6.x
|
||||||
|
ARG DISTRO=xenial
|
||||||
|
|
||||||
# get ruby in the house
|
RUN apt-get update && \
|
||||||
RUN mkdir /app && \
|
apt-get install -y wget software-properties-common apt-transport-https && \
|
||||||
|
add-apt-repository ppa:brightbox/ruby-ng && \
|
||||||
|
echo "deb https://deb.nodesource.com/$NODE_VERSION $DISTRO main" >/etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
autoconf \
|
autoconf \
|
||||||
build-essential \
|
build-essential \
|
||||||
curl \
|
|
||||||
git-core \
|
git-core \
|
||||||
libcurl4-openssl-dev \
|
imagemagick \
|
||||||
libffi-dev \
|
libfontconfig1 \
|
||||||
libpq-dev \
|
libpq-dev \
|
||||||
libreadline-dev \
|
|
||||||
libsqlite3-dev \
|
|
||||||
libssl-dev \
|
|
||||||
libtool \
|
libtool \
|
||||||
libxml2-dev \
|
libxml2-dev \
|
||||||
libxslt1-dev \
|
libxslt1-dev \
|
||||||
libyaml-dev \
|
nginx \
|
||||||
|
nodejs \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
postgresql \
|
ruby2.1 \
|
||||||
python-software-properties \
|
ruby2.1-dev \
|
||||||
sendmail \
|
sendmail \
|
||||||
software-properties-common \
|
supervisor \
|
||||||
sqlite3 \
|
ttf-bitstream-vera
|
||||||
zlib1g-dev
|
|
||||||
|
# Packages required for:
|
||||||
ENV PATH /usr/local/rbenv/bin:/usr/local/rbenv/plugins/ruby-build/bin:$PATH
|
# autoconf, libtool and pkg-config for libtsm
|
||||||
|
# libfontconfig1 for PhantomJS
|
||||||
# install ruby
|
# ttf-bitstream-vera for a2png
|
||||||
RUN mkdir /usr/local/rbenv && \
|
# imagemagick (identify) for PNG generator (Ruby)
|
||||||
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 && \
|
# install Bundler
|
||||||
git clone https://github.com/sstephenson/rbenv-gem-rehash.git /usr/local/rbenv/plugins/rbenv-gem-rehash && \
|
|
||||||
rbenv install $RUBY_VERSION && \
|
RUN gem install bundler
|
||||||
rbenv global $RUBY_VERSION && \
|
|
||||||
rbenv rehash
|
# install PhantomJS
|
||||||
|
|
||||||
# get asciinema dependencies
|
ARG PHANTOMJS_VERSION=2.1.1
|
||||||
RUN curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash - && \
|
|
||||||
add-apt-repository ppa:tanguy-patte/phantomjs && \
|
RUN wget --quiet -O /opt/phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOMJS_VERSION-linux-x86_64.tar.bz2 && \
|
||||||
apt-get update && \
|
tar xjf /opt/phantomjs.tar.bz2 -C /opt && \
|
||||||
apt-get install -y phantomjs nodejs && \
|
rm /opt/phantomjs.tar.bz2 && \
|
||||||
rbenv exec gem install bundler
|
ln -sf /opt/phantomjs-$PHANTOMJS_VERSION-linux-x86_64/bin/phantomjs /usr/local/bin
|
||||||
|
|
||||||
# get libtsm
|
# install libtsm
|
||||||
RUN git clone git://people.freedesktop.org/~dvdhrm/libtsm /tmp/libtsm && \
|
|
||||||
|
RUN git clone https://github.com/asciinema/libtsm.git /tmp/libtsm && \
|
||||||
cd /tmp/libtsm && \
|
cd /tmp/libtsm && \
|
||||||
git checkout libtsm-3 && \
|
git checkout asciinema && \
|
||||||
test -f ./configure || NOCONFIGURE=1 ./autogen.sh && \
|
test -f ./configure || NOCONFIGURE=1 ./autogen.sh && \
|
||||||
./configure --prefix=/usr/local && \
|
./configure --prefix=/usr/local && \
|
||||||
make && \
|
make && \
|
||||||
sudo make install && \
|
make install && \
|
||||||
sudo ldconfig
|
ldconfig && \
|
||||||
|
rm -rf /tmp/libtsm
|
||||||
|
|
||||||
|
# install JDK
|
||||||
|
|
||||||
|
RUN wget --quiet -O /opt/jdk-8u111-linux-x64.tar.gz --no-check-certificate --no-cookies --header 'Cookie: oraclelicense=accept-securebackup-cookie' http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz && \
|
||||||
|
tar xzf /opt/jdk-8u111-linux-x64.tar.gz -C /opt && \
|
||||||
|
rm /opt/jdk-8u111-linux-x64.tar.gz && \
|
||||||
|
update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_111/bin/java 1000
|
||||||
|
|
||||||
|
# install leiningen
|
||||||
|
|
||||||
|
RUN wget --quiet -O /usr/local/bin/lein https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein && \
|
||||||
|
chmod a+x /usr/local/bin/lein
|
||||||
|
|
||||||
|
ARG LEIN_ROOT=yes
|
||||||
|
|
||||||
# install asciinema
|
# install asciinema
|
||||||
ADD . /app
|
|
||||||
|
ENV RAILS_ENV "production"
|
||||||
|
|
||||||
|
RUN mkdir -p /app/tmp /app/log
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN rbenv local $RUBY_VERSION && \
|
COPY Gemfile* /app/
|
||||||
cd /app/src && \
|
RUN bundle install --deployment --without development test
|
||||||
eval "$(rbenv init -)" && \
|
|
||||||
make && \
|
COPY a2png/project.clj /app/a2png/
|
||||||
cd /app && \
|
RUN cd a2png && lein deps
|
||||||
rm -f log/* && \
|
|
||||||
bundle install && \
|
COPY a2png /app/a2png
|
||||||
mkdir -p tmp && \
|
RUN cd a2png && lein cljsbuild once main && lein cljsbuild once page
|
||||||
ln -s /app/vendor/assets/javascripts/asciinema-player.js /app/a2png/ && \
|
|
||||||
ln -s /app/vendor/assets/stylesheets/asciinema-player.css /app/a2png/ && \
|
COPY . /app
|
||||||
touch tmp/restart.txt
|
|
||||||
|
ENV DATABASE_URL "postgresql://postgres:mypass@postgres/asciinema"
|
||||||
VOLUME ["/app/config", "/app/log", "/app/uploads"]
|
ENV REDIS_URL "redis://redis:6379"
|
||||||
|
|
||||||
# 172.17.42.1 is the docker0 address
|
RUN cd src && make
|
||||||
ENV DATABASE_URL "postgresql://postgres:mypass@172.17.42.1/asciinema"
|
RUN bundle exec rake assets:precompile
|
||||||
ENV REDIS_URL "redis://172.17.42.1:6379"
|
|
||||||
ENV RAILS_ENV "development"
|
# configure Nginx
|
||||||
# when using Docker Toolbox/Virtualbox this is going to be your address
|
|
||||||
# set to whatever FQDN/address you want asciinema to advertise itself as
|
COPY docker/nginx/asciinema.conf /etc/nginx/sites-available/default
|
||||||
# for ex. asciinema.example.com
|
|
||||||
|
# configure Supervisor
|
||||||
|
|
||||||
|
RUN mkdir -p /var/log/supervisor
|
||||||
|
COPY docker/supervisor/asciinema.conf /etc/supervisor/conf.d/asciinema.conf
|
||||||
|
|
||||||
|
VOLUME ["/app/log", "/app/uploads"]
|
||||||
|
|
||||||
ENV HOST "localhost:3000"
|
ENV HOST "localhost:3000"
|
||||||
|
|
||||||
ENTRYPOINT ["rbenv", "exec"]
|
CMD ["/usr/bin/supervisord"]
|
||||||
CMD ["bundle", "exec", "rails", "server"]
|
|
||||||
# bundle exec rake db:setup
|
# bundle exec rake db:setup
|
||||||
# bundle exec sidekiq OR ruby start_sidekiq.rb (to start sidekiq with sendmail)
|
# bundle exec sidekiq OR ruby start_sidekiq.rb (to start sidekiq with sendmail)
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
ASCIINEMA_HOME = ENV["ASCIINEMA_HOME"] || Dir.pwd
|
||||||
|
UNICORN_WORKERS = (ENV["UNICORN_WORKERS"] || "4").to_i
|
||||||
|
|
||||||
|
# Use at least one worker per core if you're on a dedicated server,
|
||||||
|
# more will usually help for _short_ waits on databases/caches.
|
||||||
|
worker_processes UNICORN_WORKERS
|
||||||
|
|
||||||
|
# Help ensure your application will always spawn in the symlinked
|
||||||
|
# "current" directory that Capistrano sets up.
|
||||||
|
working_directory ASCIINEMA_HOME
|
||||||
|
|
||||||
|
listen 3000, :tcp_nopush => true
|
||||||
|
|
||||||
|
# nuke workers after 60 seconds
|
||||||
|
timeout 60
|
||||||
|
|
||||||
|
# feel free to point this anywhere accessible on the filesystem
|
||||||
|
pid "#{ASCIINEMA_HOME}/tmp/unicorn.pid"
|
||||||
|
|
||||||
|
preload_app true
|
||||||
|
|
||||||
|
# Enable this flag to have unicorn test client connections by writing the
|
||||||
|
# beginning of the HTTP headers before calling the application. This
|
||||||
|
# prevents calling the application for connections that have disconnected
|
||||||
|
# while queued. This is only guaranteed to detect clients on the same
|
||||||
|
# host unicorn runs on, and unlikely to detect disconnects even on a
|
||||||
|
# fast LAN.
|
||||||
|
check_client_connection false
|
||||||
|
|
||||||
|
before_exec do |server|
|
||||||
|
ENV["BUNDLE_GEMFILE"] = "#{ASCIINEMA_HOME}/Gemfile"
|
||||||
|
end
|
||||||
|
|
||||||
|
before_fork do |server, worker|
|
||||||
|
if defined?(ActiveRecord::Base)
|
||||||
|
ActiveRecord::Base.connection.disconnect!
|
||||||
|
Rails.logger.info('Disconnected from ActiveRecord')
|
||||||
|
end
|
||||||
|
|
||||||
|
old_pid = "#{server.config[:pid]}.oldbin"
|
||||||
|
if old_pid != server.pid
|
||||||
|
begin
|
||||||
|
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
|
||||||
|
Process.kill(sig, File.read(old_pid).to_i)
|
||||||
|
rescue Errno::ENOENT, Errno::ESRCH
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
after_fork do |server, worker|
|
||||||
|
if defined?(ActiveRecord::Base)
|
||||||
|
ActiveRecord::Base.establish_connection
|
||||||
|
Rails.logger.info('Connected to ActiveRecord')
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,36 @@
|
|||||||
|
upstream rails-server {
|
||||||
|
server 127.0.0.1:3000 fail_timeout=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /app/public;
|
||||||
|
|
||||||
|
client_max_body_size 16m;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/index.html $uri.html @rails;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/assets/ {
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control public;
|
||||||
|
|
||||||
|
add_header ETag "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
location @rails {
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_pass http://rails-server;
|
||||||
|
proxy_redirect off;
|
||||||
|
error_page 500 502 504 /500.html; # Rails error pages
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
|
||||||
|
[program:nginx]
|
||||||
|
command=/usr/sbin/nginx -g "daemon off;"
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
|
||||||
|
[program:rails]
|
||||||
|
command=bundle exec unicorn -c config/unicorn.rb
|
||||||
|
directory=/app
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stderr_logfile_maxbytes=0
|
Loading…
Reference in New Issue