Here is my docker image
FROM node:8-alpine
ADD oracle-instantclient*.rpm /tmp/
COPY . /app
WORKDIR /app
RUN npm install --production --no-optional
ENV LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib/
CMD ["node", "."]
I am getting error
1540183793466 Registered plugin: #axway/api-builder-plugin-fn-swagger
Failed to load connector sub directory module; skipping it:
Error: NJS-045: cannot load the oracledb add-on binary for Node.js 8.11.2 (linux, x64)
Node.js require() error was:
DPI-1047: 64-bit Oracle Client library cannot be loaded: "Error loading shared library libclntsh.so: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
Node.js require() mapped to /app/node_modules/#axway/api-builder-plugin-dc-oracle/node_modules/oracledb/build/Release/oracledb.node
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
at Object. (/app/node_modules/#axway/api-builder-plugin-dc-oracle/node_modules/oracledb/lib/oracledb.js:65:13)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/app/node_modules/#axway/api-builder-plugin-dc-oracle/node_modules/oracledb/index.js:1:80)
at Module._compile (module.js:652:30)
Failed to load connector sub directory module; skipping it:
Adding the .rpm to your image is not sufficient to install the Oracle client.
You need to install it through a package manager.
That might not be easy, since you are using node:8-alpine as a base image.
I would suggest using the normal node image and installing the Oracle instantclient like so in your image:
FROM node:8
ADD oracle-instantclient*.rpm /tmp/
RUN yum -y install /tmp/oracle-instantclient*.rpm && \
rm -rf /var/cache/yum && \
rm -f /tmp/oracle-instantclient*.rpm && \
echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient12.2.conf && \
ldconfig
ENV PATH=$PATH:/usr/lib/oracle/12.2/client64/bin
COPY . /app
WORKDIR /app
RUN npm install --production --no-optional
CMD ["node", "."]
For reference check here
Related
I'm trying to dockerize Nuxt 3 app, but I have strange issue.
This Dockerfile is working with this docker run command:
docker run -v /Users/my_name/developer/nuxt-app:/app -it -p 3000:3000 nuxt-app
# Dockerfile
FROM node:16-alpine3.14
# create destination directory
RUN mkdir -p /usr/src/nuxt-app
WORKDIR /usr/src/nuxt-app
# update and install dependency
RUN apk update && apk upgrade
RUN apk add git
# copy the app, note .dockerignore
COPY . /usr/src/nuxt-app/
RUN npm install
# RUN npm run build
EXPOSE 3000
# ENV NUXT_HOST=0.0.0.0
# ENV NUXT_PORT=3000
CMD [ "npm", "run", "dev"]
I don't understand why despite mounting it to /app folder in the container and declaring /usr/src/nuxt-app in Dockerfile it works.
When I try to match them then I get this error:
ERROR (node:18) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 3) 20:09:42
(Use `node --trace-warnings ...` to show where the warning was created)
✔ Nitro built in 571 ms nitro 20:09:43
ERROR [unhandledRejection]
You installed esbuild for another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.
Specifically the "#esbuild/darwin-arm64" package is present but this platform
needs the "#esbuild/linux-arm64" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.
If you are installing with npm, you can try not copying the "node_modules"
directory when you copy the files over, and running "npm ci" or "npm install"
on the destination platform after the copy. Or you could consider using yarn
instead of npm which has built-in support for installing a package on multiple
platforms simultaneously.
If you are installing with yarn, you can try listing both this platform and the
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.
Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.
at generateBinPath (node_modules/vite/node_modules/esbuild/lib/main.js:1841:17)
at esbuildCommandAndArgs (node_modules/vite/node_modules/esbuild/lib/main.js:1922:33)
at ensureServiceIsRunning (node_modules/vite/node_modules/esbuild/lib/main.js:2087:25)
at build (node_modules/vite/node_modules/esbuild/lib/main.js:1978:26)
at runOptimizeDeps (node_modules/vite/dist/node/chunks/dep-3007b26d.js:42941:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
I have absolutely no clue what is going on here except architecture mismatch (that doesn't seem to be the case with working version - I'm on MacBook Air M1).
The second issue is that mounting doesn't update the page.
Okay, found the way. The issue was with Vite because HMR module is using port 24678 and I didn't expose it so it couldn't reload the page. This is how it should be looking:
docker run --rm -it \
-v /path/to/your/app/locally:/usr/src/app \
-p 3000:3000 \
-p 24678:24678 \
nuxt-app
Dockerfile
FROM node:lts-slim
WORKDIR /usr/src/app
CMD ["sh", "-c", "npm install && npm run dev"]
I have an extremely simple Docker app that uses json-server as a fake backend, but I can't get it to work for some bizarre reason. Here's the Docker file:
The directory I'm building this in contains a Dockerfile, server.js, and db.json.
FROM node:latest
RUN npm install json-server -g
WORKDIR /app
ADD . /app
EXPOSE 3004
CMD ["node", "server.js"]
The json-server itself is dead simple:
const jsonServer = require('json-server')
const server = jsonServer.create()
const router = jsonServer.router('db.json')
const middlewares = jsonServer.defaults()
server.use(middlewares)
server.use(router)
server.listen(3004, () => {
console.log('JSON Server is running')
})
Docker is able to build this image. But when I try to run it, I get the following error:
node:internal/modules/cjs/loader:1042
throw err;
^
Error: Cannot find module 'json-server'
Require stack:
- /app/server.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
at Module._load (node:internal/modules/cjs/loader:885:27)
at Module.require (node:internal/modules/cjs/loader:1105:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/app/server.js:1:20)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/server.js' ]
}
Why can't it find the json-server module, especially when I just installed it globally? I'm so confused by this since it couldn't be simpler.
The node image doesn't set the NODE_PATH environment variable, so node can't find globally installed modules.
Since containers are only meant to run a single process, it doesn't really make sense to install things globally.
If you install the module non-globally in your /app directory, it works:
FROM node:latest
WORKDIR /app
RUN npm install json-server
ADD . /app
EXPOSE 3004
CMD ["node", "server.js"]
I am getting the following exception while trying to dockerize my python project, this is my docker file.
RUN mkdir /app
WORKDIR /app
ADD requirements.txt /app
ADD main.py /app
RUN pip3 install -r requirements.txt
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
One fix around is to use posix but how do I solve it in python.
Failed to deploy '<unknown> Dockerfile: Dockerfile': group id '192360288' is too big
( > 2097151 ).
Use STAR or POSIX extensions to overcome this limit
I'm trying to set up a hot-reload enabled dev server for vue on Docker, however, there seems to be some issue with the quasar dependency.
Here is my Dockerfile:
FROM node:14.5.0-alpine3.12
WORKDIR /app
COPY package*.json ./
RUN npm install -g #vue/cli \
&& npm install -g #quasar/cli \
&& npm install
EXPOSE 8080
CMD ["npm", "run", "serve"]
I build and run the image by:
docker image build -t test .
docker container run -it -p 8080:8080 -v $pwd:/app test
But then, the error shows up:
ERROR TypeError: Cannot read property 'quasar' of undefined
TypeError: Cannot read property 'quasar' of undefined
at module.exports (/app/node_modules/vue-cli-plugin-quasar/index.js:13:29)
at /app/node_modules/#vue/cli-service/lib/Service.js:78:7
at Array.forEach (<anonymous>)
at Service.init (/app/node_modules/#vue/cli-service/lib/Service.js:76:18)
at Service.run (/app/node_modules/#vue/cli-service/lib/Service.js:215:10)
at Object.<anonymous> (/app/node_modules/#vue/cli-service/bin/vue-cli-service.js:36:9)
at Module._compile (internal/modules/cjs/loader.js:1201:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
at Module.load (internal/modules/cjs/loader.js:1050:32)
at Function.Module._load (internal/modules/cjs/loader.js:938:14)
I also tried to use yarn, but the same result occurred.
Getting Error: EACCES: permission denied, open '/usr/local/lib/node_modules when trying to install a global module in docker:
FROM node:latest
RUN mkdir -p /code
RUN npm i -g npm
WORKDIR /code
RUN npm set progress=false && npm install -g exp
There is no information about it in the official docs for node or in https://forums.docker.com/
Npm does not allow running as root by default for security reasons. When you run npm as root (this is the default user in Docker build) and install a global package, npm installs and executes binaries as user nobody instead, who doesn't have any permissions.
You can avoid this by adding the --unsafe-perm flag:
RUN npm install --global --unsafe-perm exp
or by setting the global user explicitly to root:
RUN npm --global config set user root && \
npm --global install exp
source
or by switching to a non-root USER during docker build. Be aware that this will affect ownership of files in your container.
The USER instruction sets the user name (or UID) and optionally the user group (or GID) to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile.
Per the current docker-node documentation, you can set the location of the global npm dependencies to a user-writeable location by adding these lines to the Dockerfile:
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
# optionally if you want to run npm global bin without specifying path
ENV PATH=$PATH:/home/node/.npm-global/bin
This is an issue between npm and exp module. You can install the module using yarn instead
MODULE 72: Module._load REQUEST path parent: /usr/local/lib/node_modules/exp/node_modules/decompress-zip/lib/file-details.js
MODULE 72: load native module path
ngrok - error unpacking binary { Error: EACCES: permission denied, open '/usr/local/lib/node_modules/exp/node_modules/#expo/ngrok/bin/ngrok'
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/usr/local/lib/node_modules/exp/node_modules/#expo/ngrok/bin/ngrok' }
npm info lifecycle #expo/ngrok#2.2.8~postinstall: Failed to exec postinstall script
npm WARN react-redux#5.0.6 requires a peer of react#^0.14.0 || ^15.0.0-0 || ^16.0.0-0 but none was installed.
MODULE 38: Module._load REQUEST os parent: /usr/local/lib/node_modules/npm/lib/utils/error-handler.js
MODULE 38: load native module os
But you can install it using yarn
$ yarn global add exp
See below issue for more detail
https://github.com/expo/exp/issues/59
You can try login as node or root user before install command, add USER before RUN command:
USER node
or
USER root