🏡 index : ~doyle/bin.git

author alk3pInjection <webmaster@raspii.tech> 2023-10-21 15:08:12.0 +00:00:00
committer jordan <jordan@doyle.la> 2023-10-22 11:19:12.0 +00:00:00
commit
8d02b31688452a3f337cb680c6c1ea18f7b4991e [patch]
tree
fc997daa6201fb58aa923613206886571bfe056a
parent
dc6f9b5ec6e125b8a22437443406f8168279dc84
download
8d02b31688452a3f337cb680c6c1ea18f7b4991e.tar.gz

Revert "use static linking in Dockerfile"

The root cause of glibc version mismatch (#60) is we're trying to
build on bookworm and run on bullseye. The proper fix is simply
aligning the distro version during multi-stage builds.

While it's okay to statically link against musl libc, I don't see
any benefits in doing so, which _might_ also introduce performance
regressions.

Switch to smaller "distroless" image while we're at it.

This partially reverts commit dc6f9b5ec6e125b8a22437443406f8168279dc84.

Signed-off-by: alk3pInjection <webmaster@raspii.tech>

Diff

 Dockerfile | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 2dc4861..0a9e759 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,17 +1,14 @@
FROM rust:1-slim AS builder
FROM rust:1-slim-bookworm AS builder

RUN apt-get update && \
    apt-get install -y libclang-dev musl-tools
RUN rustup target add x86_64-unknown-linux-musl
RUN apt update && apt install -y libclang-dev

COPY . /sources
WORKDIR /sources
# force static linking with target to avoid glibc issues
RUN cargo build --release --target x86_64-unknown-linux-musl
RUN chown nobody:nogroup /sources/target/x86_64-unknown-linux-musl/release/bin
RUN cargo build --release
RUN chown nobody:nogroup /sources/target/release/bin

FROM debian:bullseye-slim
COPY --from=builder /sources/target/x86_64-unknown-linux-musl/release/bin /pastebin
FROM gcr.io/distroless/cc-debian12
COPY --from=builder /sources/target/release/bin /pastebin

USER nobody
EXPOSE 8000