You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Does not work in Docker container based on node:slim #1986
For production I containerized with this Dockerfile -
FROM node:slim
WORKDIR /app
COPY . .
RUN RUN apt-get install -y python3 libkrb5-dev gcc openssl libssh2-1-dev g++ make
RUN npm ci
RUN npm run build
ENV NODE_ENV=production
EXPOSE 3000
CMD ["node", "build/index.js"]
and all commands succeeded, including npm ci. But cannot read the Git repository, receiving this error message.
"err":{"type":"TypeError","message":"Cannot read properties of undefined (reading 'open')","stack":"TypeError: Cannot read properties of undefined (reading 'open')\n at addAndCommit (file:///carbon/build/server/chunks/git-7c944c50.js:6:37)\n at POST (file:///carbon/build/server/chunks/_server.ts-8d43896a.js:47:15)\n at async render_endpoint (file:///carbon/build/server/index.js:1570:20)\n at async resolve (file:///carbon/build/server/index.js:3942:22)\n at async respond (file:///carbon/build/server/index.js:3831:22)\n at async Array.ssr (file:///carbon/build/handler.js:1221:3)"}
I may miss some packages to make nodegit work inside docker container, but since we do not have any official documentation about including this library in the container I'm not sure.
When executed in the docker container this throws an exception since the repository we try to open does not exist in the container:
[Error: failed to resolve path '/path/to/git/repo': No such file or directory] {
errno: -3,
errorFunction: 'Repository.open'
}
But just tried with nodegit@0.27.0 and seems to work just fine, same error Error: failed to resolve path ....
Also did a quick test with ESM modules (setting "type": "module" in package.json and changing the import to import Git from "nodegit";). This also seems to work fine.
Could it be different node versions on the host and container resulting in slightly different module resolutions or something similar? Or try re-downloading the container (think it is docker build --no-cache --pull) and add RUN apt-get update && apt-get upgrade -y to the Dockerfile.
I vaguely recall some similar behavior on MacOS (maybe?) where some functions where missing on the "Git" object (nodegit import). That might have been something with nodegit being built against a different version of openssl resulting in some things working and others didn't. But don̈́t quite remember..
Don't know if it can help somehow but if you execute
Activity
weedz commentedon Oct 3, 2023
Seems to work with the latest alpha version (
0.28.0-alpha.21).Tested with this Dockerfile:
(This installs with node v20.8.0 in the container.)
main.js:package.json:{ "name": "nodegit-test", "version": "1.0.0", "description": "", "main": "main.js", "scripts": { "podman:build": "podman build . --tag nodegit-test", "podman:run": "podman run -t nodegit-test" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "nodegit": "0.28.0-alpha.21" } }When executed in the docker container this throws an exception since the repository we try to open does not exist in the container:
But just tried with nodegit@0.27.0 and seems to work just fine, same error
Error: failed to resolve path ....Also did a quick test with ESM modules (setting
"type": "module"in package.json and changing the import toimport Git from "nodegit";). This also seems to work fine.Could it be different node versions on the host and container resulting in slightly different module resolutions or something similar? Or try re-downloading the container (think it is
docker build --no-cache --pull) and addRUN apt-get update && apt-get upgrade -yto the Dockerfile.I vaguely recall some similar behavior on MacOS (maybe?) where some functions where missing on the "Git" object (nodegit import). That might have been something with nodegit being built against a different version of openssl resulting in some things working and others didn't. But don̈́t quite remember..
Don't know if it can help somehow but if you execute
it should show:
somewhere in the output.
weedz commentedon Oct 3, 2023
Also just noticed nodegit can't be imported as
Then you get all the exports and functions on
Git.default. SoGit.Repository.open()becomesGit.default.Repository.open().