Deployment error

I am looking to understand why the deployments on a certain version of my app are failing. The application is Kapstan. Can someone help me with the cause of failure?

I took a look and it seems the error your getting is:

2023-11-21 15:45:58 qemu-x86_64: Could not open ‘/lib64/ld-linux-x86-64.so.2’: No such file or directory

This issue most likely comes from the image build process. If you plan to do multi-stage builds, you’ll need to be careful about ensuring all the required libraries are present on the final image you use to deploy. That is to say, if you use one image to compile your code and then copy the binary to a different one to deploy it, you’ll need to ensure the binary can run on the latter. I believe what’s happening here is you are compiling your code on an x86 (AMD) architecture and using dynamic linking. This means your compiler generates a binary that contains references to external libraries, rather than containing the libraries themselves. When you use a “deploy” image with a different architecture (such as ARM) the binary may not be able to resolve the link since the different environment may have different libraries, or simply put them under different paths.

Fixes

In order to fix this, you could either change your compilation to produce statically linked binaries, or compile unique binaries for each arch + os combination you want to deploy on. I will use Golang as an example, but this should be possible in other compiled languages as well.

Changing your binaries to be statically linked:

Set the following environment variable before running go build:

export CGO_ENABLED=0

Cross-Compiling

Set the following environment variables for the arch + os combination you want to compile for and then run go build. For example, here is how you could compile for an ARM + Linux platform:

export GOOS=linux
export GOARCH=arm

Here is a link to the docs I used for these examples, hope this helps!

6 Likes