Wednesday, March 22, 2023
HomePythonUtilizing docker multistage construct to construct turbodbc with pyarrow assistance on Debian...

Utilizing docker multistage construct to construct turbodbc with pyarrow assistance on Debian 11 


turbodbc



Turbodbc is a Python component to
accessibility relational data sources through the Open Data Source Connection (ODBC) user interface.
For optimal efficiency, turbodbc uses integrated NumPy and also Apache Arrowhead assistance
and also inside depends on batched information transfer rather than single-record
interaction as various other preferred ODBC components do.

Structure turbodbc with pyarrow assistance has some cautions as it has construct
time discovery if pyarrow is set up and also requires pybind and also numerous debian
dev bundles to obtain the C++ collection.

By utilizing docker multistage develops
we can natively construct turbodbc with pyarrow assistance without obtaining the dev bundles.
right into the last photo.

Very first step is the base photo that has all needed debian bundles to run turbodbc later:

 # phrase structure= docker/dockerfile:1

 FROM  debian:  bullseye  as  base

 # Develop customer, have to not be origin and also UID need to be more than 1000
 RUN  useradd -- uid  1100  application -- produce- house

 RUN  appropriate- obtain  upgrade
 RUN -- place = kind = cache, target=/ var/ cache/ appropriate   appropriate- obtain  mount -- yes  python3  python3- venv  git
 RUN -- place = kind = cache, target=/ var/ cache/ appropriate   appropriate- obtain  mount -- yes  libodbc1  odbcinst  odbcinst1debian2  binutils- x86- 64- linux- gnu
 RUN  python3 - m  venv / choose/ venv
 ENV  COURSE ="/ opt/venv/bin:$ {COURSE} "
 WORKDIR / application/
 ENV  PYTHONPATH=/ application/

In the 2nd phase we mount the construct demands that are just required to.
put together turbodbc with arrowhead assistance. There are 2 essential notes:

First of all pyarrow needs to be set up prior to turbodbc is construct as the.
turbodbc construct procedure instantly finds if pyarrow is readily available.

To make the discovery job you require to pass -- no-build-isolation to.
the turbodbc mount and also ensure the arrowhead collections are connected appropriately.

 FROM  base  as  home builder
 RUN  -- place = kind = cache, target=/ var/ cache/ appropriate   appropriate- obtain - yq  mount 
     construct- necessary 
     gdb 
     lcov 
     libbz2- dev 
     libffi- dev 
     libgdbm- dev 
     liblzma- dev 
     libboost- dev 
     libncurses5- dev 
     libreadline6- dev 
     libsqlite3- dev 
     libssl- dev 
     lzma 
     lzma- dev 
     python3- dev 
     tk- dev 
     unixodbc- dev 
     uuid- dev 
     xvfb 
     zlib1g- dev


 RUN  pip3  mount - U  pip= = 22.0 4  setuptools= = 45.2 0  wheel= = 0.37 1

 RUN  pip3  mount - U  pybind11= = 2.10 1  numpy= = 1.23 5  pandas= = 1.5 2  6= = 1.16 0  pyarrow= = 5.0 0

 RUN  python3 - c " import pyarrow; pyarrow.create _ library_symlinks()" 
    &&& &  CPPFLAGS ="- D_GLIBCXX_USE_CXX11_ABI= 0"  pip3  mount  -- no- construct- seclusion  turbodbc= = 4.5 5

In the 3rd phase we produce a fresh phase and also just reuse venv with the turbodbc construct bundles

 FROM  base  as  jogger
 DUPLICATE -- from = home builder / choose/ venv / choose/ venv

 DUPLICATE  demands txt / application/ demands txt

 RUN -- place = kind = cache, target=/ origin/. cache   pip  mount  -- demand / application/ demands txt

 # Establish the Customer we produced over
 CUSTOMER  1100

 CMD []

RELATED ARTICLES

Most Popular

Recent Comments