1

while i'm not really into Docker i'm struggling with an issue of a not found file. I've added a ls command to show if the file is really there. and sometimes it is, and sometimes it isn't, but always the 'file is missing' error occurs.

I'm running Docker Desktop Community V 2.0.0.3 (31259) on Win10-2004

It went wrong when a library is build:

Dockerfile:

ADD ./build_opus.sh /usr/local/sbin/

#added for debugging
RUN cd /usr/local/sbin && ls

RUN IFS=" " &&
for arch in $TARGET_ARCHS;
do
./build_opus.sh ${arch};
done

ouput:

---> Using cache 
---> 4ddfdc31b266 Step 28/40 : ADD ./build_opus.sh /usr/local/sbin/ 
---> Using cache ---> e4c4ac7fea69 
Step 29/40 : RUN cd /usr/local/sbin && ls 
---> Using cache 
---> 6fda1595d295 Step 30/40 : RUN IFS=" " && for arch in $TARGET_ARCHS; do .usr/local/sbin/build_opus.sh ${arch}; done 
---> Running in 2fcf560d0dbc 
/bin/sh: 1: .usr/local/sbin/build_opus.sh: not found 
/bin/sh: 1: .usr/local/sbin/build_opus.sh: not found 
/bin/sh: 1: .usr/local/sbin/build_opus.sh: not found 
/bin/sh: 1: .usr/local/sbin/build_opus.sh: not found 
The command '/bin/sh -c IFS=" " && for arch in $TARGET_ARCHS; do .usr/local/sbin/build_opus.sh ${arch}; done' returned a non-zero code: 127

Does anyone have an idea?

EDIT: ADDED FULL DOCKER FILE

Full Docker file:

    FROM ubuntu:latest

##############################
# Download dependencies
##############################

RUN dpkg --add-architecture i386 && \
    apt-get -y upgrade && \
    apt-get -y dist-upgrade && \
    apt-get update

RUN DEBIAN_FRONTEND=noninteractive apt-get -y install \
    software-properties-common git curl bzip2 gcc g++ binutils make autoconf openssl \
    libssl-dev ant libopus0 libpcre3 libpcre3-dev build-essential nasm libc6:i386 libstdc++6:i386 zlib1g:i386 \
    openjdk-8-jdk unzip

##############################
# Configuration
##############################

# ENV TARGET_ARCHS "armeabi armeabi-v7a x86 mips arm64-v8a x86_64 mips64"
ENV TARGET_ARCHS "armeabi-v7a x86 arm64-v8a x86_64" 
ENV ANDROID_NDK_DOWNLOAD_URL "https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip"
ENV ANDROID_SDK_DOWNLOAD_URL "https://dl.google.com/android/repository/tools_r25.2.5-linux.zip"
ENV ANDROID_SETUP_APIS "23 25"
ENV ANDROID_BUILD_TOOLS_VERSION 25
ENV ANDROID_TARGET_API 23

#ENV PJSIP_DOWNLOAD_URL "http://www.pjsip.org/release/2.7.1/pjproject-2.7.1.tar.bz2"
ENV PJSIP_DOWNLOAD_URL "https://github.com/pjsip/pjproject/archive/2.9.tar.gz"



ENV SWIG_DOWNLOAD_URL "http://prdownloads.sourceforge.net/swig/swig-3.0.7.tar.gz"

ENV OPENSSL_DOWNLOAD_URL "https://www.openssl.org/source/openssl-1.0.2g.tar.gz"

ENV OPENH264_DOWNLOAD_URL "https://github.com/cisco/openh264/archive/v1.7.0.tar.gz"
ENV OPENH264_TARGET_NDK_LEVEL 23

ENV OPUS_DOWNLOAD_URL "http://downloads.xiph.org/releases/opus/opus-1.2.1.tar.gz"
ENV OPUS_ANDROID_MK_DOWNLOAD_URL "https://trac.pjsip.org/repos/raw-attachment/ticket/1904/Android.mk"

