FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }}
MAINTAINER {{ maintainer }}

{% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}
RUN yum -y install \
        git \
        iproute \
        openssl \
    && yum clean all

{% endif %}
{% if install_type == 'binary' %}
    {% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}

# TODO(Allen) Remove python-dogpile-cache after the requirement of
# python-ironicclient is fixed.
RUN yum -y install \
        avahi-libs \
        cups-libs \
        fontconfig \
        fontpackages-filesystem \
        freetype \
        initscripts \
        libjpeg-turbo \
        libpng \
        libtomcrypt \
        libtommath \
        libX11 \
        libX11-common \
        libXau \
        libxcb \
        libXext \
        libXi \
        libxslt \
        libyaml \
        MySQL-python \
        Percona-Server-shared-56 \
        pyOpenSSL \
        pyparsing \
        python2-cffi \
        python2-crypto \
        python2-cryptography \
        python2-debtcollector \
        python2-eventlet \
        python2-fasteners \
        python2-funcsigs \
        python2-futurist \
        python2-greenlet \
        python2-iso8601 \
        python2-msgpack \
        python2-oslo-concurrency \
        python2-oslo-config \
        python2-oslo-context \
        python2-oslo-db \
        python2-oslo-i18n \
        python2-oslo-log \
        python2-oslo-messaging \
        python2-oslo-middleware \
        python2-oslo-policy \
        python2-oslo-serialization \
        python2-oslo-service \
        python2-oslo-utils \
        python2-pika \
        python2-pika_pool \
        python2-positional \
        python2-pyasn1 \
        python2-PyMySQL \
        python-alembic \
        python-amqp \
        python-anyjson \
        python-barbicanclient \
        python-beaker \
        python-cachetools \
        python-ceilometerclient \
        python-cliff \
        python-cmd2 \
        python-congressclient \
        python-contextlib2 \
        python-dateutil \
        python-decorator \
        python-designateclient \
        python-dogpile-cache \
        python-editor \
        python-enum34 \
        python-extras \
        python-fixtures \
        python-futures \
        python-glanceclient \
        python-heatclient \
        python-httplib2 \
        python-idna \
        python-inotify \
        python-ipaddress \
        python-ironicclient \
        python-jsonpatch \
        python-jsonpointer \
        python-jsonschema \
        python-keyring \
        python-keystoneauth1 \
        python-keystoneclient \
        python-keystonemiddleware \
        python-kombu \
        python-linecache2 \
        python-lxml \
        python-magnumclient \
        python-mako \
        python-manilaclient \
        python-memcached \
        python-migrate \
        python-mimeparse \
        python-mistralclient \
        python-monotonic \
        python-muranoclient \
        python-netaddr \
        python-netifaces \
        python-neutronclient \
        python-novaclient \
        python-openstackclient \
        python-paste \
        python-paste-deploy \
        python-pbr \
        python-pip \
        python-ply \
        python-posix_ipc \
        python-prettytable \
        python-pycparser \
        python-PyMySQL \
        python-repoze-lru \
        python-requests \
        python-retrying \
        python-routes \
        python-saharaclient \
        python-simplejson \
        python-sqlalchemy \
        python-sqlparse \
        python-stevedore \
        python-swiftclient \
        python-tempita \
        python-testtools \
        python-traceback2 \
        python-troveclient \
        python-tuskarclient \
        python-unicodecsv \
        python-unittest2 \
        python-urllib3 \
        python-warlock \
        python-webob \
        python-wrapt \
        python-zaqarclient \
        PyYAML \
        systemd-sysv \
        sysvinit-tools \
        tcp_wrappers-libs \
    && yum clean all

    {% elif base_distro in ['ubuntu'] %}

