Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV (Address boundary error) while atempting to open connection #270

Open
kalstong opened this issue Dec 16, 2022 · 18 comments
Open

SIGSEGV (Address boundary error) while atempting to open connection #270

kalstong opened this issue Dec 16, 2022 · 18 comments

Comments

@kalstong
Copy link

kalstong commented Dec 16, 2022

Hi,
Here we go.

OS: Arch linux
Kernel: Linux version 5.15.83-1-lts
ODBC Driver: msodbcsql 18.1.2.1-1
msnodesqlv8 Version: 2.7.0

node output:

fish: Job 1, '/usr/bin/env 'NODE_OPTIONS=--re…' terminated by signal SIGSEGV (Address boundary error)

coredump:

           PID: 194627 (ICONE Data Proc)
           UID: 1000 (kal)
           GID: 1000 (kal)
        Signal: 11 (SEGV)
     Timestamp: Fri 2022-12-16 14:18:04 WET (12s ago)
  Command Line: $'ICONE Data Processor [debug]'
    Executable: /home/kal/.cache/nvm/versions/node/v14.19.3/bin/node
 Control Group: /user.slice/user-1000.slice/session-1.scope
          Unit: session-1.scope
         Slice: user-1000.slice
       Session: 1
     Owner UID: 1000 (kal)
       Boot ID: c2b664d4c382485384a4280f4a33b396
    Machine ID: a9b84e66a8624ce0a521b06388316a91
      Hostname: midas
       Storage: /var/lib/systemd/coredump/core.ICONE\x20Data\x20Proc.1000.c2b664d4c382485384a4280f4a33b396.194627.1671200284>
  Size on Disk: 4.7M
       Message: Process 194627 (ICONE Data Proc) of user 1000 dumped core.
                
                Stack trace of thread 194655:
                #0  0x00000000015e02d0 n/a (/home/kal/.cache/nvm/versions/node/v14.19.3/bin/node + 0x11e02d0)
                ELF object binary architecture: AMD x86-64

More detail:

#0  0x00000000015e02d0 in EC_GROUP_order_bits ()
#1  0x00007f251a5194fd in ?? () from /usr/lib/libcrypto.so.3
#2  0x00007f251a521f79 in ENGINE_init () from /usr/lib/libcrypto.so.3
#3  0x00007f251a560322 in ?? () from /usr/lib/libcrypto.so.3
#4  0x00007f2530074ab3 in SSL_CTX_new_ex () from /usr/lib/libssl.so.3
#5  0x00007f2530367227 in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#6  0x00007f2530361e12 in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#7  0x00007f25303626db in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#8  0x00007f253032c23f in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#9  0x00007f253032955c in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#10 0x00007f253032a2e5 in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#11 0x00007f253032a944 in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#12 0x00007f25302983fc in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#13 0x00007f25302cd13e in ?? () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#14 0x00007f2530296fba in SQLDriverConnectW () from /opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1
#15 0x00007f25306c8be3 in SQLDriverConnectW () from /usr/lib/libodbc.so.2
#16 0x00007f2530f80b27 in mssql::OdbcConnection::try_open(std::shared_ptr<std::vector<unsigned short, std::allocator<unsigned short> > >, int) ()
   from /home/kal/code/icone/src/no-cego/node_modules/msnodesqlv8/build/Release/sqlserverv8.node
#17 0x00007f2530f93cb5 in mssql::OpenOperation::TryInvokeOdbc() () from /home/kal/code/icone/src/no-cego/node_modules/msnodesqlv8/build/Release/sqlserverv8.node
#18 0x00007f2530f85cf8 in mssql::OdbcOperation::Execute() () from /home/kal/code/icone/src/no-cego/node_modules/msnodesqlv8/build/Release/sqlserverv8.node
#19 0x00000000013bbbf4 in worker (arg=0x0) at ../deps/uv/src/threadpool.c:122
#20 0x00007f253403f8fd in start_thread (arg=<optimized out>) at pthread_create.c:442
#21 0x00007f25340c1a60 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Any clue?

@TimelordUK
Copy link
Owner

