FROM ubuntu:12.04

# ==System
VOLUME ["/root/.ssh", "/root/.gnupg"]

# ==Packages
ENV P2P_WAIT_TIMEOUT=1
ENV NPM_CONFIG_REGISTRY=http://npm.yandex-team.ru

RUN apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
RUN echo "deb http://old-releases.ubuntu.com/ubuntu precise main restricted universe multiverse" > /etc/apt/sources.list
RUN echo "deb http://old-releases.ubuntu.com/ubuntu precise-updates main restricted universe multiverse" >> /etc/apt/sources.list

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7FCD11186050CD1A

# partner-precise
RUN echo deb http://partner-precise.dist.yandex.ru/partner-precise/ stable/all/ >> /etc/apt/sources.list.d/partner-precise.list
RUN echo deb http://partner-precise.dist.yandex.ru/partner-precise/ stable/amd64/ >> /etc/apt/sources.list.d/partner-precise.list
RUN echo deb http://partner-precise.dist.yandex.ru/partner-precise/ unstable/amd64/ >> /etc/apt/sources.list.d/partner-precise.list
RUN echo deb http://yandex.dist.yandex.ru/yandex/ stable/all/ >> /etc/apt/sources.list.d/partner-precise.list
RUN echo deb http://yandex.dist.yandex.ru/yandex/ unstable/all/ >> /etc/apt/sources.list.d/partner-precise.list
RUN echo deb http://tojetstyle.dist.yandex.ru/tojetstyle/ unstable/all/ >> /etc/apt/sources.list.d/partner-precise.list
RUN echo deb http://tojetstyle.dist.yandex.ru/tojetstyle/ testing/all/ >> /etc/apt/sources.list.d/partner-precise.list

# yandex-precise
RUN echo deb http://yandex-precise.dist.yandex.ru/yandex-precise/ stable/all/ >> /etc/apt/sources.list.d/yandex-precise.list
RUN echo deb http://yandex-precise.dist.yandex.ru/yandex-precise/ stable/amd64/ >> /etc/apt/sources.list.d/yandex-precise.list
RUN echo deb http://yandex-precise.dist.yandex.ru/yandex-precise/ unstable/all/ >> /etc/apt/sources.list.d/yandex-precise.list

# direct-precise
RUN echo deb http://direct-precise.dist.yandex.ru/direct-precise/ stable/all/ >> /etc/apt/sources.list.d/direct-precise.list
RUN echo deb http://direct-precise.dist.yandex.ru/direct-precise/ stable/amd64/ >> /etc/apt/sources.list.d/direct-precise.list

# common
RUN echo deb http://common.dist.yandex.ru/common/ stable/all/ >> /etc/apt/sources.list.d/common.list

RUN echo deb http://advq-precise.dist.yandex.ru/advq-precise/ stable/all/ >> /etc/apt/sources.list.d/advq.list
RUN echo deb http://advq-precise.dist.yandex.ru/advq-precise/ stable/amd64/ >> /etc/apt/sources.list.d/advq.list
RUN echo deb http://advq-common.dist.yandex.ru/advq-common/ stable/all/ >> /etc/apt/sources.list.d/advq.list
RUN echo deb http://advq-common.dist.yandex.ru/advq-common/ stable/amd64/ >> /etc/apt/sources.list.d/advq.list

RUN echo deb http://verstka.dist.yandex.ru/verstka stable/all/ >> /etc/apt/sources.list.d/verstka.list
RUN echo deb http://verstka.dist.yandex.ru/verstka stable/amd64/ >> /etc/apt/sources.list.d/verstka.list

RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y dpkg-dev

# local
ADD ./dist_local /dist
RUN echo deb file:/dist files/ >> /etc/apt/sources.list.d/local.list
RUN cd /dist; dpkg-scanpackages ./files /dev/null | gzip -9c > ./files/Packages.gz

RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y curl
RUN apt-get install -y vim
RUN apt-get install -y devscripts
RUN apt-get install -y yandex-dh-environment
RUN apt-get install -y --force-yes liblocale-po-perl
RUN apt-get install -y --force-yes libhttp-cookies-perl=6.00-2 libhttp-message-perl=6.02-1 libhttp-negotiate-perl=6.00-2 libwww-perl=6.03-5~timeout-fix liblwp-protocol-https-perl
RUN apt-get install -y --force-yes libdist-zilla-perl
RUN apt-get install -y --force-yes libdist-zilla-plugin-git-perl
RUN apt-get install -y --force-yes libdist-zilla-plugin-pi-perl
RUN apt-get install -y --force-yes libdist-zilla-plugin-release-yandexdist
RUN apt-get install -y --force-yes libqbit-application-model-api-yandex-botblocker-perl
RUN apt-get install -y --force-yes libqbit-application-model-memcached-perl
# skynet emulation, needed for the packages below
COPY ./sky /skynet/tools/
COPY ./skyhost /skynet/tools/
##
RUN apt-get install -y --force-yes libqbit-application-model-yandex-cbb-xs-perl
RUN apt-get install -y --force-yes libqbit-cron-perl
RUN apt-get install -y --force-yes libqbit-webinterface-fastcgi-perl
RUN apt-get install -y --force-yes libyandex-tanker-perl
RUN apt-get install -y --force-yes qbit-xgettext

RUN apt-get install -y dupload
ADD ./dupload.conf /root/.dupload.conf

# ==FRONT

RUN apt-get install -y --force-yes nodejs
RUN apt-get install -y --force-yes npm
RUN echo registry = http://npm.yandex-team.ru/ >> /etc/npmrc

# ===Lego
# ADD http://gitlab.yandex-team.ru/direct/romochka/-/archive/2.10.21/romochka-2.10.21.zip /tmp
# RUN mkdir -p /var/lib/yandex/lego
# RUN unzip /tmp/2.10.21.zip -d /var/lib/yandex/lego/
RUN git clone https://github.yandex-team.ru/lego/romochka /var/lib/yandex/lego/romochka-2.10.21
RUN cd /var/lib/yandex/lego/romochka-2.10.21; git checkout 2.10.21
RUN ln -s /var/lib/yandex/lego/romochka-2.10.21 /var/lib/yandex/lego/2.10.21
## RUN cd /var/lib/yandex/lego/2.10.21; make -f GNUmakefile depends


# ===node_modules
RUN npm set strict-ssl false
RUN cd /usr/lib/node_modules/; npm install bem@0.6.5
RUN ln -s /usr/lib/node_modules/bem/bin/bem /usr/bin/bem
RUN cd /usr/lib/node_modules/; npm install dom-js@0.0.9
RUN cd /usr/lib/node_modules/; npm install xjst@0.4.17
RUN cd /usr/lib/node_modules/; npm install ometajs@3.1.14

RUN apt-get update
RUN apt-get install -y --force-yes yandex-ycssjs


# ===QBit
ADD ./QBit /tmp/QBit
RUN tar xzvf /tmp/QBit/qbit_all.tgz -C /tmp/
RUN cp -r /tmp/QBit/usr/* /usr/ && rm -rf /tmp/QBit/usr

RUN tar xzvf /tmp/QBit/qbit-githooks.tgz -C /


# == APP
RUN mkdir /app
WORKDIR /app

