# Dockerfile

FROM       centos:centos7

WORKDIR    /var/app

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

# Add IUS and Orchard SQLRelay repositories
RUN        yum -y install https://centos7.iuscommunity.org/ius-release.rpm
RUN        curl -s https://packagecloud.io/install/repositories/orchardit/sqlrelay/script.rpm.sh | bash

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

# Install python SQLRelay packages
RUN        yum -y install python34-sqlrelay python34-db-sqlrelay

# Create and configure virtualenv and uwsgi
RUN        pyvenv-3.4 /var/app
RUN        sed -i 's/false/true/g' /var/app/pyvenv.cfg
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 /

ENTRYPOINT ["/uwsgi-start.sh"]

EXPOSE     8080
