Docker Image Size Doubled After Switching to aws-iot-device-sdk-v2 #525
-
Hi everyone, I'm encountering an issue with my Docker image size after migrating from As you can see in the attached image, after installing only the production dependencies, the largest package by far is aws-crt, which is a dependency of aws-iot-device-sdk-v2. This package alone seems to contribute significantly to the overall size of the Docker image. I'm reaching out to the community to ask if there are any optimizations or best practices that could help reduce the Docker image size when using aws-iot-device-sdk-v2. Any insights or suggestions would be greatly appreciated! Thanks in advance for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You can reduce the size of the binaries by building this sdk and the crt yourself. This is a potentially complicated workaround as you will have to maintain the build process yourself to include any updates. This would include building the CRT c libraries for your target platform. Then while building aws-iot-device-sdk-js-v2 you will need to make sure it points at the CRT binaries that you previously built. |
Beta Was this translation helpful? Give feedback.
-
We are looking into the best way to approach this for size-conscious users. Building the CRT yourself is one option, but after some additional discussion, it may be easier to instead delete all the un-needed native binaries after you've fully built your application, right before you package it up. If you look in |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
We are looking into the best way to approach this for size-conscious users. Building the CRT yourself is one option, but after some additional discussion, it may be easier to instead delete all the un-needed native binaries after you've fully built your application, right before you package it up.
If you look in
node_modules/aws-crt/dist/bin
you'll see folders for each supported platform-arch combo. Deleting unneeded folders (based on your final runtime host) will save 1-4MB each, depending on the platform.