FROM centos:centos7

WORKDIR /var/app

# Update and install common packages
RUN yum -y update
RUN yum -y install epel-release java-1.8.0-openjdk java-1.8.0-openjdk-devel curl git tar zip openssl openssl-devel glibc-common mariadb-devel postgresql postgresql-devel
# Add Supervisord
RUN yum -y install supervisor

# Add IUS Repository
RUN yum -y install https://centos7.iuscommunity.org/ius-release.rpm

# Install python 3.4
RUN yum -y install gcc python34u python34u-libs python34u-devel python34u-pip

# Create and configure virtualenv and uwsgi
RUN python3.4 -m venv /var/app

# Add application
ADD . /var/app

RUN mkdir -p /root/.ssh
ADD id_rsa /root/.ssh/id_rsa
RUN chmod 700 /root/.ssh/id_rsa
RUN ssh-keyscan -H github.com >> /root/.ssh/known_hosts \
    && chmod 600 /root/.ssh/known_hosts
RUN echo 'Host github.com\n\tStrictHostKeyChecking no\n' >> ~/.ssh/config

# Install requirements
RUN /var/app/bin/pip install --upgrade pip
RUN if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -I -r /var/app/requirements.txt; fi

# Explicitly set locale and related env vars to use not default POSIX, but en_US.UTF-8
RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8

# Run supervisord
ENTRYPOINT ["/usr/bin/supervisord", "-c", "conf/supervisor.conf"]
EXPOSE 9001