I have an alpine running container which contains some binaries in usr/local/bin
When I ls
the content of usr/local/bin
I got this output :
/usr/local/bin # ls
dwg2SVG dwg2dxf dwgadd dwgbmp dwgfilter dwggrep dwglayers dwgread dwgrewrite dwgwrite dxf2dwg dxfwrite
Which is what I expected.
However if I execute one of these binaries by calling it I got a not found
error from the shell :
/usr/local/bin # dwg2dxf
sh: dwgread: not found
/usr/local/bin # ./dwg2dxf
sh: ./dwgread: not found
I tested my $PATH
which seems to be correct :
/usr/local/bin # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
How can I make those binaries callable or "foundable" ? Did I miss something in my Dockerfile build ?
I suppose that there is something with the ldconfig
command in alpine that went wrong but I'm not sure.
EDIT
As suggested in one answer here I executed the file
command and here is the output :
/usr/local/bin # file dwg2dxf
dwgread: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=7835d4a42651a5fb7bdfa2bd8a76e40096bacb07, with debug_info, not stripped
Thoses binaries are from the LibreDWG Official repository as well as the first part of my Dockerfile. Here is the complete Dockerfile :
# podman/docker build -t libredwg .
############################
# STEP 1 build package from latest tar.xz
############################
FROM python:3.7.7-buster AS extracting
# libxml2-dev is broken so we need to compile it by our own
ARG LIBXML2VER=2.9.9
RUN apt-get update &&
apt-get install -y --no-install-recommends autoconf libtool swig texinfo
build-essential gcc libxml2 python3-libxml2 libpcre2-dev libpcre2-32-0 curl
libperl-dev libxml2-dev &&
mkdir libxmlInstall && cd libxmlInstall &&
wget ftp://xmlsoft.org/libxml2/libxml2-$LIBXML2VER.tar.gz &&
tar xf libxml2-$LIBXML2VER.tar.gz &&
cd libxml2-$LIBXML2VER/ &&
./configure &&
make &&
make install &&
cd /libxmlInstall &&
rm -rf gg libxml2-$LIBXML2VER.tar.gz libxml2-$LIBXML2VER
WORKDIR /app
RUN tarxz=`curl --silent 'https://ftp.gnu.org/gnu/libredwg/?C=M;O=D' | grep '.tar.xz<' |
head -n1|sed -E 's/.*href="([^"]+)".*/1/'`;
echo "latest release $tarxz";
curl --silent --output "$tarxz" https://ftp.gnu.org/gnu/libredwg/$tarxz &&
mkdir libredwg &&
tar -C libredwg --xz --strip-components 1 -xf "$tarxz" &&
rm "$tarxz" &&
cd libredwg &&
./configure --disable-bindings --enable-release &&
make -j `nproc` &&
mkdir install &&
make install DESTDIR="$PWD/install" &&
make check DOCKER=1 DESTDIR="$PWD/install"
############################
# STEP 2 install into stable-slim
############################
# pull official base image
FROM osgeo/gdal:alpine-normal-latest
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# copy requirements file
COPY ./requirements.txt /usr/src/app/requirements.txt
# install dependencies
RUN set -eux
&& apk add --no-cache --virtual .build-deps build-base
py3-pip libressl-dev libffi-dev gcc musl-dev python3-dev postgresql-dev
&& pip3 install --upgrade pip setuptools wheel
&& pip3 install -r /usr/src/app/requirements.txt
&& rm -rf /root/.cache/pip
# Install libredwg binaries
COPY --from=extracting /app/libredwg/install/usr/local/bin/* /usr/local/bin/
COPY --from=extracting /app/libredwg/install/usr/local/include/* /usr/local/include/
COPY --from=extracting /app/libredwg/install/usr/local/lib/* /usr/local/lib/
COPY --from=extracting /app/libredwg/install/usr/local/share/* /usr/local/share/
RUN ldconfig /usr/local/bin/
RUN ldconfig /usr/local/include/
RUN ldconfig /usr/local/lib/
RUN ldconfig /usr/local/share/
# copy project
COPY . /usr/src/app/
See Question&Answers more detail:os