can you provide details of what was being done

  • can you open a connection?
  • if this is on a query what was the SQL
  • what platform is this - we test on Ubuntu, Windows, Debian, MacOS (inc apple silicon), Alpine Linux

I dont have enough information from above to determine what is happening - you need ODBC installed with Sql Server Driver 2017.3+

@TimelordUK
Copy link
Owner

actually sorry i see it was on open and went down in openssl - this has been extensively doscussed in various issues and is not easy to fix - it is related to default version of openssl being used on your system not being compatible with native MS driver and is only fixable with something like a change in LD path

e.g. from home /home/me
libssl.so.1.1 -> /home/linuxbrew/.linuxbrew/opt/openssl@3/lib/libssl.so.3

LD_PRELOAD=/home/me/libssl.so.1.1

@kalstong
Copy link
Author

kalstong commented Dec 19, 2022 via email

@TimelordUK
Copy link
Owner

TimelordUK commented Dec 19, 2022

looking again at a ubunti install - if I run a node process without the LD SSL patch above it crashes and looking at the loaded libs I see below

If I run the ms sqlcmd connection tool which connects fine I see the second set of loaded libs

yet actually they are the same - they are using the same SSL / odbc / gcc runtime yet in case of node it does fail with SEGV

in last example I patch LD as above node now works and we see a new ssl running

MS command line - working no LD patch

me@me:~/dev/js/v8/node_modules/msnodesqlv8$ lsof -p 7387 | grep -i -e gcc -e stdc -e odbc -e ssl
sqlcmd  7387 me  mem    REG   8,16   598104 11601 /usr/lib/x86_64-linux-gnu/libssl.so.1.1
sqlcmd  7387 me  mem    REG   8,16   608957 68879 /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0
sqlcmd  7387 me  mem    REG   8,16  2080528  7709 /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.1.so.1.1
sqlcmd  7387 me  mem    REG   8,16   104984 12332 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
sqlcmd  7387 me  mem    REG   8,16  1956992 12642 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
sqlcmd  7387 me  mem    REG   8,16  2453791 68863 /usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0
me@me:~/dev/js/v8/node_modules/msnodesqlv8$ lsof -p 7534 | grep -i -e gcc -e stdc -e odbc -e ssl

node msnodesqlv8 no patch - looks same version loaded yet crashes

node    7534 me  mem       REG   8,16   598104 11601 /usr/lib/x86_64-linux-gnu/libssl.so.1.1
node    7534 me  mem       REG   8,16   608957 68879 /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0
node    7534 me  mem       REG   8,16  2080528  7709 /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.1.so.1.1
node    7534 me  mem       REG   8,16  2453791 68863 /usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0
node    7534 me  mem       REG   8,16   104984 12332 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
node    7534 me  mem       REG   8,16  1956992 12642 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28

this is node with patch and note new ssl - this is working

me@me:~/dev/js/v8/node_modules/msnodesqlv8$ lsof -p 7611 | grep -i -e gcc -e stdc -e odbc -e ssl
node    7611 me  mem       REG   8,16   608957  68879 /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0
node    7611 me  mem       REG   8,16  2080528   7709 /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.1.so.1.1
node    7611 me  mem       REG   8,16  2453791  68863 /usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0
node    7611 me  mem       REG   8,16  5242296 100436 /home/linuxbrew/.linuxbrew/Cellar/openssl@3/3.0.5/lib/libcrypto.so.3
node    7611 me  mem       REG   8,16   104984  12332 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
node    7611 me  mem       REG   8,16  1956992  12642 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
node    7611 me  mem       REG   8,16   807584 100439 /home/linuxbrew/.linuxbrew/Cellar/openssl@3/3.0.5/lib/libssl.so.3

@TimelordUK
Copy link
Owner

if i include crypto it still all looks same from sqlcmd that works and node - this is weirder than i thought

