Dockerfile can't find shell script on build [duplicate] - linux

This question already has answers here:
Are shell scripts sensitive to encoding and line endings?
(14 answers)
Closed 3 years ago.
I'm trying to docker build an application that utilizes go. To install go, the dockerfile has the following command (this executes fine, by the way):
RUN wget https://dl.google.com/go/go1.11.linux-amd64.tar.gz \
&& tar -xf go1.11.linux-amd64.tar.gz \
&& mv go /usr/local
The problem arises when script runs shell files within the 'install' subdirectory. Note, output of the following two steps:
Step 9/13 : RUN . install/install-lmdb-linux.sh
---> Running in 0c666807720a
: not found install/install-lmdb-linux.sh:
: not found install/install-lmdb-linux.sh:
-e
Installing LMDB
Cloning into 'lmdb'...
: not found install/install-lmdb-linux.sh:
make: Entering directory '/root/bystro/lmdb/libraries/liblmdb'
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized -c mdb.c
gcc -pthread -O2 -g -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized -c midl.c
ar rs liblmdb.a mdb.o midl.o
ar: creating liblmdb.a
This shell script seems to be failing, but somehow recovers (?) and build continues to:
Step 11/13 : RUN . install/install-go-packages.sh
---> Running in 7700bf77c2b1
: not found install/install-go-packages.sh:
-e
Installing go packages (bystro-vcf, stats, snp)
: not found install/install-go-packages.sh:
: not found install/install-go-packages.sh:
: not found install/install-go-packages.sh:
Made /root/go path
: not found install/install-go-packages.sh:
: not found install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
: not found: install/install-go-packages.sh:
The command '/bin/sh -c . install/install-go-packages.sh' returned a non-zero code: 127
This script is the point at which build fails with exit code 127 (command not found). The task of this script is basically just to 'go install' some dependencies for the app.
My Debug:
After messing around with variations of the two RUN functions, I finally decided to log some of the situation: I check to see if the two shell scripts were actually present at runtime, and to see if Go was present at runtime. Both were present.
Step 9/15 : RUN ls install/
---> Running in 0f0ad051b009
export-bystro-libs.sh
export-go-path-linux.sh
install-apt-deps.sh
install-go-linux.sh
install-go-mac.sh
install-go-packages.sh
install-liftover-linux.sh
install-lmdb-linux.sh
install-mac-deps.sh
install-perl-libs.sh
install-perlbrew-linux.sh
install-rpm-deps.sh
update-packages.sh
Step 12/15 : RUN go version
---> Running in b8b9d08ef9c3
go version go1.11 linux/amd64
Also, note, both scripts execute perfectly when I run them manually.
Question:
Why is my build failing? It seems like Docker has the scripts, the tools to execute them, and the proper instruction to do so, so I'm not sure how to approach this.

If you don't want to use absolute path.
There is a command for changing your working directory
WORKDIR /your/directory
Then execute your shell commands using RUN
reference:Change directory command in Docker?

Related

Mozilla syncstorage-rs installation / make fails under RHEL8

I'm currently trying to install Mozilla syncstorage-rs on a RockyLinux machine, and step by step I could reduce the amount of errors, but now I got stuck. I found in Makefile to execute the following command in case of SSL trouble, so I did so cargo build --features grpcio/openssl
and this is fine, this finally works:
cargo build --features grpcio/openssl
Compiling syncstorage v0.10.2 (/var/www/html/syncstorage-rs)
Finished dev [unoptimized + debuginfo] target(s) in 35.59s
But when I try to now run either make run or make test or anything else, I just get:
= note: /usr/bin/ld: /var/www/html/syncstorage-rs/target/debug/deps/libopenssl-dc6f50ea1194640f.rlib(openssl-dc6f50ea1194640f.openssl.9bacb62b-cgu.1.rcgu.o): undefined reference to symbol 'OPENSSL_cipher_name##OPENSSL_1_1_1'
//usr/lib64/libssl.so.1.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
= help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
error: could not compile `syncstorage` due to previous error
make: *** [Makefile:45: test] Error 101
What am I missing? I thought after building it could be run easily.
So the answer is to use cargo clean before continuing. I don't know why, but there seemed to be some old artifacts even if I hadn't built before. However, after executing cargo clear command, the build openssl runs completely (many lines more than before) and after that, there is one more little step to do:
python3 -m venv venv # creates a virtual environment named "venv"
source venv/bin/activate # enters the virtual environment
python3 -m pip install -r requirements.txt # installs the packages
and finally make run works.
For more details, see https://github.com/mozilla-services/syncstorage-rs/issues/1241
See https://www.youtube.com/watch?v=jdtoyIW4Lec
for a step by step instruction.

Unable to cross compile PostgreSQL with OpenSSL, fails on <openssl/opensslconf.h> not found - despite specifying include search path

