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

Can't run image. #694

Open
smarttang opened this issue Jun 21, 2024 · 5 comments
Open

Can't run image. #694

smarttang opened this issue Jun 21, 2024 · 5 comments

Comments

@smarttang
Copy link

Expected Behavior

➜ ~ slim build --target ghcr.io/cyclonedx/cdxgen:latest --tag ghcr.io/cyclonedx/cdxgen:slims --http-probe=true
cmd=build info=param.http.probe message='using default probe'
cmd=build state=started
cmd=build info=params tags='ghcr.io/cyclonedx/cdxgen:slims' image-build-engine='internal' target.type='image' target.image='ghcr.io/cyclonedx/cdxgen:latest' continue.mode='probe' rt.as.user='true' keep.perms='true'
cmd=build state=image.inspection.start
cmd=build info=image id='sha256:0341e32d89418b307daebea66eae33cccb53c2a27b9ecf7cbde9594d11556707' size.bytes='8155766825' size.human='8.2 GB'
cmd=build info=image.stack index='0' name='ghcr.io/cyclonedx/cdxgen:latest' id='sha256:0341e32d89418b307daebea66eae33cccb53c2a27b9ecf7cbde9594d11556707'
cmd=build state=image.inspection.done
cmd=build state=container.inspection.start
cmd=build info=container name='slimk_40961_20240621142124' id='b54f73d53717f8f6a0bacc1b8e76d320f527da2cc9413ff3c47f71f1cdba5bcb' status='created'
cmd=build info=container status='running' name='slimk_40961_20240621142124' id='b54f73d53717f8f6a0bacc1b8e76d320f527da2cc9413ff3c47f71f1cdba5bcb'
cmd=build info=container message='obtained IP address' ip='172.17.0.3'
cmd=build info=cmd.startmonitor status='sent'
cmd=build info=event.startmonitor.done status='received'
cmd=build info=container name='slimk_40961_20240621142124' id='b54f73d53717f8f6a0bacc1b8e76d320f527da2cc9413ff3c47f71f1cdba5bcb' target.port.list='' target.port.info='' message='YOU CAN USE THESE PORTS TO INTERACT WITH THE CONTAINER'
cmd=build state=http.probe.error error="NO EXPOSED PORTS" message="expose your service port with --expose or disable HTTP probing with --http-probe=false if your containerized application doesnt expose any network services"
cmd=build state=exited code=33554435
cmd=build info=container.inspector.cleanup name='slimk_40961_20240621142124' id='b54f73d53717f8f6a0bacc1b8e76d320f527da2cc9413ff3c47f71f1cdba5bcb'
cmd=build state=container.target.shutdown.start
cmd=build state=container.target.shutdown.done
cmd=build info=report file='slim.report.json'
cmd=build info=exit code='33554435' version='darwin/arm64|Transformer|1.40.11|latest|latest' location='/opt/homebrew/bin'
app='slim' message='GitHub Discussions' info='https://github.com/slimtoolkit/slim/discussions'
app='slim' message='Join the CNCF Slack channel to ask questions or to share your feedback' info='https://cloud-native.slack.com/archives/C059QP1RH1S'
app='slim' message='Join the Discord server to ask questions or to share your feedback' info='https://discord.gg/9tDyxYS'
app='slim' message='Join the Gitter channel to ask questions or to share your feedback' info='https://gitter.im/docker-slim/community'


Actual Behavior

➜ ~ docker run --rm -v /tmp:/tmp -p 9090:9090 -v $(pwd):/app:rw -t ghcr.io/cyclonedx/cdxgen:slims -r /app --server --server-host 0.0.0.0
node:internal/modules/cjs/loader:1186
const err = new Error(message);
^