me@me:~/dev/js/v8/node_modules/msnodesqlv8$ lsof -p 7534 | grep -i -e gcc -e stdc -e odbc -e ssl -e crypto
node    7534 me  mem       REG   8,16  2954080 11600 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
node    7534 me  mem       REG   8,16   598104 11601 /usr/lib/x86_64-linux-gnu/libssl.so.1.1
node    7534 me  mem       REG   8,16   608957 68879 /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0
node    7534 me  mem       REG   8,16  2080528  7709 /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.1.so.1.1
node    7534 me  mem       REG   8,16  2453791 68863 /usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0
node    7534 me  mem       REG   8,16   191040 12432 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
node    7534 me  mem       REG   8,16   104984 12332 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
node    7534 me  mem       REG   8,16  1956992 12642 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
me@me:~/dev/js/v8/node_modules/msnodesqlv8$ lsof -p 7387 | grep -i -e gcc -e stdc -e odbc -e ssl -e crypto
sqlcmd  7387 me  mem    REG   8,16  2954080 11600 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
sqlcmd  7387 me  mem    REG   8,16   598104 11601 /usr/lib/x86_64-linux-gnu/libssl.so.1.1
sqlcmd  7387 me  mem    REG   8,16   191040 12432 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
sqlcmd  7387 me  mem    REG   8,16   608957 68879 /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0
sqlcmd  7387 me  mem    REG   8,16  2080528  7709 /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.1.so.1.1
sqlcmd  7387 me  mem    REG   8,16   104984 12332 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
sqlcmd  7387 me  mem    REG   8,16  1956992 12642 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
sqlcmd  7387 me  mem    REG   8,16  2453791 68863 /usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0

@ghost
Copy link

ghost commented Dec 24, 2022

I have the exact same problem under a similar environment.

> node --version; npm --version
v14.21.1
6.14.17

> uname -rm
5.15.80-1-lts x86_64

