# Dockerfile
FROM       centos:centos7
WORKDIR    /var/app

# Update and install common packages
RUN        yum -y update
RUN        yum -y install epel-release curl tar zip wget epel-release tar zip openssl openssl-devel glibc-common

# Install python 3.6 dependencies
RUN        yum -y install gcc python3 python3-libs python3-devel python3-pip

# Add application
ADD        . /var/app

# Install supervisor & configure supervisor dirs
RUN        yum -y install supervisor
RUN        mkdir /var/app/logs/supervisor
RUN        mkdir /var/app/run

# Add user & set permisson
RUN        useradd worker -s /bin/false
RUN        chown -R worker:worker /var/app

# Create and configure virtualenv and install requirements
RUN        python3.6 -m venv /var/app
RUN        if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -I -r /var/app/requirements.txt; fi

# Set ENV vars
ENV        START_DATE="change_start_date"
ENV        END_DATE="change_end_date"

RUN        chmod +x index.py

USER       worker

ENTRYPOINT ["/usr/bin/supervisord", "-c", "conf/supervisor.conf"]

EXPOSE     9001
