From 451be65cd3b0f4c72dda204cbf837106192061e1 Mon Sep 17 00:00:00 2001 From: Cheng <89034346+chengjie8@users.noreply.github.com> Date: Thu, 25 Jan 2024 14:55:49 -0500 Subject: [PATCH] Chengjie8/issue 2428 (#2460) * disable loopback user for rabbitmq * minor change * minor update * minor change * clean up and added rabbitmq conf file * minor change * update back * minor change * added entrypoint script for setting rabbitmq conf file * minor change' * Automated commit: Unpin versions of updated images * use entrypoint.sh file * entrypoint.sh changes * minor change * clean up * rollback minor changes * limit free disk space to 10gb --------- Co-authored-by: VRO Machine User --- rabbitmq/Dockerfile | 15 ++++++++++++++ rabbitmq/build.gradle | 4 ++++ rabbitmq/src/main/resources/entrypoint.sh | 24 ++++++++++++++++++++++ rabbitmq/src/main/resources/rabbitmq.conf | 25 +++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100755 rabbitmq/src/main/resources/entrypoint.sh create mode 100644 rabbitmq/src/main/resources/rabbitmq.conf diff --git a/rabbitmq/Dockerfile b/rabbitmq/Dockerfile index 9365da191f..c10b8efbd5 100644 --- a/rabbitmq/Dockerfile +++ b/rabbitmq/Dockerfile @@ -1 +1,16 @@ +# Use the Bitnami RabbitMQ image as the base FROM bitnami/rabbitmq:3.12 + +COPY rabbitmq.conf /tmp/rabbitmq.conf + +USER root + +RUN chown 1001 /tmp/rabbitmq.conf \ + && chmod g+w /tmp/rabbitmq.conf + +USER 1001 + +## Copy the entrypoint script +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/rabbitmq/build.gradle b/rabbitmq/build.gradle index a1dd8f532c..f341d7170f 100644 --- a/rabbitmq/build.gradle +++ b/rabbitmq/build.gradle @@ -5,6 +5,10 @@ plugins { group = 'gov.va.vro' version = '3.5.4-SNAPSHOT' +docker { + copySpec.from("src/main/resources").into(".") +} + repositories { mavenCentral() } diff --git a/rabbitmq/src/main/resources/entrypoint.sh b/rabbitmq/src/main/resources/entrypoint.sh new file mode 100755 index 0000000000..eb35d5e647 --- /dev/null +++ b/rabbitmq/src/main/resources/entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -e + +# Check if RABBITMQ_USERNAME or RABBITMQ_USER is set and assign it to a variable +if [ ! -z "$RABBITMQ_USERNAME" ]; then + RABBITMQ_USER_VALUE="$RABBITMQ_USERNAME" +elif [ ! -z "$RABBITMQ_USER" ]; then + RABBITMQ_USER_VALUE="$RABBITMQ_USER" +else + echo "Neither RABBITMQ_USERNAME nor RABBITMQ_USER is set. Exiting." + exit 1 +fi + +# Define the path to your configuration file +CONFIG_FILE="/tmp/rabbitmq.conf" + +# Replace lines in the config file +sed -i "s/^default_user .*/default_user = $RABBITMQ_USER_VALUE/" $CONFIG_FILE +sed -i "s/^default_pass .*/default_pass = ${RABBITMQ_PASSWORD}/" $CONFIG_FILE + + +cp /tmp/rabbitmq.conf /etc/rabbitmq/rabbitmq.conf + +exec /opt/bitnami/scripts/rabbitmq/entrypoint.sh /opt/bitnami/scripts/rabbitmq/run.sh diff --git a/rabbitmq/src/main/resources/rabbitmq.conf b/rabbitmq/src/main/resources/rabbitmq.conf new file mode 100644 index 0000000000..8009ae7be9 --- /dev/null +++ b/rabbitmq/src/main/resources/rabbitmq.conf @@ -0,0 +1,25 @@ +## Clustering +cluster_partition_handling = ignore + +## Defaults +# During the first start, RabbitMQ will create a vhost and a user +# These config items control what gets created +default_permissions.configure = .* +default_permissions.read = .* +default_permissions.write = .* +log.console = true +default_vhost = / +default_user = guest +default_pass = guest + +## Networking +listeners.tcp.default = 5672 + +## Management +management.tcp.ip = 0.0.0.0 +management.tcp.port = 15672 +loopback_users.user = false + +## Resource limits +# Set a free disk space limit relative to total available RAM +disk_free_limit.absolute = 10GB