> cat /opt/microsoft/msodbcsql/etc/odbcinst.ini
[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-18.1.so.2.1

> openssl version
OpenSSL 3.0.7 1 Nov 2022 (Library: OpenSSL 3.0.7 1 Nov 2022)

I wasn't able to fix the issue by forcing a different OpenSSL version with LD_PRELOAD but I was able to bypass it using NodeJS 18, removing node_modules and running npm install.

Came across this announcement on the NodeJS blog and decided to give v18 a try. It worked. I still don't know what's causing the original problem but maybe this can help to narrow the search.

@TimelordUK
Copy link
Owner

Very interesting thanks a lot for pointing out release notes and relation to ssl

@eretztzvi
Copy link

eretztzvi commented May 29, 2023

I'm dealing with SIGSEGV problem also,

ODBC Driver: ODBC Driver 17 for SQL Server
msnodesqlv8 Version: ^4.1.0
NodeJS version: 18.16.0
NPM version: 8.15.0
uname -r: 5.4.17-2136.318.7.1.el8uek.x86_64

I'm getting Segmentation fault (core dumped) while trying to make a connection,
Does anyone know what cause this?
I've tried to remove node_modules and run npm install again and it didn't work,

Thanks!

@TimelordUK
Copy link
Owner

TimelordUK commented May 29, 2023 via email

@TimelordUK
Copy link
Owner

here on appveyor script is being run as part of install pre test for node 18 only - test suite then runs

https://ci.appveyor.com/project/TimelordUK/node-sqlserver-v8/branch/master/job/7h7u9annw75jj8lp

@TimelordUK
Copy link
Owner

log from appveyor

omputing checksum with sha256sum
[00:00:12] Checksums matched!
[00:00:16] Now using node v18.16.0 (npm v9.5.1)
[00:00:16] npm install
[00:00:22] npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[00:00:23] npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
[00:00:23] npm WARN deprecated har-validator@5.1.5: this library is no longer supported
[00:00:25] npm WARN deprecated @types/electron@1.6.10: This is a stub types definition for electron (https://github.com/electron/electron). electron provides its own type definitions, so you don't need @types/electron installed!
[00:00:29] npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
[00:00:29] npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
[00:00:30] npm WARN deprecated tslint@6.1.3: TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.
[00:00:37] 
[00:00:37] > msnodesqlv8@4.1.0 install
[00:00:37] > prebuild-install || node-gyp rebuild
[00:00:37] 
[00:00:38] 
[00:00:38] added 876 packages, and audited 877 packages in 22s
[00:00:38] 
[00:00:38] 132 packages are looking for funding
[00:00:38]   run `npm fund` for details
[00:00:38] 
[00:00:38] 8 vulnerabilities (3 moderate, 5 high)
[00:00:38] 
[00:00:38] To address issues that do not require attention, run:
[00:00:38]   npm audit fix
[00:00:38] 
[00:00:38] To address all issues (including breaking changes), run:
[00:00:38]   npm audit fix --force
[00:00:38] 
[00:00:38] Run `npm audit` for details.
[00:00:38] Starting 'services'
[00:00:38] Starting Microsoft SQL Server 2017
[00:00:39] Running "build_script" scripts
[00:00:39] node --version
[00:00:39] v18.16.0
[00:00:39] npm run build
[00:00:40] 
[00:00:40] > msnodesqlv8@4.1.0 build
[00:00:40] > tsc
[00:00:40] 
[00:00:54] chmod 775 /home/appveyor/projects/node_modules/msnodesqlv8/tool/install_openssl.sh
[00:00:55] /home/appveyor/projects/node_modules/msnodesqlv8/tool/install_openssl.sh
[00:00:55] node version 18 folder /home/appveyor/projects/node_modules/msnodesqlv8
[00:00:55] Cloning into 'openssl'...

@edanidzerda
Copy link

FWIW, I was also able to get it working with OpenSSL 3.0.2 on Ubuntu 22.04. I can also attest that the "install_openssl.sh" script to build the latest openssl 3.2 works as well.

@TimelordUK
Copy link
Owner

i have built a docker image bringing things together which works

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...

@eretztzvi
Copy link

i have built a docker image bringing things together which works

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...

I've tried to build this image but I get an error: #22 0.554 /bin/sh: 1: npm: not found
I searched a little bit and found that the version of nodejs that is installed is 12~, although you specified : RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - - the required version is 18~,
how can we fix this?

@TimelordUK
Copy link
Owner

does this 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 ACCEPT_EULA=Y
apt-get install -y nodejs
RUN ACCEPT_EULA=Y
apt-get install -y yarn
RUN useradd -ms /bin/bash apprunner
USER apprunner
RUN mkdir -p $HOME/app
RUN cd $HOME/app

Administrator in dev\docker\ubuntu-msnodesqlv8 took 16s
❯ docker run -it msnodesqlv8-ubuntu bash
apprunner@8b3b24f942f1:/$ node --version
v18.16.0
apprunner@8b3b24f942f1:/$ npm --version
9.5.1
apprunner@8b3b24f942f1:/$ yarn --version
0.32+git
apprunner@8b3b24f942f1:/$

@TimelordUK
Copy link
Owner

Dockerfile.zip

@eretztzvi
Copy link

eretztzvi commented May 30, 2023

This is what i get after building an image by your latest Dockerfile:

apprunner@cb5b1b97e500:/$ node -v
v12.22.9
apprunner@cb5b1b97e500:/$ npm -v
bash: npm: command not found
apprunner@cb5b1b97e500:/$ openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.2.0-dev )
apprunner@cb5b1b97e500:/$

Dockerfile.zip

@TimelordUK
Copy link
Owner

Dockerfile.zip

can you do a clean build and capture log with latest - are you behind a firewall is it actually installing the node18

docker build --no-cache --progress=plain . 2>&1 | tee build.log

note from log

 grep nodejs .\build.log
#10 5.128 ## Run `sudo apt-get install -y nodejs` to install Node.js 18.x and npm
#20 [17/20] RUN DEBIAN_FRONTEND=noninteractive   apt-get update   && apt-get install -y nodejs yarn
#20 4.300   cmdtest libyaml-0-2 nodejs python3-cliapp python3-importlib-metadata
#20 4.489 Get:1 https://deb.nodesource.com/node_18.x jammy/main amd64 nodejs amd64 18.16.0-deb-1nodesource1 [28.7 MB]
#20 10.33 Selecting previously unselected package nodejs.
#20 10.33 Preparing to unpack .../9-nodejs_18.16.0-deb-1nodesource1_amd64.deb ...
#20 10.34 Unpacking nodejs (18.16.0-deb-1nodesource1) ...
#20 16.81 Setting up nodejs (18.16.0-deb-1nodesource1) ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants