FROM python:3.6
ADD . /lpq
WORKDIR /lpq

ARG SECRET_KEY_ARG=''
ARG DB_HOST_ARG=''
ARG DB_PASS_ARG=''
ARG DB_NAME_ARG=''
ARG CC_URL_ARG=''

ENV SECRET_KEY=${SECRET_KEY_ARG}
ENV DB_HOST=${DB_HOST_ARG}
ENV DB_PASS=${DB_PASS_ARG}
ENV DB_NAME=${DB_NAME_ARG}
ENV CC_URL=${CC_URL_ARG}
ENV ENV_TYPE='testing'

RUN apt-get update -q && \
    apt-get install -yq --no-install-recommends \
        python3-pip \
        vim \
        git \
        less \
        telnet \
        libssl-dev \
        expect
RUN pip3 install --upgrade setuptools && \
    pip3 install --upgrade pip && \
    pip3 install uwsgi && \
    pip3 install . && \
    pip3 install --upgrade --no-binary :all: psycopg2

COPY entrypoint.sh /usr/local/bin/
RUN chmod 777 -R /usr/local/bin/entrypoint.sh

# migrate and run with tee
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 80