-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
51 lines (42 loc) · 2.02 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM python:3.7-slim AS base
# Mount volume
ADD ./src /app
# Set working directory
WORKDIR /app
RUN ls -l
# Setup dependencies for pyodbc
RUN \
export ACCEPT_EULA='Y' && \
export MYSQL_CONNECTOR='mysql-connector-odbc-8.0.18-linux-glibc2.12-x86-64bit' && \
apt-get update && \
apt-get install -y curl build-essential unixodbc-dev g++ apt-transport-https && \
#
# Install pyodbc db drivers for MSSQL, PG and MySQL
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
curl -L -o ${MYSQL_CONNECTOR}.tar.gz https://dev.mysql.com/get/Downloads/Connector-ODBC/8.0/${MYSQL_CONNECTOR}.tar.gz && \
apt-get update && \
gunzip ${MYSQL_CONNECTOR}.tar.gz && tar xvf ${MYSQL_CONNECTOR}.tar && \
cp ${MYSQL_CONNECTOR}/bin/* /usr/local/bin && cp ${MYSQL_CONNECTOR}/lib/* /usr/local/lib && \
myodbc-installer -a -d -n "MySQL ODBC 8.0 Driver" -t "Driver=/usr/local/lib/libmyodbc8w.so" && \
myodbc-installer -a -d -n "MySQL ODBC 8.0" -t "Driver=/usr/local/lib/libmyodbc8a.so" && \
apt-get install -y msodbcsql17 odbc-postgresql && \
#
# Update odbcinst.ini to make sure full path to driver is listed
sed 's/Driver=psql/Driver=\/usr\/lib\/x86_64-linux-gnu\/odbc\/psql/' /etc/odbcinst.ini > /tmp/temp.ini && \
mv -f /tmp/temp.ini /etc/odbcinst.ini && \
# Install dependencies
pip install --upgrade pip && \
pip install -r requirements.txt && rm requirements.txt
## Cleanup build dependencies
#rm -rf ${MYSQL_CONNECTOR}* && \
#apt-get remove -y curl apt-transport-https debconf-utils g++ gcc rsync unixodbc-dev build-essential gnupg2 && \
#apt-get autoremove -y && apt-get autoclean -y
# install pyodbc (and, optionally, sqlalchemy)
RUN pip install --trusted-host pypi.python.org pyodbc==4.0.26 sqlalchemy==1.3.5 pandasql seaborn
ENV FLASK_APP=server.py
# Hot reload flag
ENV FLASK_ENV=development
# Run flask app on port 6650
ENV FLASK_RUN_PORT=6650
CMD ["flask", "run", "--host", "0.0.0.0"]