FROM centos:centos7

RUN yum -y update
RUN yum install -y gcc
RUN yum install -y libgfortran
RUN yum install -y git

#
# Python 3.6 (pip3 install is enough)
#
# RUN yum install -y https://centos7.iuscommunity.org/ius-release.rpm   # it seems this one is deprecated
RUN yum install -y https://repo.ius.io/ius-release-el7.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN yum install -y python36u python36u-libs python36u-devel python36u-pip

RUN pip3 install numpy
RUN pip3 install scipy
RUN pip3 install pytest
RUN pip3 install pandas
RUN pip3 install spiceypy==2.3.2
RUN pip3 install html-testRunner
RUN pip3 install bs4

#WORKDIR /
#RUN mkdir .ssh
#COPY id_rsa_centos /.ssh/id_rsa

#WORKDIR /root
#RUN git clone ssh://git@repos.cosmos.esa.int:7998/spice/adcsng.git
#RUN git clone ssh://git@repos.cosmos.esa.int:7998/spice/arcgen.git
#RUN git clone https://repos.cosmos.esa.int/socci/projects/SPICE_KERNELS/repos/ExoMarsRSP

COPY adcsng root/adcsng/
COPY arcgen root/arcgen/

COPY incoming root/incoming/
COPY ExoMarsRSP/kernels root/kernels/

COPY run_spice-pipeline.sh root/run_spice-pipeline.sh
WORKDIR /root

RUN mkdir temp log
RUN mkdir -p output/spk output/ck output/sclk output/mk

#
# Install ADCSng and ARCGEN
#
WORKDIR /root/adcsng
RUN pip3 install -e .

WORKDIR /root/arcgen
RUN pip3 install -e .

WORKDIR /root
COPY adcsng.json ./

WORKDIR /root
COPY arcgen.json ./

WORKDIR /root/adcsng/adcsng/exe/pc_linux_64bit
RUN chmod 777 *

#
# Run ADCSng regression tests
#
WORKDIR /root/adcsng/adcsng/tests
RUN python3 test_regression.py

#
# Back to the root
#
WORKDIR /root


