-
Notifications
You must be signed in to change notification settings - Fork 846
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
99 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,21 @@ FROM rabbitmq:3.12-management-alpine | |
LABEL maintainer="574/[email protected]" | ||
LABEL version="0.62.6" | ||
|
||
ARG RABBIT_MQ_DEFAULT_USER | ||
ARG RABBIT_MQ_DEFAULT_PASSWORD | ||
ARG RABBIT_MQ_DEFAULT_VHOST | ||
|
||
COPY --chown=rabbitmq:rabbitmq ./docker/rabbitmq/augur.conf /etc/rabbitmq/conf.d/ | ||
|
||
ADD docker/rabbitmq/definitions.json /etc/rabbitmq/ | ||
RUN chown rabbitmq:rabbitmq /etc/rabbitmq/definitions.json | ||
|
||
ADD docker/rabbitmq/advanced.config /etc/rabbitmq/ | ||
RUN chown rabbitmq:rabbitmq /etc/rabbitmq/advanced.config | ||
|
||
RUN chmod 777 /etc/rabbitmq/conf.d/augur.conf | ||
|
||
RUN touch /etc/rabbitmq/advanced.config \ | ||
&& chmod 544 /etc/rabbitmq/advanced.config \ | ||
&& echo '[ {rabbit, [ {consumer_timeout, undefined} ]} ].' >> /etc/rabbitmq/advanced.config | ||
RUN apk add --no-cache python3 | ||
COPY docker/rabbitmq/update_config.py / | ||
|
||
RUN exec python3 update_config.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{rabbit, [ | ||
{loopback_users, []}, | ||
{consumer_timeout, undefined} | ||
]}, | ||
{rabbitmq_management, [ | ||
{load_definitions, "/etc/rabbitmq/definitions.json"} | ||
]} | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"rabbit_version": "3.12", | ||
"users": [ | ||
{ | ||
"name": "", | ||
"password_hash": "", | ||
"hashing_algorithm": "rabbit_password_hashing_sha256", | ||
"tags": "administrator" | ||
} | ||
], | ||
"vhosts": [ | ||
{ | ||
"name": "" | ||
} | ||
], | ||
"permissions": [ | ||
{ | ||
"user": "", | ||
"vhost": "", | ||
"configure": ".*", | ||
"write": ".*", | ||
"read": ".*" | ||
} | ||
], | ||
"parameters": [], | ||
"policies": [], | ||
"queues": [], | ||
"exchanges": [], | ||
"bindings": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from os import environ as env | ||
import json, subprocess | ||
from pathlib import Path | ||
|
||
rabbit_user = env.get("RABBIT_MQ_DEFAULT_USER") | ||
rabbit_pass = env.get("RABBIT_MQ_DEFAULT_PASSWORD") | ||
rabbit_vhost = env.get("RABBIT_MQ_DEFAULT_VHOST") | ||
|
||
if not rabbit_user: | ||
raise ValueError("No default user set") | ||
|
||
if not rabbit_pass: | ||
raise ValueError("No default password set") | ||
|
||
if not rabbit_vhost: | ||
raise ValueError("No default vhost set") | ||
|
||
config_file = Path("/etc/rabbitmq/definitions.json") | ||
|
||
with config_file.open() as file: | ||
config = json.load(file) | ||
|
||
hash_processor = subprocess.run(f"rabbitmqctl hash_password {rabbit_pass}".split(), | ||
text=True, | ||
stdout=subprocess.PIPE) | ||
|
||
if hash_processor.returncode != 0: | ||
raise Exception("Could not calculate password hash") | ||
|
||
pass_hash = hash_processor.stdout.splitlines()[-1] | ||
|
||
config["users"][0]["name"] = rabbit_user | ||
config["users"][0]["password_hash"] = pass_hash | ||
|
||
config["vhosts"][0]["name"] = rabbit_vhost | ||
|
||
config["permissions"][0]["user"] = rabbit_user | ||
config["permissions"][0]["vhost"] = rabbit_vhost | ||
|
||
with config_file.open("w") as file: | ||
json.dump(config, file) |