# Dockerfile

FROM       centos:centos7

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

# Update and install common packages
RUN        yum -y update
RUN        yum -y install curl git tar zip supervisor

WORKDIR    /var/app

# Install python 3.6
RUN        yum -y install gcc python36u python36u-libs python36u-devel

# Create and configure virtualenv and worker
RUN        python3.6 -m venv /var/app
RUN        useradd worker -s /bin/false
RUN        mkdir /var/log/worker
RUN        chown -R worker:worker /var/log/worker

# Add application and install requirements
ADD        . /var/app
RUN        if [ -f /var/app/requirements.txt ]; then /var/app/bin/pip install -I -r /var/app/requirements.txt; fi

EXPOSE     9001
CMD        ["/usr/bin/supervisord", "-c", "/var/app/conf/supervisord.conf"]
