-
Notifications
You must be signed in to change notification settings - Fork 90
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
Latest Alpine images break SQL CLI build #167
Comments
Still the same issue with the
This is weird because both
|
If we don't use the provided docker image, but manually install rust into the
|
I tried adding
|
You can if you do it properly: sfackler/rust-openssl#1627 (comment) # Rust alpine container with extra deps added:
docker run --rm -it rust:alpine ash
apk add musl-dev openssl-dev openssl-libs-static
# Minimal project example:
cargo init /example && cd /example
cargo add openssl
# All one command (can paste into terminal without needing `\`)
cat > src/main.rs <<EOF
fn main() {
println!("Version: {}", openssl::version::version());
}
EOF
# Check builds successfully:
cargo run --release
# OUTPUT:
# Version: OpenSSL 3.1.4 24 Oct 2023 You can replace my
The C program worked because you dynamically linked, while the rust target The reason it's different when you use the official alpine image directly is because you installed cargo from So there's your answer :)
If you want to use |
@polarathene Thanks for the explanation, that makes perfect sense. It is quite weird that @mrsarm's issue can also be fixed by either installing |
Thanks all for the feedback and workarounds, I'll test them Today or Tomorrow and post here the results. |
Worked ! So for those that need the same, here is the example again fixed, and with the latest Rust image available Today: FROM rust:1.76-alpine3.19
RUN apk update \
&& apk add --no-cache --purge openssl-dev openssl-libs-static musl-dev libc-dev \
&& cargo install sqlx-cli \
--target x86_64-unknown-linux-musl \
--no-default-features \
--features native-tls,postgres
ENTRYPOINT ["/usr/local/cargo/bin/sqlx"] This is how to build it, and test it: # Build with:
docker build -t sqlx-cli .
# ...
# Run with:
docker run -it --rm sqlx-cli --version
sqlx-cli 0.7.3 |
Not sure whether this is an issue related to changes in how the Rust Alpine image is generated, but I'm able to build the latest version of
sqlx-cli
without problems in older versions of Alpine with Docker, and with my local Ubuntu machine using latest Rust as well.Using a not so old Alpine image
rust:1.71-alpine3.18
the following Dockerfile works:I can build the executable, and run a container with the resulting image:
Changing the image to
rust:1.72-alpine3.18
,rust:1.73-alpine3.18
or the latest Alpine versionrust:1.74.1-alpine3.18
the build fails with the following:CC @abonander @mehcode
The text was updated successfully, but these errors were encountered: