2017-04-12 13:58:26 +00:00
FROM ubuntu:16.04
2015-10-27 11:39:35 +00:00
MAINTAINER Bartosz Ptaszynski <foobarto@gmail.com>
2017-04-12 13:58:26 +00:00
MAINTAINER Marcin Kulik <support@asciinema.org>
2015-10-27 11:39:35 +00:00
# A quickstart:
#
2017-04-14 22:01:31 +00:00
# docker run -d -p 5432:5432 -e POSTGRES_USER=asciinema -e POSTGRES_PASSWORD=sekrit --name=postgres postgres
2015-10-27 11:39:35 +00:00
# docker run -d -p 6379:6379 --name=redis redis
2017-04-14 22:01:31 +00:00
# docker run --rm -e DATABASE_URL="postgresql://asciinema:sekrit@postgres/asciinema" asciinema/asciinema.org bundle exec rake db:setup
# docker run -d -e DATABASE_URL="postgresql://asciinema:sekrit@postgres/asciinema" asciinema/asciinema.org bundle exec sidekiq
# docker run -d -e DATABASE_URL="postgresql://asciinema:sekrit@postgres/asciinema" -p 3000:80 asciinema/asciinema.org
2015-10-27 11:39:35 +00:00
#
# 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.
2017-04-12 13:58:26 +00:00
ARG DEBIAN_FRONTEND = noninteractive
ARG NODE_VERSION = node_6.x
ARG DISTRO = xenial
RUN apt-get update && \
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 - && \
2015-10-27 11:39:35 +00:00
apt-get update && \
apt-get install -y \
autoconf \
build-essential \
git-core \
2017-04-13 18:10:19 +00:00
imagemagick \
2017-04-12 13:58:26 +00:00
libfontconfig1 \
2015-10-27 11:39:35 +00:00
libpq-dev \
libtool \
libxml2-dev \
libxslt1-dev \
2017-04-13 11:03:51 +00:00
nginx \
2017-04-12 13:58:26 +00:00
nodejs \
2015-10-27 11:39:35 +00:00
pkg-config \
2017-04-12 13:58:26 +00:00
ruby2.1 \
ruby2.1-dev \
2017-04-13 11:03:51 +00:00
supervisor \
2017-04-14 07:10:17 +00:00
ttf-bitstream-vera \
tzdata
2015-10-27 11:39:35 +00:00
2017-04-13 17:37:02 +00:00
# Packages required for:
# autoconf, libtool and pkg-config for libtsm
# libfontconfig1 for PhantomJS
# ttf-bitstream-vera for a2png
2017-04-13 18:10:19 +00:00
# imagemagick (identify) for PNG generator (Ruby)
2015-10-27 11:39:35 +00:00
2017-04-13 09:27:10 +00:00
# install Bundler
2017-04-12 13:58:26 +00:00
RUN gem install bundler
2015-10-27 11:39:35 +00:00
2017-04-13 09:27:10 +00:00
# install PhantomJS
2017-04-12 13:58:26 +00:00
ARG PHANTOMJS_VERSION = 2 .1.1
RUN wget --quiet -O /opt/phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-$PHANTOMJS_VERSION -linux-x86_64.tar.bz2 && \
tar xjf /opt/phantomjs.tar.bz2 -C /opt && \
rm /opt/phantomjs.tar.bz2 && \
ln -sf /opt/phantomjs-$PHANTOMJS_VERSION -linux-x86_64/bin/phantomjs /usr/local/bin
2015-10-27 11:39:35 +00:00
2017-04-13 09:27:10 +00:00
# install libtsm
2017-04-12 19:22:12 +00:00
RUN git clone https://github.com/asciinema/libtsm.git /tmp/libtsm && \
2015-10-27 11:39:35 +00:00
cd /tmp/libtsm && \
2017-04-12 19:22:12 +00:00
git checkout asciinema && \
2015-10-27 11:39:35 +00:00
test -f ./configure || NOCONFIGURE = 1 ./autogen.sh && \
./configure --prefix= /usr/local && \
make && \
2017-04-12 13:58:26 +00:00
make install && \
2017-04-12 19:18:38 +00:00
ldconfig && \
rm -rf /tmp/libtsm
2015-10-27 11:39:35 +00:00
2017-04-13 09:26:22 +00:00
# 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
2015-10-27 11:39:35 +00:00
# install asciinema
2017-04-13 09:26:22 +00:00
2017-04-13 12:37:40 +00:00
ENV RAILS_ENV "production"
2017-04-13 09:26:22 +00:00
RUN mkdir -p /app/tmp /app/log
2015-10-27 11:39:35 +00:00
WORKDIR /app
2017-04-13 18:22:47 +00:00
COPY Gemfile* /app/
2017-04-13 12:37:40 +00:00
RUN bundle install --deployment --without development test
2017-04-12 19:43:32 +00:00
2017-04-14 22:25:21 +00:00
# build a2png
2017-04-13 16:10:23 +00:00
COPY a2png/project.clj /app/a2png/
2017-04-13 09:26:22 +00:00
RUN cd a2png && lein deps
2017-04-14 22:25:21 +00:00
COPY a2png/package.json /app/a2png/
RUN cd a2png && npm install
2017-04-13 16:10:23 +00:00
COPY a2png /app/a2png
RUN cd a2png && lein cljsbuild once main && lein cljsbuild once page
2017-04-14 22:30:18 +00:00
# copy the rest of the source code
2017-04-13 18:22:47 +00:00
COPY . /app
2017-04-12 19:43:32 +00:00
2017-04-14 22:01:31 +00:00
ENV DATABASE_URL "postgresql://asciinema:sekrit@postgres/asciinema"
2017-04-13 16:12:45 +00:00
ENV REDIS_URL "redis://redis:6379"
2017-04-14 22:30:18 +00:00
# compile terminal.c
2017-04-12 19:43:32 +00:00
RUN cd src && make
2017-04-14 22:30:18 +00:00
# compile assets
2017-04-13 12:37:40 +00:00
RUN bundle exec rake assets:precompile
2017-04-14 22:30:18 +00:00
# install smtp configuration
2017-04-13 20:19:39 +00:00
COPY docker/asciinema.yml /app/config/asciinema.yml
2015-10-27 11:39:35 +00:00
2017-04-13 11:03:51 +00:00
# configure Nginx
COPY docker/nginx/asciinema.conf /etc/nginx/sites-available/default
# configure Supervisor
RUN mkdir -p /var/log/supervisor
COPY docker/supervisor/asciinema.conf /etc/supervisor/conf.d/asciinema.conf
2017-04-13 16:13:30 +00:00
VOLUME [ "/app/log" , "/app/uploads" ]
2015-10-27 11:39:35 +00:00
2016-11-29 19:23:18 +00:00
ENV HOST "localhost:3000"
2015-10-27 11:39:35 +00:00
2017-04-13 11:03:51 +00:00
CMD [ "/usr/bin/supervisord" ]
2015-10-27 11:39:35 +00:00
# bundle exec rake db:setup
2017-04-13 20:19:39 +00:00
# bundle exec sidekiq
2017-04-13 11:03:51 +00:00
EXPOSE 80