-
Notifications
You must be signed in to change notification settings - Fork 6
/
pyodbc.dockerfile
47 lines (39 loc) · 1.56 KB
/
pyodbc.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
FROM python:3.7-slim AS base
ADD requirements.txt ./
# Setup dependencies for pyodbc
RUN \
apt-get update && \
apt-get install -y curl build-essential unixodbc-dev g++ apt-transport-https && \
gpg --keyserver hkp://keys.gnupg.net --recv-keys 5072E1F5
# install netcat (i.e. `nc` command)
RUN apt install -y netcat
RUN \
export ACCEPT_EULA='Y' && \
# Install pyodbc db drivers for MSSQL
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 && \
apt-get update && \
apt-get install -y msodbcsql17 odbc-postgresql mssql-tools
# add sqlcmd to the path
ENV PATH="$PATH:/opt/mssql-tools/bin"
# Update odbcinst.ini to make sure full path to driver is listed
RUN \
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 pip
RUN \
pip install --upgrade pip && \
pip install -r requirements.txt && \
rm requirements.txt
# permission management
RUN \
chmod +rwx /etc/ssl/openssl.cnf && \
# change TLS back to version 1
sed -i 's/TLSv1.2/TLSv1/g' /etc/ssl/openssl.cnf && \
# allow weak certificates (certificate signed with SHA1)
# by downgrading OpenSSL security level from 2 to 1
sed -i 's/SECLEVEL=2/SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN \
# Cleanup build dependencies
apt-get remove -y curl apt-transport-https debconf-utils g++ gcc rsync build-essential gnupg2 && \
apt-get autoremove -y && apt-get autoclean -y