diff --git a/.gitignore b/.gitignore index d548f66d..25f34d4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ +*.tar.gz +*.zip +rustup-init.sh .jq-template.awk diff --git a/3.13/alpine/Dockerfile b/3.13/alpine/Dockerfile index d0995fa1..73f9af56 100644 --- a/3.13/alpine/Dockerfile +++ b/3.13/alpine/Dockerfile @@ -6,6 +6,7 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: # Alpine Linux is not officially supported by the RabbitMQ team -- use at your own risk! FROM alpine:3.22 AS build-base diff --git a/3.13/alpine/management/Dockerfile b/3.13/alpine/management/Dockerfile index d13431fe..8b8e7d66 100644 --- a/3.13/alpine/management/Dockerfile +++ b/3.13/alpine/management/Dockerfile @@ -6,18 +6,52 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: +FROM rabbitmq:3.13-alpine AS builder + +RUN set +e; set -ux; \ + apk add --no-cache build-base wget unzip musl-dev; \ + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v2.17.0.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ + echo "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4 rmqadmin.zip" | sha256sum -c -; \ + echo "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2 rustup-init.sh" | sha256sum -c -; \ + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-2.17.0"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ +# NOTE: since OpenSSL is dynamically linked to musl, rabbitmqadmin must also be (https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172) + export RUSTFLAGS="-C target-feature=-crt-static -C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + FROM rabbitmq:3.13-alpine RUN set -eux; \ rabbitmq-plugins enable --offline rabbitmq_management; \ # make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ - apk add --no-cache python3; \ - rabbitmqadmin --version + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/3.13/ubuntu/Dockerfile b/3.13/ubuntu/Dockerfile index 040e0721..c6e7f383 100644 --- a/3.13/ubuntu/Dockerfile +++ b/3.13/ubuntu/Dockerfile @@ -6,6 +6,7 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: # The official Canonical Ubuntu Focal image is ideal from a security perspective, # especially for the enterprises that we, the RabbitMQ team, have to deal with FROM ubuntu:24.04 AS build-base diff --git a/3.13/ubuntu/management/Dockerfile b/3.13/ubuntu/management/Dockerfile index 54957590..8e4beabf 100644 --- a/3.13/ubuntu/management/Dockerfile +++ b/3.13/ubuntu/management/Dockerfile @@ -6,20 +6,52 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: +FROM rabbitmq:3.13 AS builder + +RUN set +e; set -ux; \ + apt-get update; \ + apt-get install -y --no-install-recommends build-essential unzip wget; \ + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v2.17.0.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ + echo "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4 rmqadmin.zip" | sha256sum --check --strict -; \ + echo "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2 rustup-init.sh" | sha256sum --check --strict -; \ + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-2.17.0"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ + export RUSTFLAGS="-C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + FROM rabbitmq:3.13 RUN set -eux; \ rabbitmq-plugins enable --offline rabbitmq_management; \ # make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ - apt-get update; \ - apt-get install -y --no-install-recommends python3; \ - rm -rf /var/lib/apt/lists/*; \ - rabbitmqadmin --version + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/4.0/alpine/Dockerfile b/4.0/alpine/Dockerfile index b507a2f9..f69e3cb8 100644 --- a/4.0/alpine/Dockerfile +++ b/4.0/alpine/Dockerfile @@ -6,6 +6,7 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: # Alpine Linux is not officially supported by the RabbitMQ team -- use at your own risk! FROM alpine:3.22 AS build-base diff --git a/4.0/alpine/management/Dockerfile b/4.0/alpine/management/Dockerfile index 285600d0..559166b5 100644 --- a/4.0/alpine/management/Dockerfile +++ b/4.0/alpine/management/Dockerfile @@ -6,18 +6,52 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: +FROM rabbitmq:4.0-alpine AS builder + +RUN set +e; set -ux; \ + apk add --no-cache build-base wget unzip musl-dev; \ + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v2.17.0.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ + echo "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4 rmqadmin.zip" | sha256sum -c -; \ + echo "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2 rustup-init.sh" | sha256sum -c -; \ + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-2.17.0"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ +# NOTE: since OpenSSL is dynamically linked to musl, rabbitmqadmin must also be (https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172) + export RUSTFLAGS="-C target-feature=-crt-static -C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + FROM rabbitmq:4.0-alpine RUN set -eux; \ rabbitmq-plugins enable --offline rabbitmq_management; \ # make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ - apk add --no-cache python3; \ - rabbitmqadmin --version + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/4.0/ubuntu/Dockerfile b/4.0/ubuntu/Dockerfile index b3013fd8..d118278a 100644 --- a/4.0/ubuntu/Dockerfile +++ b/4.0/ubuntu/Dockerfile @@ -6,6 +6,7 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: # The official Canonical Ubuntu Focal image is ideal from a security perspective, # especially for the enterprises that we, the RabbitMQ team, have to deal with FROM ubuntu:24.04 AS build-base diff --git a/4.0/ubuntu/management/Dockerfile b/4.0/ubuntu/management/Dockerfile index fa8c1040..c07160f2 100644 --- a/4.0/ubuntu/management/Dockerfile +++ b/4.0/ubuntu/management/Dockerfile @@ -6,20 +6,52 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: +FROM rabbitmq:4.0 AS builder + +RUN set +e; set -ux; \ + apt-get update; \ + apt-get install -y --no-install-recommends build-essential unzip wget; \ + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v2.17.0.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ + echo "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4 rmqadmin.zip" | sha256sum --check --strict -; \ + echo "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2 rustup-init.sh" | sha256sum --check --strict -; \ + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-2.17.0"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ + export RUSTFLAGS="-C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + FROM rabbitmq:4.0 RUN set -eux; \ rabbitmq-plugins enable --offline rabbitmq_management; \ # make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ - apt-get update; \ - apt-get install -y --no-install-recommends python3; \ - rm -rf /var/lib/apt/lists/*; \ - rabbitmqadmin --version + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/4.1/alpine/Dockerfile b/4.1/alpine/Dockerfile index 7dbb3c18..ebb08b3c 100644 --- a/4.1/alpine/Dockerfile +++ b/4.1/alpine/Dockerfile @@ -6,6 +6,7 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: # Alpine Linux is not officially supported by the RabbitMQ team -- use at your own risk! FROM alpine:3.22 AS build-base diff --git a/4.1/alpine/management/Dockerfile b/4.1/alpine/management/Dockerfile index 78b9469e..caff65e1 100644 --- a/4.1/alpine/management/Dockerfile +++ b/4.1/alpine/management/Dockerfile @@ -6,18 +6,52 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: +FROM rabbitmq:4.1-alpine AS builder + +RUN set +e; set -ux; \ + apk add --no-cache build-base wget unzip musl-dev; \ + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v2.17.0.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ + echo "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4 rmqadmin.zip" | sha256sum -c -; \ + echo "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2 rustup-init.sh" | sha256sum -c -; \ + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-2.17.0"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ +# NOTE: since OpenSSL is dynamically linked to musl, rabbitmqadmin must also be (https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172) + export RUSTFLAGS="-C target-feature=-crt-static -C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + FROM rabbitmq:4.1-alpine RUN set -eux; \ rabbitmq-plugins enable --offline rabbitmq_management; \ # make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ - apk add --no-cache python3; \ - rabbitmqadmin --version + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/4.1/ubuntu/Dockerfile b/4.1/ubuntu/Dockerfile index b65af317..fac220df 100644 --- a/4.1/ubuntu/Dockerfile +++ b/4.1/ubuntu/Dockerfile @@ -6,6 +6,7 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: # The official Canonical Ubuntu Focal image is ideal from a security perspective, # especially for the enterprises that we, the RabbitMQ team, have to deal with FROM ubuntu:24.04 AS build-base diff --git a/4.1/ubuntu/management/Dockerfile b/4.1/ubuntu/management/Dockerfile index da441db1..6a6ae537 100644 --- a/4.1/ubuntu/management/Dockerfile +++ b/4.1/ubuntu/management/Dockerfile @@ -6,20 +6,52 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: +FROM rabbitmq:4.1 AS builder + +RUN set +e; set -ux; \ + apt-get update; \ + apt-get install -y --no-install-recommends build-essential unzip wget; \ + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v2.17.0.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ + echo "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4 rmqadmin.zip" | sha256sum --check --strict -; \ + echo "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2 rustup-init.sh" | sha256sum --check --strict -; \ + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-2.17.0"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ + export RUSTFLAGS="-C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + FROM rabbitmq:4.1 RUN set -eux; \ rabbitmq-plugins enable --offline rabbitmq_management; \ # make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ - apt-get update; \ - apt-get install -y --no-install-recommends python3; \ - rm -rf /var/lib/apt/lists/*; \ - rabbitmqadmin --version + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/4.2/alpine/Dockerfile b/4.2/alpine/Dockerfile index 41b14f65..1daf6dfd 100644 --- a/4.2/alpine/Dockerfile +++ b/4.2/alpine/Dockerfile @@ -6,6 +6,7 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: # Alpine Linux is not officially supported by the RabbitMQ team -- use at your own risk! FROM alpine:3.22 AS build-base diff --git a/4.2/alpine/management/Dockerfile b/4.2/alpine/management/Dockerfile index 9864514b..a6adec76 100644 --- a/4.2/alpine/management/Dockerfile +++ b/4.2/alpine/management/Dockerfile @@ -6,18 +6,52 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: +FROM rabbitmq:4.2-alpine AS builder + +RUN set +e; set -ux; \ + apk add --no-cache build-base wget unzip musl-dev; \ + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v2.17.0.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ + echo "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4 rmqadmin.zip" | sha256sum -c -; \ + echo "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2 rustup-init.sh" | sha256sum -c -; \ + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-2.17.0"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ +# NOTE: since OpenSSL is dynamically linked to musl, rabbitmqadmin must also be (https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172) + export RUSTFLAGS="-C target-feature=-crt-static -C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + FROM rabbitmq:4.2-alpine RUN set -eux; \ rabbitmq-plugins enable --offline rabbitmq_management; \ # make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ - apk add --no-cache python3; \ - rabbitmqadmin --version + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/4.2/ubuntu/Dockerfile b/4.2/ubuntu/Dockerfile index 470c8a2f..19095db4 100644 --- a/4.2/ubuntu/Dockerfile +++ b/4.2/ubuntu/Dockerfile @@ -6,6 +6,7 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: # The official Canonical Ubuntu Focal image is ideal from a security perspective, # especially for the enterprises that we, the RabbitMQ team, have to deal with FROM ubuntu:24.04 AS build-base diff --git a/4.2/ubuntu/management/Dockerfile b/4.2/ubuntu/management/Dockerfile index d3d1f50b..075288e8 100644 --- a/4.2/ubuntu/management/Dockerfile +++ b/4.2/ubuntu/management/Dockerfile @@ -6,20 +6,52 @@ # PLEASE DO NOT EDIT IT DIRECTLY. # +# vim:noet: +FROM rabbitmq:4.2 AS builder + +RUN set +e; set -ux; \ + apt-get update; \ + apt-get install -y --no-install-recommends build-essential unzip wget; \ + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v2.17.0.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ + echo "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4 rmqadmin.zip" | sha256sum --check --strict -; \ + echo "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2 rustup-init.sh" | sha256sum --check --strict -; \ + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-2.17.0"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ + export RUSTFLAGS="-C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + FROM rabbitmq:4.2 RUN set -eux; \ rabbitmq-plugins enable --offline rabbitmq_management; \ # make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ - apt-get update; \ - apt-get install -y --no-install-recommends python3; \ - rm -rf /var/lib/apt/lists/*; \ - rabbitmqadmin --version + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index fdcccc7b..5f53bdf0 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -1,3 +1,4 @@ +# vim:noet: # Alpine Linux is not officially supported by the RabbitMQ team -- use at your own risk! FROM alpine:{{ .alpine.version }} AS build-base diff --git a/Dockerfile-management.template b/Dockerfile-management.template index c0d742de..79d1cedd 100644 --- a/Dockerfile-management.template +++ b/Dockerfile-management.template @@ -1,24 +1,69 @@ +# vim:noet: FROM {{ "rabbitmq:" + env.version + if env.variant == "alpine" then "-alpine" else "" end -}} +}} AS builder -RUN set -eux; \ - rabbitmq-plugins enable --offline rabbitmq_management; \ -# make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) - rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf; \ -# grab "rabbitmqadmin" from inside the "rabbitmq_management-X.Y.Z" plugin folder -# see https://github.com/docker-library/rabbitmq/issues/207 - cp /plugins/rabbitmq_management-*/priv/www/cli/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ - [ -s /usr/local/bin/rabbitmqadmin ]; \ - chmod +x /usr/local/bin/rabbitmqadmin; \ +RUN set +e; set -ux; \ {{ if env.variant == "alpine" then ( -}} - apk add --no-cache python3; \ + apk add --no-cache build-base wget unzip musl-dev; \ {{ ) else ( -}} apt-get update; \ - apt-get install -y --no-install-recommends python3; \ - rm -rf /var/lib/apt/lists/*; \ + apt-get install -y --no-install-recommends build-essential unzip wget; \ +{{ ) end -}} + \ + wget --quiet --output-document=rmqadmin.zip "https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v{{ .rabbitmqadmin.version }}.zip"; \ + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs; \ + \ +{{ if env.variant == "alpine" then ( -}} + echo "{{ .rabbitmqadmin.sha256 }} rmqadmin.zip" | sha256sum -c -; \ + echo "{{ .rabbitmqadmin.rustInitSha256 }} rustup-init.sh" | sha256sum -c -; \ +{{ ) else ( -}} + echo "{{ .rabbitmqadmin.sha256 }} rmqadmin.zip" | sha256sum --check --strict -; \ + echo "{{ .rabbitmqadmin.rustInitSha256 }} rustup-init.sh" | sha256sum --check --strict -; \ +{{ ) end -}} + \ + /bin/sh -x ./rustup-init.sh -y --default-toolchain stable --profile minimal; \ + . "$HOME/.cargo/env"; \ + unzip -q rmqadmin.zip; \ + cd "rabbitmqadmin-ng-{{ .rabbitmqadmin.version }}"; \ + export OPENSSL_DIR=/opt/openssl; \ + \ +{{ if env.variant == "alpine" then ( -}} +# NOTE: since OpenSSL is dynamically linked to musl, rabbitmqadmin must also be (https://users.rust-lang.org/t/sigsegv-with-program-linked-against-openssl-in-an-alpine-container/52172) + export RUSTFLAGS="-C target-feature=-crt-static -C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ +{{ ) else ( -}} + export RUSTFLAGS="-C link-arg=-Wl,-rpath,/opt/openssl/lib"; \ {{ ) end -}} - rabbitmqadmin --version + \ + if cargo build --release && [ -f target/release/rabbitmqadmin ]; then \ + cp target/release/rabbitmqadmin /usr/local/bin/rabbitmqadmin; \ + chmod +x /usr/local/bin/rabbitmqadmin; \ + else \ + echo "[INFO] could not build rabbitmqadmin-ng via Rust toolchain."; \ + fi + +RUN touch /usr/local/bin/rabbitmqadmin + +FROM {{ + "rabbitmq:" + env.version + + if env.variant == "alpine" then "-alpine" else "" end +}} + +RUN set -eux; \ + rabbitmq-plugins enable --offline rabbitmq_management; \ +# make sure the metrics collector is re-enabled (disabled in the base image for Prometheus-style metrics by default) + rm -f /etc/rabbitmq/conf.d/20-management_agent.disable_metrics_collector.conf + +# Copy Rust binary from builder if it exists +COPY --from=builder /usr/local/bin/rabbitmqadmin /tmp/rabbitmqadmin-rust + +RUN set -eux; \ + if [ -x /tmp/rabbitmqadmin-rust ]; then \ + mv /tmp/rabbitmqadmin-rust /usr/local/bin/rabbitmqadmin; \ + rabbitmqadmin --help; \ + else \ + echo "[INFO] rabbitmqadmin is not available on this platform."; \ + fi EXPOSE 15671 15672 diff --git a/Dockerfile-ubuntu.template b/Dockerfile-ubuntu.template index 5f700d6d..c5451a31 100644 --- a/Dockerfile-ubuntu.template +++ b/Dockerfile-ubuntu.template @@ -1,3 +1,4 @@ +# vim:noet: # The official Canonical Ubuntu Focal image is ideal from a security perspective, # especially for the enterprises that we, the RabbitMQ team, have to deal with FROM ubuntu:{{ .ubuntu.version }} AS build-base diff --git a/apply-templates.sh b/apply-templates.sh index cfeaf487..53a5dd12 100755 --- a/apply-templates.sh +++ b/apply-templates.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# vim:noet: set -Eeuo pipefail [ -f versions.json ] # run "versions.sh" first diff --git a/versions.json b/versions.json index 0732b9fc..b66274bf 100644 --- a/versions.json +++ b/versions.json @@ -11,6 +11,11 @@ "sha256": "932d091933f818d89c2cf7a8c23d84781bbae4b1ee7b846e8676e22768570cae", "version": "26.2.5.16" }, + "rabbitmqadmin": { + "rustInitSha256": "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2", + "sha256": "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4", + "version": "2.17.0" + }, "ubuntu": { "version": "24.04" }, @@ -29,6 +34,11 @@ "sha256": "658529f94cc5b8833907aa680a5e979e67c32dd6ebba69ed3b90b95f526ccda2", "version": "27.3.4.6" }, + "rabbitmqadmin": { + "rustInitSha256": "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2", + "sha256": "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4", + "version": "2.17.0" + }, "ubuntu": { "version": "24.04" }, @@ -47,6 +57,11 @@ "sha256": "658529f94cc5b8833907aa680a5e979e67c32dd6ebba69ed3b90b95f526ccda2", "version": "27.3.4.6" }, + "rabbitmqadmin": { + "rustInitSha256": "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2", + "sha256": "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4", + "version": "2.17.0" + }, "ubuntu": { "version": "24.04" }, @@ -65,6 +80,11 @@ "sha256": "658529f94cc5b8833907aa680a5e979e67c32dd6ebba69ed3b90b95f526ccda2", "version": "27.3.4.6" }, + "rabbitmqadmin": { + "rustInitSha256": "17247e4bcacf6027ec2e11c79a72c494c9af69ac8d1abcc1b271fa4375a106c2", + "sha256": "872860dcc3358467fc8f8447cf4364d2903658d2500af100771c4eaa6b3831d4", + "version": "2.17.0" + }, "ubuntu": { "version": "24.04" }, diff --git a/versions.sh b/versions.sh index 6612f337..999fc22c 100755 --- a/versions.sh +++ b/versions.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# vim:noet: set -Eeuo pipefail declare -A alpineVersions=( @@ -160,7 +161,30 @@ for version in "${versions[@]}"; do ubuntuVersion="${ubuntuVersions[$rcVersion]}" export ubuntuVersion - echo "$version: $fullVersion (otp $otpVersion, openssl $opensslVersion, alpine, $alpineVersion, ubuntu $ubuntuVersion)" + if [[ ${rabbitmqadminVersion:-undefined} == 'undefined' ]] + then + rabbitmqadminVersion="$(wget --quiet --output-document=- \ + --header='Accept: application/vnd.github+json' \ + --header='X-GitHub-Api-Version: 2022-11-28' \ + https://api.github.com/repos/rabbitmq/rabbitmqadmin-ng/releases/latest | jq -r '.tag_name')" + rabbitmqadminVersion="${rabbitmqadminVersion#v}" # NOTE: removes leading "v" + readonly rabbitmqadminVersion + + readonly rabbitmqadminSourceZipUrl="https://github.com/rabbitmq/rabbitmqadmin-ng/archive/refs/tags/v$rabbitmqadminVersion.zip" + wget --quiet --output-document=rmqadmin.zip "$rabbitmqadminSourceZipUrl" + rabbitmqadminSourceSha256="$(sha256sum rmqadmin.zip | cut -d' ' -f1)" + # TODO rm -f rmqadmin.zip + readonly rabbitmqadminSourceSha256 + + wget --quiet --output-document=rustup-init.sh https://sh.rustup.rs + rustInitSha256="$(sha256sum rustup-init.sh | cut -d' ' -f1)" + # TODO rm -f rustup-init.sh + readonly rustInitSha256 + + export rustInitSha256 rabbitmqadminVersion rabbitmqadminSourceSha256 + fi + + echo "$version: $fullVersion (otp $otpVersion, openssl $opensslVersion, rabbitmqadmin $rabbitmqadminVersion, alpine, $alpineVersion, ubuntu $ubuntuVersion)" json="$( jq <<<"$json" -c ' @@ -180,6 +204,11 @@ for version in "${versions[@]}"; do ubuntu: { version: env.ubuntuVersion }, + rabbitmqadmin: { + version: env.rabbitmqadminVersion, + sha256: env.rabbitmqadminSourceSha256, + rustInitSha256: env.rustInitSha256, + }, } ' )"