Repository navigation
Does not work in Docker container based on node:slim #1986
Description
Activity
Seems to work with the latest alpha version (
0.28.0-alpha.21).Tested with this Dockerfile:
FROM node:slim WORKDIR /app COPY . . RUN apt-get update && apt-get upgrade -y RUN apt-get install -y python3 libkrb5-dev gcc openssl libssh2-1-dev g++ make RUN JOBS=max npm ci ENV NODE_ENV=production CMD ["node", "main.js"]
(This installs with node v20.8.0 in the container.)
main.js:const Git = require("nodegit"); (async () => { const repo = await Git.Repository.open("/path/to/git/repo"); const index = await repo.refreshIndex(); const status = await repo.getStatusExt(); console.log("Repo status:", status); })();
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:
[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 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
console.dir(Git.__proto__, { depth: 1, showHidden: true, showProxy: true });
it should show:
Repository: [Function: Repository] { ... }somewhere in the output.
Also just noticed nodegit can't be imported as
import * as Git from "nodegit";
Then you get all the exports and functions on
Git.default. SoGit.Repository.open()becomesGit.default.Repository.open().
System information
These are about the container.
Trying to use nodegit with SvelteKit.
With e.g. the following function, dev build works perfectly fine.
For production I containerized with this Dockerfile -
and all commands succeeded, including
npm ci. But cannot read the Git repository, receiving this error message.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.
Does anyone make it in a docker container?