Error: Cannot find module 'node-gyp/bin/node-gyp.js'
Require stack:

  • /opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/run-script/lib/make-spawn-args.js
  • /opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/run-script/lib/run-script-pkg.js
  • /opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/run-script/lib/run-script.js
  • /opt/cdxgen/node_modules/.pnpm/[email protected]/node_modules/pacote/lib/dir.js
  • /opt/cdxgen/node_modules/.pnpm/[email protected]/node_modules/pacote/lib/git.js
  • /opt/cdxgen/node_modules/.pnpm/[email protected]/node_modules/pacote/lib/fetcher.js
  • /opt/cdxgen/node_modules/.pnpm/[email protected]/node_modules/pacote/lib/index.js
  • /opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/metavuln-calculator/lib/index.js
  • /opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/arborist/lib/audit-report.js
  • /opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/arborist/lib/arborist/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1186:15)
    at Function.resolve (node:internal/modules/helpers:133:19)
    at Object. (/opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/run-script/lib/make-spawn-args.js:4:37)
    at Module._compile (node:internal/modules/cjs/loader:1434:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
    at Module.load (node:internal/modules/cjs/loader:1249:32)
    at Module._load (node:internal/modules/cjs/loader:1065:12)
    at Module.require (node:internal/modules/cjs/loader:1271:19)
    at require (node:internal/modules/helpers:123:16)
    at Object. (/opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/run-script/lib/run-script-pkg.js:1:23) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/run-script/lib/make-spawn-args.js',
    '/opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/run-script/lib/run-script-pkg.js',
    '/opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/run-script/lib/run-script.js',
    '/opt/cdxgen/node_modules/.pnpm/[email protected]/node_modules/pacote/lib/dir.js',
    '/opt/cdxgen/node_modules/.pnpm/[email protected]/node_modules/pacote/lib/git.js',
    '/opt/cdxgen/node_modules/.pnpm/[email protected]/node_modules/pacote/lib/fetcher.js',
    '/opt/cdxgen/node_modules/.pnpm/[email protected]/node_modules/pacote/lib/index.js',
    '/opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/metavuln-calculator/lib/index.js',
    '/opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/arborist/lib/audit-report.js',
    '/opt/cdxgen/node_modules/.pnpm/@[email protected]/node_modules/@npmcli/arborist/lib/arborist/index.js'
    ]
    }

Node.js v22.2.0


Steps to Reproduce the Problem


Specifications

  • Version:
  • Platform:
@kcq
Copy link
Member

kcq commented Jun 21, 2024

Thanks for sharing the extra context and the container image info @smarttang ! This will make it easier to reproduce. It'll be great to have a minified CDX Gen image.

@smarttang
Copy link
Author

You're welcome. I hope this can be handled. We currently have actual scenarios, such as Java images, which are basically up to 20GB. We hope to use tools to reduce the size of container images. For example, the Jar package we currently build based on the Java Spring boot image is very large, and the cost of each build is extremely high. If the tool can provide assistance, it will be of great help to us.

@kcq
Copy link
Member

kcq commented Jun 23, 2024

The current failure is due to missing port info, but it's likely there's more to configure (investigating...).

The Java use cases sound interesting... I'm sure we'll be able to come up with something

@kcq
Copy link
Member

kcq commented Jun 24, 2024

@smarttang here's a minified version that i tested with github repos and container images: mintoolkit/cdxgen.slim

Here's an example of how I run it (I also mounted the Docker socket, so cdxgen can handle container scanning requests): docker run --init --name cdxgen-slim --rm -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp -p 9090:9090 -v $(pwd):/app:rw -t mintoolkit/cdxgen.slim -r /app --server --server-host 0.0.0.0

Here are the curl calls I used for testing:

  • curl http://localhost:9090/health
  • curl "http://localhost:9090/sbom?url=https://github.com/HooliCorp/vulnerable-aws-koa-app.git&multiProject=true&type=js"
  • curl "http://127.0.0.1:9090/sbom?url=https://github.com/kcq/cloud-native-rejekts-2023.git&multiProject=true&type=js"
  • curl "http://localhost:9090/sbom?url=mintoolkit/cncf-securitycon-app&multiProject=true&type=docker"

Do you mind running more tests with this minified cdxgen image to make sure I'm not missing anything there?

@smarttang
Copy link
Author

@smarttang here's a minified version that i tested with github repos and container images: mintoolkit/cdxgen.slim

Here's an example of how I run it (I also mounted the Docker socket, so cdxgen can handle container scanning requests): docker run --init --name cdxgen-slim --rm -v /var/run/docker.sock:/var/run/docker.sock -v /tmp:/tmp -p 9090:9090 -v $(pwd):/app:rw -t mintoolkit/cdxgen.slim -r /app --server --server-host 0.0.0.0

Here are the curl calls I used for testing:

  • curl http://localhost:9090/health
  • curl "http://localhost:9090/sbom?url=https://github.com/HooliCorp/vulnerable-aws-koa-app.git&multiProject=true&type=js"
  • curl "http://127.0.0.1:9090/sbom?url=https://github.com/kcq/cloud-native-rejekts-2023.git&multiProject=true&type=js"
  • curl "http://localhost:9090/sbom?url=mintoolkit/cncf-securitycon-app&multiProject=true&type=docker"

Do you mind running more tests with this minified cdxgen image to make sure I'm not missing anything there?

ok, I'm try again. thx

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

2 participants