diff --git a/orchestration/coins/bitcoin/Dockerfile b/orchestration/coins/bitcoin/Dockerfile index cff65eb9..cf06d864 100644 --- a/orchestration/coins/bitcoin/Dockerfile +++ b/orchestration/coins/bitcoin/Dockerfile @@ -7,8 +7,7 @@ ENV BITCOIN_DATA=/home/bitcoin/.bitcoin WORKDIR /home/bitcoin -RUN apk update && \ - apk --no-cache add ca-certificates bash su-exec git gnupg +RUN apk --no-cache add git gnupg # Download Bitcoin RUN wget https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_VERSION}/bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz \ @@ -27,8 +26,24 @@ RUN grep bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz SHA256SUMS | sha256s RUN tar xzvf bitcoin-${BITCOIN_VERSION}-x86_64-linux-gnu.tar.gz RUN mv bitcoin-${BITCOIN_VERSION}/bin/bitcoind . +# Also build mimalloc +FROM debian:bookworm-slim as mimalloc + +RUN apt update && apt upgrade -y && apt install -y gcc g++ make cmake git +RUN git clone https://github.com/microsoft/mimalloc && \ + cd mimalloc && \ + mkdir -p out/secure && \ + cd out/secure && \ + cmake -DMI_SECURE=ON ../.. && \ + make && \ + cp ./libmimalloc-secure.so ../../../libmimalloc.so + +# Build the actual image FROM debian:bookworm-slim as image +COPY --from=mimalloc libmimalloc.so /usr/lib +RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload + # Upgrade packages RUN apt update && apt upgrade -y && apt autoremove -y && apt clean diff --git a/orchestration/coins/monero/Dockerfile b/orchestration/coins/monero/Dockerfile index 930a936e..991228bc 100644 --- a/orchestration/coins/monero/Dockerfile +++ b/orchestration/coins/monero/Dockerfile @@ -11,8 +11,16 @@ ENV GLIBC_VERSION=2.28-r0 WORKDIR /home/monero -RUN apk update \ - && apk --no-cache add ca-certificates gnupg bash su-exec +RUN apk update && apk --no-cache add gcc g++ libc-dev make cmake git +RUN git clone https://github.com/microsoft/mimalloc && \ + cd mimalloc && \ + mkdir -p out/secure && \ + cd out/secure && \ + cmake -DMI_SECURE=ON ../.. && \ + make && \ + cp ./libmimalloc-secure.so ../../../libmimalloc.so + +RUN apk --no-cache add gnupg # Download Monero RUN wget https://downloads.getmonero.org/cli/monero-linux-x64-v${MONERO_VERSION}.tar.bz2 @@ -29,8 +37,11 @@ RUN tar -xvjf monero-linux-x64-v${MONERO_VERSION}.tar.bz2 --strip-components=1 # Build the actual image FROM alpine:latest as image +COPY --from=builder /home/monero/libmimalloc.so /usr/lib +ENV LD_PRELOAD=libmimalloc.so + # Upgrade packages -RUN apk update && apk upgrade && apk add gcompat +RUN apk update && apk upgrade && apk --no-cache add gcompat # Switch to a non-root user # System user (not a human), shell of nologin, no password assigned diff --git a/orchestration/coordinator/Dockerfile b/orchestration/coordinator/Dockerfile index 039a5819..6a7664a1 100644 --- a/orchestration/coordinator/Dockerfile +++ b/orchestration/coordinator/Dockerfile @@ -32,9 +32,23 @@ RUN --mount=type=cache,target=/root/.cargo \ mkdir /serai/bin && \ mv /serai/target/release/serai-coordinator /serai/bin -# Prepare Image +# Also build mimalloc +FROM debian:bookworm-slim as mimalloc + +RUN apt update && apt upgrade -y && apt install -y gcc g++ make cmake git +RUN git clone https://github.com/microsoft/mimalloc && \ + cd mimalloc && \ + mkdir -p out/secure && \ + cd out/secure && \ + cmake -DMI_SECURE=ON ../.. && \ + make && \ + cp ./libmimalloc-secure.so ../../../libmimalloc.so + +# Build the actual image FROM debian:bookworm-slim as image -LABEL description="STAGE 2: Copy and Run" + +COPY --from=mimalloc libmimalloc.so /usr/lib +RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload # Upgrade packages and install openssl RUN apt update && apt upgrade -y && apt install -y libssl-dev && apt autoremove && apt clean diff --git a/orchestration/message-queue/Dockerfile b/orchestration/message-queue/Dockerfile index c4a17fce..2f5a3250 100644 --- a/orchestration/message-queue/Dockerfile +++ b/orchestration/message-queue/Dockerfile @@ -29,9 +29,23 @@ RUN --mount=type=cache,target=/root/.cargo \ mkdir /serai/bin && \ mv /serai/target/release/serai-message-queue /serai/bin -# Prepare Image +# Also build mimalloc +FROM debian:bookworm-slim as mimalloc + +RUN apt update && apt upgrade -y && apt install -y gcc g++ make cmake git +RUN git clone https://github.com/microsoft/mimalloc && \ + cd mimalloc && \ + mkdir -p out/secure && \ + cd out/secure && \ + cmake -DMI_SECURE=ON ../.. && \ + make && \ + cp ./libmimalloc-secure.so ../../../libmimalloc.so + +# Build the actual image FROM debian:bookworm-slim as image -LABEL description="STAGE 2: Copy and Run" + +COPY --from=mimalloc libmimalloc.so /usr/lib +RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload # Upgrade packages RUN apt update && apt upgrade -y diff --git a/orchestration/processor/Dockerfile b/orchestration/processor/Dockerfile index 13c7559f..c4b48a89 100644 --- a/orchestration/processor/Dockerfile +++ b/orchestration/processor/Dockerfile @@ -32,9 +32,23 @@ RUN --mount=type=cache,target=/root/.cargo \ mkdir /serai/bin && \ mv /serai/target/release/serai-processor /serai/bin -# Prepare Image +# Also build mimalloc +FROM debian:bookworm-slim as mimalloc + +RUN apt update && apt upgrade -y && apt install -y gcc g++ make cmake git +RUN git clone https://github.com/microsoft/mimalloc && \ + cd mimalloc && \ + mkdir -p out/secure && \ + cd out/secure && \ + cmake -DMI_SECURE=ON ../.. && \ + make && \ + cp ./libmimalloc-secure.so ../../../libmimalloc.so + +# Build the actual image FROM debian:bookworm-slim as image -LABEL description="STAGE 2: Copy and Run" + +COPY --from=mimalloc libmimalloc.so /usr/lib +RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload # Upgrade packages and install openssl RUN apt update && apt upgrade -y && apt install -y libssl-dev diff --git a/orchestration/serai/Dockerfile b/orchestration/serai/Dockerfile index 8c5d8347..32c4f274 100644 --- a/orchestration/serai/Dockerfile +++ b/orchestration/serai/Dockerfile @@ -32,9 +32,23 @@ RUN --mount=type=cache,target=/root/.cargo \ mkdir /serai/bin && \ mv /serai/target/release/serai-node /serai/bin -# Prepare Image +# Also build mimalloc +FROM debian:bookworm-slim as mimalloc + +RUN apt update && apt upgrade -y && apt install -y gcc g++ make cmake git +RUN git clone https://github.com/microsoft/mimalloc && \ + cd mimalloc && \ + mkdir -p out/secure && \ + cd out/secure && \ + cmake -DMI_SECURE=ON ../.. && \ + make && \ + cp ./libmimalloc-secure.so ../../../libmimalloc.so + +# Build the actual image FROM debian:bookworm-slim as image -LABEL description="STAGE 2: Copy and Run" + +COPY --from=mimalloc libmimalloc.so /usr/lib +RUN echo "/usr/lib/libmimalloc.so" >> /etc/ld.so.preload # Upgrade packages RUN apt update && apt upgrade -y