ENV PATH /sources/android_ndk:$PATH

##############################
# Download sources
##############################

RUN mkdir -p /sources/android_ndk && \
    mkdir -p /sources/android_sdk && \
    mkdir -p /sources/pjsip && \
    mkdir -p /sources/swig && \
    mkdir -p /sources/openssl && \
    mkdir -p /sources/opus && \
    mkdir -p /sources/openh264

# Download Android NDK
RUN cd /sources/android_ndk && \
    curl -L -# -o ndk.zip "$ANDROID_NDK_DOWNLOAD_URL" && \
    unzip ndk.zip && \
    rm -rf ndk.zip && \
    mv android-*/* ./

# Download Android SDK & APIs
RUN cd /sources/android_sdk && \
    curl -L -# -o sdk.zip "$ANDROID_SDK_DOWNLOAD_URL" && \
    unzip sdk.zip

RUN cd /sources/android_sdk/tools && \
    ALL_SDK=$(./android list sdk --all) && \
    IFS=" " && \
    for api in $ANDROID_SETUP_APIS; \
    do \
      PACKAGE=$(echo "${ALL_SDK}" | grep "API ${api}" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1); \
      echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force; \
    done && \
    PACKAGE=$(echo "${ALL_SDK}" | grep "Android SDK Platform-tools" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1) && \
    echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force && \
    PACKAGE=$(echo "${ALL_SDK}" | grep "Build-tools" | grep "${BUILD_TOOLS_VERSION}" | head -n 1 | awk '{print $1}' | cut -d'-' -f 1) && \
    echo yes | ./android update sdk --all --filter ${PACKAGE} --no-ui --force

# Download Pjsip
RUN cd /sources/pjsip && \
    curl -L -# -o pjsip.tar.gz "$PJSIP_DOWNLOAD_URL" && \
    tar xzvf pjsip.tar.gz && \
    rm -rf pjsip.tar.gz && \
    mv pjproject-*/* ./

# Download Swig
RUN cd /sources/swig && \
    curl -L -# -o swig.tar.gz "$SWIG_DOWNLOAD_URL" && \
    tar xzf swig.tar.gz && \
    rm -rf swig.tar.gz && \
    mv swig-*/* ./

# Download OpenSSL
RUN cd /sources/openssl && \
    curl -L -# -o openssl.tar.gz "$OPENSSL_DOWNLOAD_URL" && \
    tar xzf openssl.tar.gz && \
    rm -rf openssl.tar.gz && \
    mv openssl-*/* ./

# Download Opus
RUN cd /sources/opus && \
    curl -L -# -o opus.tar.gz "$OPUS_DOWNLOAD_URL" && \
    tar xzf opus.tar.gz && \
    rm -rf opus.tar.gz && \
    mv opus-*/* ./ && \
    mkdir ./jni && \
    cd ./jni && \
    curl -L -# -o Android.mk "$OPUS_ANDROID_MK_DOWNLOAD_URL"

# Download OpenH264
RUN cd /sources/openh264 && \
    curl -L -# -o openh264.tar.gz "$OPENH264_DOWNLOAD_URL" && \
    tar xzf openh264.tar.gz && \
    rm -rf openh264.tar.gz && \
    mv openh264-*/* ./

##############################
# Build swig, openssl, opus, openh264
##############################

RUN mkdir -p /output/openssl/ && \
    mkdir -p /output/openh264/ && \
    mkdir -p /output/pjsip && \
    mkdir -p /output/opus

# Build opus

ADD ./build_opus.sh /usr/local/sbin/

RUN cd /usr/local/sbin && ls

RUN IFS=" " && \
    for arch in $TARGET_ARCHS; \
    do \
      ./build_opus.sh ${arch}; \
    done

# Build swig
RUN cd /sources/swig && \
    ./configure && \
    make && \
    make install

# Build OpenH264
ADD ./build_openh264.sh /usr/local/sbin/
RUN cd /usr/local/sbin & ls

