Skip to content

Commit

Permalink
Use prebuilt pyodbc wheels and upgrade msodbcsql18
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyBlinksma committed Dec 5, 2022
1 parent e03b12f commit 3c39da8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
25 changes: 6 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
#Build container
FROM python:3.11.0-bullseye@sha256:c9d5243be5cc5c7fd917eb6aa9b209d2c849c1661aff94ca4ca76b82b8bda098 AS builder

#Run apt update && apt install and build pyodbc and cffi as wheels
RUN apt-get update &&\
apt-get install -y build-essential unixodbc-dev &&\
python -m pip wheel --wheel-dir /tmp/wheelhouse pyodbc==4.0.32 &&\
python -m pip wheel --no-binary :all: --wheel-dir /tmp/wheelhouse cffi

#App container
FROM python:3.10.4-alpine3.15@sha256:2cca1fb3c699208f929afd487be37ddc97c531648c404f3df78fb25a0ff344a2

ENV ACCEPT_EULA=Y
#Run apk add with no caching && install MS SQL ODBC Driver v18
RUN \
apk add --no-cache curl gnupg &&\
curl -O https://download.microsoft.com/download/b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486/msodbcsql18_18.0.1.1-1_amd64.apk &&\
curl -O https://download.microsoft.com/download/b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486/msodbcsql18_18.0.1.1-1_amd64.sig &&\
curl -O https://download.microsoft.com/download/8/6/8/868e5fc4-7bfe-494d-8f9d-115cbcdb52ae/msodbcsql18_18.1.2.1-1_amd64.apk &&\
curl -O https://download.microsoft.com/download/8/6/8/868e5fc4-7bfe-494d-8f9d-115cbcdb52ae/msodbcsql18_18.1.2.1-1_amd64.sig &&\
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --import - &&\
gpg --verify -v msodbcsql18_18.0.1.1-1_amd64.sig msodbcsql18_18.0.1.1-1_amd64.apk &&\
apk add --allow-untrusted msodbcsql18_18.0.1.1-1_amd64.apk &&\
rm msodbcsql18_18.0.1.1-1_amd64.apk &&\
gpg --verify -v msodbcsql18_18.1.2.1-1_amd64.sig msodbcsql18_18.1.2.1-1_amd64.apk &&\
apk add --allow-untrusted msodbcsql18_18.1.2.1-1_amd64.apk &&\
rm msodbcsql18_18.1.2.1-1_amd64.apk &&\
apk del curl gnupg

#Copy pyodbc and cffi wheels to app container, and install them
COPY --from=builder /tmp/wheelhouse /tmp/wheelhouse
RUN ls /tmp/wheelhouse && pip install --find-links=/tmp/wheelhouse pyodbc==4.0.32 cffi

#install other redependencies and copy application
RUN pip install cryptography==36.0.2 zeep==4.1.0
RUN pip install -r requirements.txt
WORKDIR /app
COPY pubkeys /app/pubkeys
COPY lang /app/lang
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
cryptography==38.0.4
zeep==4.2.1
pyodbc==4.0.32

0 comments on commit 3c39da8

Please sign in to comment.