# This will prevent questions from being asked during the install
ENV DEBIAN_FRONTEND noninteractive
# There is no python-tuskarclient in ubuntu 14.04
RUN apt-get -y install --no-install-recommends \
        python-barbicanclient \
        python-ceilometerclient \
        python-congressclient \
        python-designateclient \
        python-heatclient \
        python-ironicclient \
        python-magnumclient \
        python-manilaclient \
        python-memcache \
        python-mistralclient \
        python-muranoclient \
        python-pip \
        python-saharaclient \
        python-swiftclient \
        python-troveclient \
        python-zaqarclient \
        python-openstackclient \
        python-pymysql \
        python-keystoneclient \
        python-oslo.log \
        openssl \
        patch \
    && apt-get clean

    {% endif %}
{% elif install_type == 'source' %}
    {% if base_distro in ['fedora', 'centos', 'oraclelinux', 'rhel'] %}

RUN yum -y install \
        gcc \
        gcc-c++ \
        libffi-devel \
        libxml2-devel \
        libxslt-devel \
        MariaDB-devel \
        openldap-devel \
        openssl-devel \
        postgresql \
        postgresql-devel \
        python-devel \
        sqlite-devel \
    && yum clean all

    {% elif base_distro in ['ubuntu', 'debian'] %}

RUN apt-get -y install --no-install-recommends \
        ca-certificates \
        build-essential \
        python-dev \
        libssl-dev \
        libmariadbclient-dev \
        libxslt1-dev \
        libffi-dev \
        libyaml-dev \
        pkg-config \
        git \
    && apt-get clean

    {% endif %}

ADD openstack-base-archive /openstack-base-source
RUN ln -s openstack-base-source/* /requirements \
    && mkdir -p /var/lib/kolla \
    && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
    && python get-pip.py \
    && rm get-pip.py \
    && pip --no-cache-dir install -U virtualenv \
    && virtualenv --system-site-packages /var/lib/kolla/venv \
    && /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt \
        Babel \
        Mako \
        MarkupSafe \
        Paste \
        PasteDeploy \
        PyYAML \
        Routes \
        SQLAlchemy \
        Tempita \
        WebOb \
        alembic \
        amqp \
        anyjson \
        appdirs \
        cachetools \
        cliff \
        cmd2 \
        contextlib2 \
        debtcollector \
        decorator \
        enum34 \
        eventlet \
        fasteners \
        funcsigs \
        functools32 \
        futures \
        futurist \
        greenlet \
        iso8601 \
        jinja2 \
        jsonpatch \
        jsonpointer \
        jsonschema \
        kazoo \
        keystoneauth1 \
        keystonemiddleware \
        kombu \
        monotonic \
        msgpack-python \
        netaddr \
        netifaces \
        os-client-config \
        oslo.concurrency \
        oslo.config \
        oslo.context \
        oslo.db \
        oslo.i18n \
        oslo.log \
        oslo.messaging \
        oslo.middleware \
        oslo.policy \
        oslo.serialization \
        oslo.service \
        oslo.utils \
        pbr \
        pika \
        pika-pool \
        positional \
        prettytable \
        pycadf \
        pycrypto \
        pyinotify \
        pymysql \
        pyparsing \
        python-barbicanclient \
        python-ceilometerclient \
        python-cinderclient \
        python-congressclient \
        python-dateutil \
        python-designateclient \
        python-editor \
        python-glanceclient \
        python-heatclient \
        python-ironicclient \
        python-keystoneclient \
        python-magnumclient \
        python-manilaclient \
        python-memcached \
        python-mistralclient \
        python-muranoclient \
        python-neutronclient \
        python-novaclient \
        python-openstackclient \
        python-saharaclient \
        python-swiftclient \
        python-troveclient \
        python-tuskarclient \
        python-zaqarclient \
        pytz \
        repoze.lru \
        requests \
        requestsexceptions \
        retrying \
        simplejson \
        six \
        sqlalchemy-migrate \
        sqlparse \
        stevedore \
        unicodecsv \
        warlock \
        wrapt

ENV PATH /var/lib/kolla/venv/bin:$PATH

{% endif %}