# Dockerfile

FROM       centos:centos7

WORKDIR    /var/app
ENV ENVIRONMENT=qa

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

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

# Install python3.6 and wsgi dependencies
RUN        yum -y install gcc python36u python36u-libs python36u-devel

# Install postgresql-devel (needed for psycopg2)
RUN        yum -y install postgresql-devel

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

# 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

# Add startup script
ADD        uwsgi-start.sh /
RUN        chmod +x /uwsgi-start.sh
ENTRYPOINT ["/uwsgi-start.sh"]

EXPOSE     8080
