CraZySacX / node-jdbc

JDBC Wrapper for node.js
140 stars 106 forks source link

Has anyone managed to get a working docker image? #241

Open cory-weiner opened 6 months ago

cory-weiner commented 6 months ago

I've got this library working on my local OSX machine, but I'm struggling to get it running in a docker image.

My image file starts with an Ubuntu instance with JDK8 preinstalled. I think install node 16.15.0 and python:

FROM sgrio/java:jdk_8_ubuntu

ENV NODE_VERSION=16.15.0
RUN apt install -y curl
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version

RUN apt-get update

RUN apt-get install -y python3

WORKDIR /app

COPY package.json .

RUN npm install

COPY . .

CMD ["node", "index.js"]

The error I get:

18.62 npm ERR! code 1
18.63 npm ERR! path /app/node_modules/java
18.63 npm ERR! command failed
18.63 npm ERR! command sh -c node-gyp rebuild
18.63 npm ERR! 
18.63 npm ERR! gyp info it worked if it ends with ok
18.63 npm ERR! gyp info using node-gyp@10.0.1
18.63 npm ERR! gyp info using node@16.15.0 | linux | x64
18.63 npm ERR! gyp info find Python using Python version 3.6.9 found at "/usr/bin/python3"
18.63 npm ERR! gyp http GET https://nodejs.org/download/release/v16.15.0/node-v16.15.0-headers.tar.gz
18.63 npm ERR! gyp http 200 https://nodejs.org/download/release/v16.15.0/node-v16.15.0-headers.tar.gz
18.63 npm ERR! gyp http GET https://nodejs.org/download/release/v16.15.0/SHASUMS256.txt
18.63 npm ERR! gyp http 200 https://nodejs.org/download/release/v16.15.0/SHASUMS256.txt
18.63 npm ERR! gyp info spawn /usr/bin/python3
18.63 npm ERR! gyp info spawn args [
18.63 npm ERR! gyp info spawn args '/app/node_modules/node-gyp/gyp/gyp_main.py',
18.63 npm ERR! gyp info spawn args 'binding.gyp',
18.63 npm ERR! gyp info spawn args '-f',
18.63 npm ERR! gyp info spawn args 'make',
18.63 npm ERR! gyp info spawn args '-I',
18.63 npm ERR! gyp info spawn args '/app/node_modules/java/build/config.gypi',
18.63 npm ERR! gyp info spawn args '-I',
18.63 npm ERR! gyp info spawn args '/app/node_modules/node-gyp/addon.gypi',
18.63 npm ERR! gyp info spawn args '-I',
18.63 npm ERR! gyp info spawn args '/root/.cache/node-gyp/16.15.0/include/node/common.gypi',
18.63 npm ERR! gyp info spawn args '-Dlibrary=shared_library',
18.63 npm ERR! gyp info spawn args '-Dvisibility=default',
18.63 npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/16.15.0',
18.63 npm ERR! gyp info spawn args '-Dnode_gyp_dir=/app/node_modules/node-gyp',
18.63 npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/16.15.0/<(target_arch)/node.lib',
18.63 npm ERR! gyp info spawn args '-Dmodule_root_dir=/app/node_modules/java',
18.63 npm ERR! gyp info spawn args '-Dnode_engine=v8',
18.63 npm ERR! gyp info spawn args '--depth=.',
18.63 npm ERR! gyp info spawn args '--no-parallel',
18.63 npm ERR! gyp info spawn args '--generator-output',
18.63 npm ERR! gyp info spawn args 'build',
18.63 npm ERR! gyp info spawn args '-Goutput_dir=.'
18.63 npm ERR! gyp info spawn args ]
18.63 npm ERR! gyp ERR! build error 
18.63 npm ERR! gyp ERR! stack Error: not found: make
18.63 npm ERR! gyp ERR! stack at getNotFoundError (/app/node_modules/node-gyp/node_modules/which/lib/index.js:16:17)
18.63 npm ERR! gyp ERR! stack at which (/app/node_modules/node-gyp/node_modules/which/lib/index.js:77:9)
18.63 npm ERR! gyp ERR! stack at async doWhich (/app/node_modules/node-gyp/lib/build.js:112:22)
18.63 npm ERR! gyp ERR! stack at async loadConfigGypi (/app/node_modules/node-gyp/lib/build.js:77:7)
18.64 npm ERR! gyp ERR! stack at async build (/app/node_modules/node-gyp/lib/build.js:35:3)
18.64 npm ERR! gyp ERR! stack at async run (/app/node_modules/node-gyp/bin/node-gyp.js:81:18)
18.64 npm ERR! gyp ERR! System Linux 6.3.13-linuxkit
18.64 npm ERR! gyp ERR! command "/root/.nvm/versions/node/v16.15.0/bin/node" "/app/node_modules/.bin/node-gyp" "rebuild"
18.64 npm ERR! gyp ERR! cwd /app/node_modules/java
18.64 npm ERR! gyp ERR! node -v v16.15.0
18.64 npm ERR! gyp ERR! node-gyp -v v10.0.1
18.64 npm ERR! gyp ERR! not ok
18.64 
18.64 npm ERR! A complete log of this run can be found in:
18.64 npm ERR!     /root/.npm/_logs/2024-03-06T19_50_50_009Z-debug-0.log
davidmroth commented 5 months ago

Try this and tweak to your specific use case:

FROM node:16-buster as builder

WORKDIR /app

# Fix JVM libjvm.so not found
ENV LD_LIBRARY_PATH=/usr/lib/jvm/java-11-openjdk-amd64/lib/server

RUN apt-get update
RUN apt-get install make g++ python3 default-jdk -y
RUN ln -sf /usr/bin/python3 /usr/bin/python

ENV PYTHON /usr/bin/python3

# Installing dependencies
COPY package*.json /app
RUN yarn install

# Copying source files
COPY . /app

RUN yarn build

ENV PORT 3000
EXPOSE 3000

CMD ["yarn", "start:prod"]