#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#FROM centos:7.2.1511
FROM centos:7
MAINTAINER Dan Kirkwood <dangogh@apache.org>

RUN yum -y install \
        https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

RUN yum -y install \
        epel-release \
        vim \
        cpanminus \
        expat-devel \
        gcc-c++ \
        libcurl \
        libcurl-devel \
        libidn-devel \
        libpcap-devel \
        mkisofs \
        nmap-ncat \
        openssl-devel \
        perl \
        perl-App-cpanminus \
        perl-DBD-Pg \
        perl-DBI \
        perl-Digest-SHA1 \
        perl-JSON \
        perl-TermReadKey \
        perl-Test-CPAN-Meta \
        perl-WWW-Curl \
        perl-core \
        perl-libwww-perl \
        perl-Crypt-ScryptKDF \
        postgresql96 \
        postgresql96-devel && \
        yum clean all

RUN cpanm -n Carton

ARG TO_DIR=traffic_ops
ARG API_DOCKER_DIR=traffic_ops/testing/api/docker

ARG TO_RPM=traffic_ops-2.2.0-7398.7bb32b09.el7.x86_64.rpm
ADD $API_DOCKER_DIR/$TO_RPM /
WORKDIR /
RUN yum -y install $TO_RPM

ADD $TO_DIR/install/bin/install_goose.sh /
ADD $TO_DIR/install/bin/install_go.sh /
RUN /install_go.sh
RUN /install_goose.sh


#ADD $API_DOCKER_DIR/local /opt/traffic_ops/app
WORKDIR /opt/traffic_ops/app

RUN POSTGRES_HOME=/usr/pgsql-9.6 carton

CMD bash -c 'echo "Completed"'
#CMD bash -c 'mv -v local /'

#EXPOSE 60443
