Skip to content

Commit

Permalink
Chengjie8/issue 2428 (#2460)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
chengjie8 and abd-vro-machine authored Jan 25, 2024
1 parent 7e7a504 commit 451be65
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
15 changes: 15 additions & 0 deletions rabbitmq/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 4 additions & 0 deletions rabbitmq/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ plugins {
group = 'gov.va.vro'
version = '3.5.4-SNAPSHOT'

docker {
copySpec.from("src/main/resources").into(".")
}

repositories {
mavenCentral()
}
Expand Down
24 changes: 24 additions & 0 deletions rabbitmq/src/main/resources/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions rabbitmq/src/main/resources/rabbitmq.conf
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 451be65

Please sign in to comment.