Switched from Debian to Alpine Linux for significant improvements: - Image size: ~5MB vs ~100MB (95% smaller) - Security: Minimal attack surface, no glibc vulnerabilities - Static linking: No glibc version issues ever again - Uses rust:alpine builder with x86_64-unknown-linux-musl target - Static binaries with RUSTFLAGS='-C target-feature=+crt-static' Fixes the GLIBC_2.38 error permanently by avoiding glibc entirely.
25 lines
641 B
Docker
25 lines
641 B
Docker
FROM rust:alpine AS builder
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
RUN apk add --no-cache musl-dev pkgconfig openssl-dev && rustup target add x86_64-unknown-linux-musl
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY crates ./crates
|
|
COPY apps ./apps
|
|
|
|
ENV RUSTFLAGS='-C target-feature=+crt-static'
|
|
RUN cargo build --release --bin ugc_content_creators --target x86_64-unknown-linux-musl
|
|
|
|
FROM alpine:latest AS runtime
|
|
|
|
RUN apk add --no-cache ca-certificates
|
|
|
|
RUN adduser -D -u 1000 appuser
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /usr/src/app/target/x86_64-unknown-linux-musl/release/ugc_content_creators ./ugc_content_creators
|
|
|
|
USER appuser
|
|
|
|
CMD ["./ugc_content_creators"]
|