TimelordUK / node-sqlserver-v8

branched from node-sqlserver, SQL server driver compatible with all versions of Node
Other
139 stars 43 forks source link

msnodesqlv8 can't find sqltypes.h #289

Open eretztzvi opened 1 year ago

eretztzvi commented 1 year ago

Hi,

I have this package.json:

image

When I'm trying to build a docker image I'm getting this errors (at the npm i layer):

image image

What can I do with this? Thanks

TimelordUK commented 1 year ago

this implies you are missing odbc from linux install

the driver talks to odbc and odbc loads the underlying MS driver

e.g.

sudo apt install unixodbc Reading package lists... Done Building dependency tree... Done Reading state information... Done unixodbc is already the newest version (2.3.11-1). unixodbc set to manually installed. You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies:

i should be in somewhere like

ls /usr/include/sqltypes.h /usr/include/sqltypes.h

if you are building the driver from src you also need the ms odbc include e.g.

ls /opt/microsoft/msodbcsql18/include/msodbcsql.h

there are instructions on ms website how to install the ms odbc dev include files and dev tools

On Wed, 24 May 2023 at 08:53, Amir Eretz Tzvi @.***> wrote:

Hi,

I have this package.json:

[image: image] https://user-images.githubusercontent.com/92538868/240525570-dbca1e4f-57bd-44f2-9882-09837bc998a1.png

When I'm trying to build a docker image i get this errors:

[image: image] https://user-images.githubusercontent.com/92538868/240526813-9cafdf9e-9b81-49c9-a8d7-786c3f8acc2f.png [image: image] https://user-images.githubusercontent.com/92538868/240526921-884a0513-0e7a-4ff7-a783-ccd37f076157.png

What can I do with this? Thanks

— Reply to this email directly, view it on GitHub https://github.com/TimelordUK/node-sqlserver-v8/issues/289, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXWJG3XJYGWKPRB4ZANT6TXHW5AJANCNFSM6AAAAAAYM7AX6A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

TimelordUK commented 1 year ago

for docker i have found this image to work

FROM ubuntu:22.04
RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker
RUN echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker

RUN DEBIAN_FRONTEND=noninteractive \
  apt-get update \
  && apt-get install -y vim git build-essential curl perl dialog apt-utils ca-certificates apt-transport-https locales gnupg2 openssl lsb-release

RUN mkdir -p /etc/ssl/certs/
RUN curl https://packages.microsoft.com/keys/microsoft.asc | tee | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN echo msodbcsql18 msodbcsql/ACCEPT_EULA boolean true | debconf-set-selections
RUN DEBIAN_FRONTEND=noninteractive \
  apt-get update \
  && apt-get install -y python3 unixodbc unixodbc-dev nodejs
RUN ACCEPT_EULA=Y \
  apt-get install -y msodbcsql18
RUN ACCEPT_EULA=Y \
  apt-get install -y mssql-tools18 

RUN mkdir -p $HOME/projects
RUN git clone https://github.com/openssl/openssl.git $HOME/projects/openssl
RUN ( cd $HOME/projects/openssl ; ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared; make; make install)
RUN (cd /etc/ld.so.conf.d/; echo '/usr/local/ssl/lib64/' | tee openssl-3.2.0.1s.conf)
RUN ldconfig -v
RUN npm install --g yarn
RUN useradd -ms /bin/bash apprunner
USER apprunner
RUN mkdir -p $HOME/app
RUN cd $HOME/app

i build

docker build . -t msnodesqlv8-ubuntu

launch a shell

docker run -it msnodesqlv8-ubuntu bash
cd
cd app
git clone https://github.com/TimelordUK/msnodesqlv8_yarn_sample.git
yarn install

change the index.js for a valid connection string - note will need ip address rather than host unless you set up resolution

