-
-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Could not find directory of OpenSSL installation" in a docker build #1684
Comments
Thanks to this article I've got it working. I had to build OpenSSL for Here's what my Dockerfile looks like now: FROM rust:1.63.0
RUN apt update
RUN apt install -y musl-tools
# ------------------------------- Build OpenSSL for the `musl` build target
RUN \
ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/asm && \
ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/asm-generic && \
ln -s /usr/include/linux /usr/include/x86_64-linux-musl/linux
WORKDIR /musl
RUN wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1f.tar.gz
RUN tar zxvf OpenSSL_1_1_1f.tar.gz
WORKDIR /musl/openssl-OpenSSL_1_1_1f/
RUN CC="musl-gcc -fPIE -pie" ./Configure no-shared no-async --prefix=/musl --openssldir=/musl/ssl linux-x86_64
RUN make depend
RUN make -j$(nproc)
RUN make install
# -------------------------------
WORKDIR /build
RUN rustup override set nightly-2022-08-09
RUN rustup target add x86_64-unknown-linux-musl
COPY Cargo.lock .
COPY Cargo.toml .
RUN mkdir src
RUN echo "fn main() {}" > src/main.rs
ENV OPENSSL_DIR=/musl
RUN cargo build --release --target x86_64-unknown-linux-musl |
While the issue is old, this is for anyone else that lands here 😅 FWIW, since you're using Docker anyway you could just use the alpine version of the Rust image. You don't need to build openssl for musl as above that way :)
That error might be relevant, along with your cross compiling if you don't actually need it. Since you're using the same arch + platform and just want to target UPDATE: In the linked issue I direct you to, I additionally document the |
I'm trying to build a binary for AWS Lambda here and have been stuck trying to get
openssl-sys
to build for a long time. I'm getting the error "Could not find directory of OpenSSL installation" even though I havelibssl-dev
installed, and even I tried throwingopenssl
in there for good measure.I've tried exploring the resulting file system of the docker container to see where I could point
OPENSSL_DIR
, but I can't find anything containing aninclude
and alib
directory like the build asks for.OpenSSL is just being installed here in a very standard way, I don't see why it can't be found.
Thanks!
My
Dockerfile
:My
Cargo.toml
:The error that I'm seeing:
The text was updated successfully, but these errors were encountered: