# Dockerfile

FROM       centos:centos7

WORKDIR    /var/app

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

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

# Create and configure poetry and uwsgi
RUN        pip3 install -U pip
ENV        POETRY_VERSION=1.0.10
RUN        curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
RUN        python3 ~/.poetry/bin/poetry config virtualenvs.create false
COPY       poetry.lock pyproject.toml /var/app/

RUN        python3 ~/.poetry/bin/poetry install -n

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

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

EXPOSE     8080
