Skip to content

Commit a8d67e2

Browse files
committed
Use a more reliable testing for ldd
1 parent 7fb9841 commit a8d67e2

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

examples/linking-with-git2/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ ADD --chown=rust:rust . ./
1111

1212
# Build our application.
1313
RUN cargo build
14+
15+
# Now, we need to build our _real_ Docker container, copying in `linking-with-git2`.
16+
FROM debian:stretch-slim
17+
RUN apt-get update && apt-get install -y ca-certificates
18+
COPY --from=builder \
19+
/home/rust/src/target/x86_64-unknown-linux-musl/debug/linking-with-git2 \
20+
/usr/local/bin/
21+
CMD /usr/local/bin/linking-with-git2

examples/using-sqlx/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ ADD --chown=rust:rust . ./
1717
RUN cargo build --release
1818

1919
# Now, we need to build our _real_ Docker container, copying in `using-sqlx`.
20-
FROM alpine:latest
21-
RUN apk --no-cache add ca-certificates
20+
FROM debian:stretch-slim
21+
RUN apt-get update && apt-get install -y ca-certificates
2222
COPY --from=builder \
2323
/home/rust/src/target/x86_64-unknown-linux-musl/release/using-sqlx \
2424
/usr/local/bin/

test-image

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ echo "==== Verifying static linking"
1717

1818
# Make sure we can build a static executable using `sqlx`.
1919
docker build -t rust-musl-builder-using-sqlx examples/using-sqlx
20-
docker run --rm rust-musl-builder-using-sqlx sh -c "
20+
docker run --rm rust-musl-builder-using-sqlx bash -c "
2121
set -euo pipefail
2222
2323
echo -e '--- Test case for sqlx:'
2424
echo 'ldd says:'
25-
if ldd /usr/local/bin/using-sqlx; then
25+
lddresult=\$(ldd /usr/local/bin/using-sqlx)
26+
echo \$lddresult
27+
if [[ "\$lddresult" != *statically\ linked* ]]; then
2628
echo '[FAIL] Executable is not static!' 1>&2
2729
exit 1
2830
fi
@@ -33,14 +35,16 @@ echo -e '[PASS] using-sqlx binary is statically linked.\n'
3335
docker build -t rust-musl-builder-linking-with-git2 examples/linking-with-git2
3436
docker run --rm rust-musl-builder-linking-with-git2 bash -c "
3537
set -euo pipefail
36-
cd /home/rust/src
3738
3839
echo -e '--- Test case for libgit2:'
3940
echo 'ldd says:'
40-
if ldd target/x86_64-unknown-linux-musl/debug/linking-with-git2; then
41+
lddresult=\$(ldd /usr/local/bin/linking-with-git2)
42+
echo \$lddresult
43+
if [[ "\$lddresult" != *statically\ linked* ]]; then
4144
echo '[FAIL] Executable is not static!' 1>&2
4245
exit 1
4346
fi
47+
4448
echo -e '[PASS] libgit2 binary is statically linked.\n'
4549
"
4650

0 commit comments

Comments
 (0)