Skip to content

Latest Alpine images break SQL CLI build #167

Closed
@mrsarm

Description

@mrsarm

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:

FROM rust:1.71-alpine3.18

RUN apk add --no-cache --purge openssl-dev musl-dev \
    && cargo install sqlx-cli \
         --target x86_64-unknown-linux-musl \
         --no-default-features \
         --features native-tls,postgres

ENTRYPOINT ["/usr/local/cargo/bin/sqlx"]

I can build the executable, and run a container with the resulting image:

# Build with:
docker build -t sqlx-cli .
# ...
# Run with:
docker run -it --rm sqlx-cli --version
sqlx-cli 0.7.3

Changing the image to rust:1.72-alpine3.18, rust:1.73-alpine3.18 or the latest Alpine version rust:1.74.1-alpine3.18 the build fails with the following:

docker build -t sqlx .

...
53.02    Compiling sqlx v0.7.3
53.06    Compiling sqlx-cli v0.7.3
...
80.60 
80.76 error: could not compile `sqlx-cli` (bin "cargo-sqlx") due to previous error
80.76 warning: build failed, waiting for other jobs to finish...
81.08 error: linking with `cc` failed: exit status: 1
81.08   |
81.08   = note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/1.74.1-x86_64-unkn...
...
80.60   = note: /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lssl: No such file or directory
80.60           /usr/lib/gcc/x86_64-alpine-linux-musl/12.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lcrypto: No such file or directory
80.60           collect2: error: ld returned 1 exit status
80.60           
80.60 
80.76 error: could not compile `sqlx-cli` (bin "cargo-sqlx") due to previous error
80.76 warning: build failed, waiting for other jobs to finish...
81.08   |
...
ERROR: failed to solve: process "/bin/sh -c apk add --no-cache --purge openssl-dev musl-dev     && cargo install sqlx-cli          --target x86_64-unknown-linux-musl          --no-default-features          --features native-tls,postgres" did not complete successfully: exit code: 101

CC @abonander @mehcode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions