slimtoolkit / slimtoolkit/slim
Cannot find module 'chalk' when running my nodejs app
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.4k
- Forks
- 840
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
After having optimized my image with docker-slim 1.26.1 I get this error running my app:
npm info it worked if it ends with ok
npm info using npm@6.7.0
npm info using node@v11.14.0
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'chalk'
npm timing npm Completed in 54ms
Which doesn't happen when running the container with the not optimized image.
Here are the logs:
docker-slim[build]: info=http.probe message='using default probe'
docker-slim[build]: state=started
docker-slim[build]: info=params target=xxxxxxxx.dkr.ecr..amazonaws.com/-test:1.1.6-25-g9b9c21a-dirty continue.mode=probe
docker-slim[build]: state=image.inspection.start
docker-slim[build]: info=image id=sha256:f624a85da22c63d9f6bf83c2fd43cc8333542264d02331419429e232a44bc93e size.bytes=624204102 size.human=624 MB
docker-slim[build]: info=image.users exe='node' all='node'
docker-slim[build]: info=image.stack index=0 name='node:11.14.0-alpine' id='sha256:cd4fae427afc1d5bfe712418c10ebde8a5c20b9d9ada74ce8d7b4df4cbb984e3'
docker-slim[build]: info=image.stack index=1 name='xxxxxxxx.dkr.ecr..amazonaws.com/-test:1.1.6-25-g9b9c21a-dirty' id='sha256:f624a85da22c63d9f6bf83c2fd43cc8333542264d02331419429e232a44bc93e'
docker-slim[build]: info=image.exposed_ports list='3000'
docker-slim[build]: state=image.inspection.done
docker-slim[build]: state=container.inspection.start
docker-slim[build]: info=container status=created name=dockerslimk_6715_20200127184511 id=16909fb535c8b6ca7dbccbf0afceb6cecda9d6a473cb153ff92b993c1aeaec49
docker-slim[build]: info=cmd.startmonitor status=sent
docker-slim[build]: info=event.startmonitor.done status=received
docker-slim[build]: info=container name=dockerslimk_6715_20200127184511 id=16909fb535c8b6ca7dbccbf0afceb6cecda9d6a473cb153ff92b993c1aeaec49 target.port.list=[32770] target.port.info=[3000/tcp => 0.0.0.0:32770] message='YOU CAN USE THESE PORTS TO INTERACT WITH THE CONTAINER'
docker-slim[build]: state=http.probe.starting message='WAIT FOR HTTP PROBE TO FINISH'
docker-slim[build]: info=continue.after mode=probe message='no input required, execution will resume when HTTP probing is completed'
docker-slim[build]: info=prompt message='waiting for the HTTP probe to finish'
docker-slim[build]: state=http.probe.running
docker-slim[build]: info=http.probe.ports count=1 targets='32770'
docker-slim[build]: info=http.probe.commands count=1 commands='GET /'
docker-slim[build]: info=http.probe.call status=error method=GET target=http://127.0.0.1:32770/ attempt=1 error='Get http://127.0.0.1:32770/: read tcp 127.0.0.1:47854->127.0.0.1:32770: read: connection reset by peer' time=2020-01-27T18:45:23Z
docker-slim[build]: info=http.probe.call status=error method=GET target=http://127.0.0.1:32770/ attempt=2 error='Get http://127.0.0.1:32770/: read tcp 127.0.0.1:47858->127.0.0.1:32770: read: connection reset by peer' time=2020-01-27T18:45:31Z
docker-slim[build]: info=http.probe.call status=error method=GET target=http://127.0.0.1:32770/ attempt=3 error='Get http://127.0.0.1:32770/: EOF' time=2020-01-27T18:45:39Z
docker-slim[build]: info=http.probe.call status=error method=GET target=http://127.0.0.1:32770/ attempt=4 error='Get http://127.0.0.1:32770/: read tcp 127.0.0.1:47868->127.0.0.1:32770: read: connection reset by peer' time=2020-01-27T18:45:55Z
docker-slim[build]: info=http.probe.call status=error method=GET target=http://127.0.0.1:32770/ attempt=5 error='Get http://127.0.0.1:32770/: read tcp 127.0.0.1:47872->127.0.0.1:32770: read: connection reset by peer' time=2020-01-27T18:46:03Z
docker-slim[build]: info=http.probe.summary total=5 failures=5 successful=0
docker-slim[build]: state=http.probe.done warning=no.successful.calls
docker-slim[build]: info=event message='HTTP probe is done'
docker-slim[build]: state=container.inspection.finishing
docker-slim[build]: state=container.inspection.artifact.processing
docker-slim[build]: state=container.inspection.done
docker-slim[build]: state=building message='building minified image'
docker-slim[build]: state=completed
docker-slim[build]: info=results status='MINIFIED BY 11.85X [624204102 (624 MB) => 52661761 (53 MB)]'
docker-slim[build]: info=results image.name=xxxxxxxx.dkr.ecr..amazonaws.com/-test.slim image.size='53 MB' data=true
docker-slim[build]: info=results artifacts.location='/home/circleci//.docker-slim-state/images/f624a85da22c63d9f6bf83c2fd43cc8333542264d02331419429e232a44bc93e/artifacts'
docker-slim[build]: info=results artifacts.report=creport.json
docker-slim[build]: info=results artifacts.dockerfile.original=Dockerfile.fat
docker-slim[build]: info=results artifacts.dockerfile.new=Dockerfile
docker-slim[build]: info=results artifacts.seccomp=xxxxxxxx.dkr.ecr..amazonaws.com--test-seccomp.json
docker-slim[build]: info=results artifacts.apparmor=xxxxxxxx.dkr.ecr..amazonaws.com-***************-test-apparmor-profile
docker-slim[build]: state=done
docker-slim[build]: info=report file='slim.report.json'
I'm building with:
docker build --build-arg NPM_TOKEN=$NPM_TOKEN -t $IMAGE .
./docker-slim build $IMAGE
Am I missing something ?
Thanks
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported Node.js module failure by comparing the original image with the Docker Slim output, using the provided build commands and HTTP probe logs. Inspect slim.report.json and the generated image artifacts to determine why chalk is absent; done means the optimized image starts the app without the MODULE_NOT_FOUND error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, node.js
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100