rust-musl-builder/test-image
Eric Kidd 3ae8179705 Experimental: Improve support for USER root
This PR attempts to lay the groundwork to address
https://github.com/emk/rust-musl-builder/issues/96. In particular, we
install the Rust toolchain globally by abusing `rustup`.

We still preserve the legacy `rust` user but we now encourage derived
Dockerfiles to consider `USER root`.

This PR also removes ARM support. We want to explore the idea of
supporting ARM more reliably using a separate image, but perhaps it
would be better to refer those users to one of the Rust
cross-compilation toolchains. See
https://github.com/emk/rust-musl-builder/issues/63 for discussion.
2020-09-06 11:54:46 -04:00

49 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
# Make bash fail much more aggressively on errors.
set -euo pipefail
# Make sure we can build our main container.
docker build -t ekidd/rust-musl-builder .
# Make sure we can build our example derived container.
docker build -t rust-musl-zlib examples/adding-a-library
# Make sure we can build a multi-stage container.
docker build -t rust-musl-builder-using-diesel examples/using-diesel
docker run --rm rust-musl-builder-using-diesel
echo "==== Verifying static linking"
# Make sure we can build a static executable using `sqlx`.
docker build -t rust-musl-builder-using-sqlx examples/using-sqlx
docker run --rm rust-musl-builder-using-sqlx sh -c "
set -euo pipefail
echo -e '--- Test case for sqlx:'
echo 'ldd says:'
if ldd /usr/local/bin/using-sqlx; then
echo '[FAIL] Executable is not static!' 1>&2
exit 1
fi
echo -e '[PASS] using-sqlx binary is statically linked.\n'
"
# Make sure we can build a static executable using `git2`.
docker build -t rust-musl-builder-linking-with-git2 examples/linking-with-git2
docker run --rm rust-musl-builder-linking-with-git2 bash -c "
set -euo pipefail
cd /home/rust/src
echo -e '--- Test case for libgit2:'
echo 'ldd says:'
if ldd target/x86_64-unknown-linux-musl/debug/linking-with-git2; then
echo '[FAIL] Executable is not static!' 1>&2
exit 1
fi
echo -e '[PASS] libgit2 binary is statically linked.\n'
"
# We're good.
echo 'OK. ALL TESTS PASSED.' 1>&2