FROM python:3.7-stretch
RUN apt-get update && apt-get install -y \
    curl apt-utils apt-transport-https debconf-utils gcc build-essential gcc-6-test-results\
    && rm -rf /var/lib/apt/lists/*

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install libssl - required for sqlcmd to work on Ubuntu 18.04
RUN apt-get update && apt-get install -y libssl1.1 libssl-dev

# install SQL Server drivers
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev

# install SQL Server tools
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
RUN /bin/bash -c "source ~/.bashrc"
RUN pip install pyodbc
RUN apt-get update -y && \
    apt-get install -y tzdata  && \
    rm -rf /var/lib/apt/lists/*
USER root
ADD . /app
WORKDIR /app
RUN pip install -r requirements.txt
RUN rm -rf /var/lib/apt/lists/* && rm -rf /root/.cache/pip/
CMD ["python", "cron-app.py"]
