# Dockerfile

FROM       centos:centos7

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

# Install supervisor from epel release
RUN        yum -y update
RUN        yum -y install supervisor

WORKDIR    /var/app

# Install python 3.6
RUN        yum -y install gcc python36 python36-libs python36-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        /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

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