# Build binary FROM rust:1.75.0 as build-env WORKDIR /app COPY . /app ENV TESTBINARY='testbinary' # Need JQ for parsing json RUN apt-get update -y RUN apt-get install jq -y # Create standalone test binary RUN cargo test --message-format=json --no-run --quiet | jq '.executable' | grep '/sontonio_iam*' | tr -d '"' | xargs -I '{}' mv {} ./${TESTBINARY} # Copy binary to distroless CC # Specs: https://edu.chainguard.dev/chainguard/chainguard-images/reference/glibc-dynamic/image_specs/ FROM cgr.dev/chainguard/glibc-dynamic:latest COPY --from=build-env /app/${TESTBINARY} / ENV PORT="3000" EXPOSE ${PORT} # Why no variable substition? # Docker makes the shell responsible for interpreting the variable # https://docs.docker.com/engine/reference/builder/#variable-substitution # However, there is no shell in the distroless CC. # Thus we do it manually :) CMD ["./testbinary"]