I have persisting issue when I try to build Rust in docker. It used to work but recently started to break. I've tried different images but still having this error. It seems obvious that libssl-dev should be installed but I'm already doing this. Please, any clue how to fix this?
This is docker file
FROM rust:slim AS builder
RUN apt-get update -y && \
apt-get install -y make g++ libssl-dev && \
rustup target add x86_64-unknown-linux-gnu
WORKDIR /app
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-gnu
FROM gcr.io/distroless/cc
COPY --from=builder /app/target/x86_64-unknown-linux-gnu/release/rebot /bin/rebot
ENTRYPOINT [ "/bin/rebot" ]
This is the error.
#11 426.3 error: failed to run custom build command for `openssl-sys v0.9.80`
#11 426.3
#11 426.3 Caused by:
#11 426.3 process didn't exit successfully: `/app/target/release/build/openssl-sys-a00b6be9953405cd/build-script-main` (exit status: 101)
#11 426.3 --- stdout
#11 426.3 cargo:rustc-cfg=const_fn
#11 426.3 cargo:rustc-cfg=openssl
#11 426.3 cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR
#11 426.3 X86_64_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR unset
#11 426.3 cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
#11 426.3 OPENSSL_LIB_DIR unset
#11 426.3 cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR
#11 426.3 X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR unset
#11 426.3 cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
#11 426.3 OPENSSL_INCLUDE_DIR unset
#11 426.3 cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR
#11 426.3 X86_64_UNKNOWN_LINUX_GNU_OPENSSL_DIR unset
#11 426.3 cargo:rerun-if-env-changed=OPENSSL_DIR
#11 426.3 OPENSSL_DIR unset
#11 426.3 cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-unknown-linux-gnu
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_unknown_linux_gnu
#11 426.3 cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
#11 426.3 cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
#11 426.3 cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
#11 426.3 cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
#11 426.3 run pkg_config fail: "pkg-config has not been configured to support cross-compilation.\n\nInstall a sysroot for the target platform and configure it via\nPKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a\ncross-compiling wrapper for pkg-config and set it via\nPKG_CONFIG environment variable."
#11 426.3
#11 426.3 --- stderr
#11 426.3 thread 'main' panicked at '
#11 426.3
#11 426.3 Could not find directory of OpenSSL installation, and this `-sys` crate cannot
#11 426.3 proceed without this knowledge. If OpenSSL is installed and this crate had
#11 426.3 trouble finding it, you can set the `OPENSSL_DIR` environment variable for the
#11 426.3 compilation process.
#11 426.3
#11 426.3 Make sure you also have the development packages of openssl installed.
#11 426.3 For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
#11 426.3
#11 426.3 If you're in a situation where you think the directory *should* be found
#11 426.3 automatically, please open a bug at https://github.com/sfackler/rust-openssl
#11 426.3 and include information about your system as well as this message.
#11 426.3
#11 426.3 $HOST = aarch64-unknown-linux-gnu
#11 426.3 $TARGET = x86_64-unknown-linux-gnu
#11 426.3 openssl-sys = 0.9.80
#11 426.3
#11 426.3
#11 426.3 It looks like you're compiling on Linux and also targeting Linux. Currently this
#11 426.3 requires the `pkg-config` utility to find OpenSSL but unfortunately `pkg-config`
#11 426.3 could not be found. If you have OpenSSL installed you can likely fix this by
#11 426.3 installing `pkg-config`.
#11 426.3
#11 426.3 ', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.80/build/find_normal.rs:191:5
#11 426.3 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#11 426.3 warning: build failed, waiting for other jobs to finish...
------
executor failed running [/bin/sh -c cargo build --release --target x86_64-unknown-linux-gnu]: exit code: 101
Update 1: Adding dependencies in cargo
openssl-sys = "0.9.82"
openssl = { version = "0.10.47", features = ["vendored"] }
Gives this error
#14 93.18 make[1]: Leaving directory '/rebot/target/x86_64-unknown-linux-musl/release/build/openssl-sys-5963a97b9196664b/out/openssl-build/build/src'
#14 93.18
#14 93.18 --- stderr
#14 93.18 cc1: error: unrecognized command-line option '-m64'
#14 93.18 cc1: error: unrecognized command-line option '-m64'
#14 93.18 make[1]: *** [Makefile:679: apps/app_rand.o] Error 1
#14 93.18 make: *** [Makefile:177: build_libs] Error 2
#14 93.18 thread 'main' panicked at '
#14 93.18
#14 93.18
#14 93.18 Error building OpenSSL:
#14 93.18 Command: cd "/rebot/target/x86_64-unknown-linux-musl/release/build/openssl-sys-5963a97b9196664b/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=9,14 --jobserver-auth=9,14" "make" "build_libs"
#14 93.18 Exit status: exit status: 2
#14 93.18
#14 93.18
#14 93.18 ', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.25.2+1.1.1t/src/lib.rs:505:13
#14 93.18 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#14 93.18 warning: build failed, waiting for other jobs to finish...