I am trying to cross compile PostgreSQL on an x86 host for an AArch64 target, and want to compile with OpenSSL support.
I already went ahead and successfully cross compiled OpenSSL for AArch64 using the following arguments:
../Configure linux-aarch64 --prefix=$(pwd)/packaged no-dso --cross-compile-prefix="/usr/bin/aarch64-linux-gnu-"
make -j$(nproc)
make -j$(nproc) install
Now on to cross compiling PostgreSQL, I am using the following build script:
test -e postgresql-12.2.tar.gz || wget https://ftp.postgresql.org/pub/source/v12.2/postgresql-12.2.tar.gz
test -e postgresql-12.2 || tar -xzvf postgresql-12.2.tar.gz
cd postgresql-12.2
test -e build_aarch64 && rm -rf build_aarch64
mkdir build_aarch64
cd build_aarch64
../configure --host=aarch64-linux-gnu --without-readline --without-zlib CFLAGS="-O3 -fPIC" CXXFLAGS="-fPIC" CPPFLAGS="-fPIC" --prefix=$PWD/packaged USE_DEV_URANDOM=1 --with-openssl --with-libraries=../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/lib/ --with-includes=../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/
make -j$(nproc)
The output of the configure commands shows that the include directory has been properly set:
configure: using CPPFLAGS=-fPIC -D_GNU_SOURCE -I../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/
configure: using LDFLAGS= -L../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/lib/
Running the make command fails on:
/usr/include/openssl/e_os2.h:13:11: fatal error: openssl/opensslconf.h: No such file or directory
13 | # include <openssl/opensslconf.h>
However if I run find ../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/ | grep opensslconf.h it outputs:
../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/openssl/opensslconf.h
so the file is definitely there in the include paths. Is this a bug? Am I doing something incorrectly?
Figured it out, looks like I had to use absolute paths instead of relative paths for the search directories:
../configure --host=aarch64-linux-gnu --without-readline --without-zlib CFLAGS="-O3 -fPIC" CXXFLAGS="-fPIC" CPPFLAGS="-fPIC" --prefix=$PWD/packaged USE_DEV_URANDOM=1 --with-openssl --with-libraries=$(pwd)/../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/lib/ --with-includes=$(pwd)/../../openssl-OpenSSL_1_1_1k/build_aarch64/packaged/include/
So basically just added $(pwd)/ to the start of the search directory paths.

Setting up CUDD 2.5.1 on Windows using cygwin

I am getting the following message while setting up CUDD 2.5.1 using cygwin on the command prompt:
sh ./setup.sh
make: sh: command not found
Makefile:224: recipe for target 'build' failed
make *** [build] error 127
I have saved both the directories of CUDD nad cygwin in C:/(windows 7, 64-bit).
This is the build portion of the Makefile:
build:
sh ./setup.sh
#+for dir in $(DIRS); do \
(cd $$dir; \
echo Making $$dir ...; \
make CC=$(CC) RANLIB=$(RANLIB) MFLAG= MNEMLIB= ICFLAGS="$(ICFLAGS)" XCFLAGS="$(XCFLAGS)" DDDEBUG="$(DDDEBUG)" MTRDEBUG="$(MTRDEBUG)" LDFLAGS="$(LDFLAGS)" PURE="$(PURE)" EXE="$(EXE)" )\
done
What should I do?
Have you tried installing CUDD so that the pathname of the installation directory contains no spaces?

Changing python headers directory for configure

I'm trying to build gnome-weather using jhbuild, but running build process results in the following errors:
checking for python extension module directory... ${exec_prefix}/lib64/python2.7/site-packages
checking for headers required to compile python extensions... ./configure: line 14697: /usr/local/bin/python-config: No such file or directory
not found
configure: error: Python headers not found
*** Error during phase configure of gobject-introspection: ########## Error running ./autogen.sh --prefix /home/pgolinski/jhbuild/install --disable-static --disable-gtk-doc *** [7/36]
[1] Rerun phase configure
[2] Ignore error and continue to build
[3] Give up on module
[4] Start shell
[5] Reload configuration
[6] Go to phase "wipe directory and start over"
[7] Go to phase "clean"
[8] Go to phase "distclean"
Strangely the error says that Python headers were not found even though I have python-devel installed. I managed to find python-config in usr/bin so how to change its directory for configure? Or maybe the problem lies elsewhere? (I just want to build gnome-weather)
you can download the last version of gnome-weather here:
https://git.gnome.org/browse/gnome-weather/snapshot/gnome-weather-3.14.1.zip
and compile that with these command after unzip it:
libtoolize
aclocal
autoheader
autoconf
automake --add-missing --foreign
./configure
make && make install
this should work.8y3
Here's what finally worked for me if someone struggles with something similair in future:
PYTHON=/usr/bin/python jhbuild build gnome-weather

How can I install git on my webserver with a curl.h no such file error

I have been trying to install Git on my web server. When i try "make install" i get the following errors which I cant seem to get past.
[root#site git-core-0.99.6]# make install
gcc -o http-pull.o -c -g -O2 -Wall '-DSHA1_HEADER=<openssl/sha.h>' http-pull.c
http-pull.c:6:23: error: curl/curl.h: No such file or directory
http-pull.c:7:23: error: curl/easy.h: No such file or directory
http-pull.c:16: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â*â token
http-pull.c: In function âfetch_indexâ:
http-pull.c:102: warning: implicit declaration of function âcurl_easy_setoptâ
There is alot more of that if you need to see it, but though part of it would cover the issue
It looks like you're missing the curl development package, maybe if you install the source available here (or with the package manager of your distribution), it will work better.
For example, under debian, install libcurl4-gnutls-dev

Resources