yarn test
Done in 15.26s.
apprunner@184c7c6d8c08:~/app/msnodesqlv8_yarn_sample$ ping DESKTOP-VIUCH90
bash: ping: command not found
apprunner@184c7c6d8c08:~/app/msnodesqlv8_yarn_sample$ vim index.js
apprunner@184c7c6d8c08:~/app/msnodesqlv8_yarn_sample$ yarn test
yarn run v1.22.19
$ node index
using connection 'Driver={ODBC Driver 18 for SQL Server}; Server=192.000.0.000;UID=linux; PWD=linux; Database=node;Encrypt=no;' run query 'SELECT top 2 * FROM syscolumns'
{
    "beginAt": "2023-05-29T18:56:30.565Z",
    "submittedAt": "2023-05-29T18:56:30.566Z",
    "endAt": "2023-05-29T18:56:30.640Z",
    "elapsed": 75,
    "first": [
        {
            "name": "rsid",
            "id": 3,
            "xtype": 127,
            "typestat": 1,
            "xusertype": 127,
            "length": 8,
            "xprec": 19,
            "xscale": 0,
            "colid": 1,
            "xoffset": 0,
            "bitpos": 0,
            "reserved": 0,
            "colstat": 0,
            "cdefault": 0,
 docker build . -t msnodesqlv8-ubuntu
[+] Building 603.2s (25/25) FINISHED
 => [internal] load .dockerignore                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                      0.0s
 => [internal] load build definition from Dockerfile                                                                                                                 0.0s
 => => transferring dockerfile: 1.49kB                                                                                                                               0.0s
 => [internal] load metadata for docker.io/library/ubuntu:22.04                                                                                                      0.0s
 => [ 1/21] FROM docker.io/library/ubuntu:22.04                                                                                                                      0.0s
 => CACHED [ 2/21] RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker                                                                            0.0s
 => CACHED [ 3/21] RUN echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker                                                                          0.0s
 => [ 4/21] RUN DEBIAN_FRONTEND=noninteractive   apt-get update   && apt-get install -y vim git build-essential curl perl dialog apt-utils ca-certificates apt-tra  83.7s
 => [ 5/21] RUN mkdir -p /etc/ssl/certs/                                                                                                                             0.6s
 => [ 6/21] RUN curl https://packages.microsoft.com/keys/microsoft.asc | tee | apt-key add -                                                                         1.0s
 => [ 7/21] RUN curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list                          0.8s
 => [ 8/21] RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -                                                                                            3.4s
 => [ 9/21] RUN echo msodbcsql18 msodbcsql/ACCEPT_EULA boolean true | debconf-set-selections                                                                         0.7s
 => [10/21] RUN DEBIAN_FRONTEND=noninteractive   apt-get update   && apt-get install -y python3 unixodbc unixodbc-dev nodejs                                        11.5s
 => [11/21] RUN ACCEPT_EULA=Y   apt-get install -y msodbcsql18                                                                                                       2.4s
 => [12/21] RUN ACCEPT_EULA=Y   apt-get install -y mssql-tools18                                                                                                     2.2s
 => [13/21] RUN mkdir -p $HOME/projects                                                                                                                              0.6s
 => [14/21] RUN git clone https://github.com/openssl/openssl.git $HOME/projects/openssl                                                                             54.1s
 => [15/21] RUN ( cd $HOME/projects/openssl ; ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared; make; make install)                             432.6s
 => [16/21] RUN (cd /etc/ld.so.conf.d/; echo '/usr/local/ssl/lib64/' | tee openssl-3.2.0.1s.conf)                                                                    0.7s
 => [17/21] RUN ldconfig -v                                                                                                                                          0.6s
 => [18/21] RUN npm install --g yarn                                                                                                                                 2.9s
 => [19/21] RUN useradd -ms /bin/bash apprunner                                                                                                                      0.8s
 => [20/21] RUN mkdir -p $HOME/app                                                                                                                                   0.6s
 => [21/21] RUN cd $HOME/app                                                                                                                                         0.5s
 => exporting to image                                                                                                                                               3.4s
 => => exporting layers                                                                                                                                              3.3s
 => => writing image sha256:1fc7851e63c80307bb37d8bea8ebdf546714fb34d479cb411e8bc91b307809f9                                                                         0.0s
 => => naming to docker.io/library/msnodesqlv8-ubuntu                                                                                                                0.0s

Administrator in dev\docker\ubuntu-msnodesqlv8 took 10m3s
❯ docker run -it msnodesqlv8-ubuntu bash
apprunner@184c7c6d8c08:/$ cd
apprunner@184c7c6d8c08:~$ cd app
apprunner@184c7c6d8c08:~/app$ Driver={ODBC Driver 18 for SQL Server}; Server=DESKTOP-VIUCH90;UID=linux; PWD=linux; Database=node;Encrypt=no;^C
apprunner@184c7c6d8c08:~/app$ git clone https://github.com/TimelordUK/msnodesqlv8_yarn_sample.git
Cloning into 'msnodesqlv8_yarn_sample'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 14 (delta 4), reused 14 (delta 4), pack-reused 0
Receiving objects: 100% (14/14), 7.90 KiB | 7.90 MiB/s, done.
Resolving deltas: 100% (4/4), done.
apprunner@184c7c6d8c08:~/app$ cd msnodesqlv8_yarn_sample/
apprunner@184c7c6d8c08:~/app/msnodesqlv8_yarn_sample$ vim index.js
apprunner@184c7c6d8c08:~/app/msnodesqlv8_yarn_sample$ yarn install
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...