bootleg
bootleg copied to clipboard
Binary not found after installation on Alpine linux
Hi there! Thanks for putting together this great library, and for making it available to Babashka users as a pod. I'm trying to get it set up in Docker for some lightweight documentation tasks, but I'm coming across a strange issue where I can't find the binary on Alpine linux after installing it.
Here's a Dockerfile
that reproduces the issue:
FROM alpine:3.12.0
ARG BB_VER=0.1.3
ARG BOOTLEG_VER=0.1.9
RUN apk add --no-cache wget unzip tar
RUN mkdir -p /usr/local/bin
RUN echo "Installing babashka"
RUN wget https://github.com/borkdude/babashka/releases/download/v$BB_VER/babashka-$BB_VER-linux-static-amd64.zip
RUN unzip babashka-$BB_VER-linux-static-amd64.zip -d /usr/local/bin/
#RUN bb -e '(print "babashka installed successfully.")'
RUN echo "Installing bootleg"
RUN wget https://github.com/retrogradeorbit/bootleg/releases/download/v$BOOTLEG_VER/bootleg-$BOOTLEG_VER-linux-amd64.tgz
RUN tar xvf bootleg-$BOOTLEG_VER-linux-amd64.tgz && \
mv bootleg /usr/local/bin && \
chown 0:0 root /usr/local/bin/bootleg && \
chmod +x /usr/local/bin/bootleg
RUN ls -la /usr/local/bin/
RUN /usr/local/bin/bb --version
RUN /usr/local/bin/bootleg --version
ENTRYPOINT ["bb"]
The output of the ls -la /usr/local/bin
step shows the following:
total 117636
drwxr-xr-x 1 root root 4096 Aug 24 23:30 .
drwxr-xr-x 1 root root 4096 May 29 14:20 ..
-rwxr-xr-x 1 root root 65626272 Jun 27 11:38 bb
-rwxrwxr-x 1 root root 54815784 May 27 14:13 bootleg
so it's clearly there and it's marked as executable, but attempting to execute it fails further down in the Dockerfile
.
/bin/sh: /usr/local/bin/bootleg: not found
The command '/bin/sh -c /usr/local/bin/bootleg --version' returned a non-zero code: 127
Is this because there's a runtime dependency for bootleg
or GraalVM
that the Alpine base image lacks? babashka
's static binary appears to work just fine without any additional dependencies.
Happy to provide any additional information if need be.
I just confirmed this is an Alpine issue - using debian:stable-slim
as the base image and converting the relevant apk
command to apt-get install ...
resulted in a successful build. This solves the issue for what I need to get started. If Alpine builds are not a priority for you, then please feel free to close this.
FYI: Clj-kondo and babashka publish releases that use the --static
flag which can run on Alpine. The newest GraalVM (20.2.0) offers more fine-grained static possibilities which I haven't used yet.
Step 14/16 : RUN ldd /usr/local/bin/bootleg
---> Running in a6012cf1b3f4
/lib64/ld-linux-x86-64.so.2 (0x7fb423c72000)
Error loading shared library libstdc++.so.6: No such file or directory (needed by /usr/local/bin/bootleg)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7fb423c72000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7fb423c72000)
Error relocating /usr/local/bin/bootleg: _Znam: symbol not found
Error relocating /usr/local/bin/bootleg: __strdup: symbol not found
Error relocating /usr/local/bin/bootleg: __strtok_r: symbol not found
Error relocating /usr/local/bin/bootleg: _ZdaPv: symbol not found
libz.so.1 => /lib/libz.so.1 (0x7fb41fbe6000)
librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7fb423c72000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fb423c72000)
In 2022, it's recommended to compile using musl and not use the --static
flag as a standalone option. If musl is not an option, then a "mostly static" image (everything except glibc) is also an option.
https://www.graalvm.org/22.0/reference-manual/native-image/StaticImages/