RUN IFS=" " && \
    for arch in $TARGET_ARCHS; \
    do \
      ./build_openh264.sh ${arch}; \
    done

# Build openssl
ADD ./build_openssl.sh /usr/local/sbin/
RUN IFS=" " && \
    for arch in $TARGET_ARCHS; \
    do \
      build_openssl.sh ${arch}; \
    done

# Build pjsip
ADD ./build_pjsip.sh /usr/local/sbin/
RUN IFS=" " && \
    for arch in $TARGET_ARCHS; \
    do \
      build_pjsip.sh ${arch}; \
    done

# Dist
RUN mkdir -p /dist/android/src/main && \
    mv /output/pjsip/* /dist/android/src/main && \
    rm -rf /dist/android/src/main/java/org/pjsip/pjsua2/app

RUN IFS=" " && \
    for arch in $TARGET_ARCHS; \
    do \
      mv /output/openh264/${arch}/lib/libopenh264.so /dist/android/src/main/jniLibs/${arch}/; \
    done

.sh file to start the docker:

#!/bin/bash
set -e
IMAGE_NAME="react-native-pjsip-builder/android"
CONTAINER_NAME="react-native-pjsip-builder-${RANDOM}"
rm -rf ./dist/android;
mkdir -p ./dist/;
docker build -t react-native-pjsip-builder/android ./android/;
docker run --name ${CONTAINER_NAME} ${IMAGE_NAME} bin/true
docker cp ${CONTAINER_NAME}:/dist/android ./dist/android
docker rm ${CONTAINER_NAME}
5
  • 1
    /usr/ instead of .usr/? Or even just ./build_opus.sh, since you'd cd /usr/local/sbin to it already. Commented Jun 12, 2020 at 8:58
  • Hi, thanks for the response. apologize, it should be ./build_opus.sh, it's a left over of my tryings to get it working. modified the script in the question Commented Jun 12, 2020 at 9:17
  • 1
    Can we see your complete Dockerfile? Commented Jun 12, 2020 at 9:22
  • Can we see the full Dockerfile, and the error from running that dockerfile (you mention above the path shown is wrong)? Commented Jun 12, 2020 at 9:25
  • Hi all, thanks for the response, i've added the full docker file. Commented Jun 12, 2020 at 10:24

1 Answer 1

1

You are confusing WORKDIR with cd. In docker, there is a concept called WORKDIR, which acts like cd. It changes the directory location from thereafter to all upcoming instructions. Using cd will only change the directory in that particular layer when instruction comes to the next layer the directory location will be reverted back to WORKDIR.

Hence in order to properly run you either need to use Absolute path of the script or use WORKDIR to change and then run the script.

Using Absolute Path:

RUN IFS=" " &&
for arch in $TARGET_ARCHS;
do
/usr/local/sbin/build_opus.sh ${arch};
done

Using 'WORKDIR':

WORKDIR /usr/local/sbin/
RUN IFS=" " &&
for arch in $TARGET_ARCHS;
do
./build_opus.sh ${arch};
done

Reference:

  1. WORKDIR in docker
  2. difference between RUN cd and WORKDIR in Dockerfile
Sign up to request clarification or add additional context in comments.

4 Comments

Hi Thanks for the answer, unfortunately it didn't work out. I added the WORKDIR and added a ls command to the RUN command, the file is present, but still the file is not excecuted ``` Step 30/40 : RUN ls && IFS=" " && for arch in $TARGET_ARCHS; do ./build_opus.sh ${arch}; done ---> Running in e208955e37f4 build_opus.sh unminimize /bin/sh: 1: ./build_opus.sh: not found .....exited with code 127```
Apologize guys, It's an error INSIDE the build_opus.sh file. I've added a thon of 'echo' commands and got some steps further. Thanks for all the help!
Upvotining and accepting answers are better ways of saying thanks..upvote the answer if you find it useful and accept it if it solved the error.
@impeeNL Hi, I think I'm having the same issue you had with build_opus.sh creating docker container from Windows of pjsip. Can you help me?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.