I am building my cargo docker file. It used to work now it doesn't.
I am receiving this error: error: failed to run custom build command for `openssl-sys v0.9.67
I did multiple things based on my multiple digging:
brew install openssl
brew install pkg-config
brew install perl
I added the below in my dependencies in the cargo.toml as well
openssl-sys = "0.9"
openssl = { version = "0.10.33", features = ["vendored"] }
I even added the below on my.profile
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
Still not working. The error only shows during the docker build run.
---here's the error---
#7 133.6 error: failed to run custom build command for `openssl-sys v0.9.67`
#7 133.6
#7 133.6 Caused by:
#7 133.6 process didn't exit successfully: `/build-xxx/target/release/build/openssl-sys-bb0d0329fb009fff/build-script-main` (exit status: 101)
#7 133.6 --- stdout
#7 133.6 cargo:rustc-cfg=const_fn
#7 133.6 cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_NO_VENDOR
#7 133.6 X86_64_UNKNOWN_LINUX_GNU_OPENSSL_NO_VENDOR unset
#7 133.6 cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
#7 133.6 OPENSSL_NO_VENDOR unset
#7 133.6 CC_x86_64-unknown-linux-gnu = None
#7 133.6 CC_x86_64_unknown_linux_gnu = None
#7 133.6 HOST_CC = None
#7 133.6 CC = None
#7 133.6 CFLAGS_x86_64-unknown-linux-gnu = None
#7 133.6 CFLAGS_x86_64_unknown_linux_gnu = None
#7 133.6 HOST_CFLAGS = None
#7 133.6 CFLAGS = None
#7 133.6 CRATE_CC_NO_DEFAULTS = None
#7 133.6 DEBUG = Some("false")
#7 133.6 CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
#7 133.6 running "perl" "./Configure" "--prefix=/build-xxx/target/release/build/openssl-sys-c2883a05afa95d60/out/openssl-build/install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "linux-x86_64" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64"
#7 133.6
#7 133.6 --- stderr
#7 133.6 Can't locate FindBin.pm in @INC (you may need to install the FindBin module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl) at ./Configure line 15.
#7 133.6 BEGIN failed--compilation aborted at ./Configure line 15.
#7 133.6 thread 'main' panicked at '
#7 133.6
#7 133.6
#7 133.6 Error configuring OpenSSL build:
#7 133.6 Command: "perl" "./Configure" "--prefix=/build-xxx/target/release/build/openssl-sys-c2883a05afa95d60/out/openssl-build/install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "linux-x86_64" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64"
#7 133.6 Exit status: exit status: 2
#7 133.6
#7 133.6
#7 133.6 ', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.16.0+1.1.1l/src/lib.rs:479:13
#7 133.6 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#7 133.6 warning: build failed, waiting for other jobs to finish...
#7 133.7 error: build failed
#7 ERROR: executor failed running [/bin/sh -c cd /build-xxx/ && rustup default nightly && rustup update && cargo build --release]: exit code: 101
---below is the my docker file---
FROM rust:slim
COPY . /build-xxx/
RUN cd /build-xxx/ && rustup default nightly && rustup update && cargo build --release
LABEL Name=XXX Version=0.0.1
EXPOSE 8000
ENV ROCKET_ENV=stage
CMD ["/build-xxx/target/release/xxx"]
Since my error is only happening in the docker build, I updated dockerfile and add the dependencies (build-essential checkinstall zlib1g-dev) required for the OpenSSL.
I changed my docker file to the one below, and it works!
FROM rust:slim
RUN apt-get update && apt-get install -y \
build-essential checkinstall zlib1g-dev -y
COPY . /build-xxx/
RUN cd /build-xxx/ && rustup default nightly && rustup update && cargo build --release
LABEL Name=XXX Version=0.0.1
EXPOSE 8000
ENV ROCKET_ENV=stage
CMD ["/build-xxx/target/release/xxx"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.