# vim:set ft=dockerfile:
FROM scratch AS libfakerand
COPY --from=stagex/busybox . /
COPY --from=stagex/rust . /
COPY --from=stagex/musl . /
COPY --from=stagex/gcc . /
COPY --from=stagex/llvm . /
COPY --from=stagex/binutils . /
COPY --from=stagex/libunwind . /
COPY --from=stagex/git . /
COPY --from=stagex/openssl . /
COPY --from=stagex/zlib . /
COPY --from=stagex/curl . /
COPY --from=stagex/ca-certificates . /
RUN git clone https://git.distrust.co/public/libfakerand /libfakerand
WORKDIR /libfakerand
RUN cargo build --release

FROM scratch AS stagex-openssl
COPY --from=stagex/libunwind . /
COPY --from=stagex/gcc . /
COPY --from=stagex/openssl . /
COPY --from=libfakerand /libfakerand/target/release/libfakerand.so /usr/lib/libfakerand.so
ENV LD_PRELOAD=/usr/lib/libfakerand.so
ENV FAKERAND=42

FROM stagex-openssl
COPY --from=stagex/musl . /
ENTRYPOINT ["/usr/bin/openssl"]
CMD ["rand", "-hex", "12"]
