Skip to content

Commit

Permalink
Merge pull request #7 from teufelaudio/task/WEBDEV-9814-make-rabbitmq…
Browse files Browse the repository at this point in the history
…-configurable

Make RabbitMQ Configurable
  • Loading branch information
hgajjar authored Feb 27, 2025
2 parents 1d44f03 + 5e542bd commit 4f97f42
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 9 deletions.
1 change: 1 addition & 0 deletions .ci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp-test
6 changes: 6 additions & 0 deletions .ci/sample-dynamic/harnesses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"inviqa/spryker": {
"vx.x.x": {
}
}
}
2 changes: 2 additions & 0 deletions .ci/sample-dynamic/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ workspace('ci-spryker-sample-dynamic'):
description: generated local workspace for ci-spryker-sample.
harness: inviqa/spryker

harness.repository.source('name'): ./harnesses.json

attribute('aws.bucket'): null
attribute('app.repository'): null
attribute('aws.access_key_id'): null
Expand Down
6 changes: 6 additions & 0 deletions .ci/sample-static/harnesses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"inviqa/spryker": {
"vx.x.x": {
}
}
}
7 changes: 3 additions & 4 deletions .ci/sample-static/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ workspace('ci-spryker-sample-static'):
description: generated local workspace for ci-spryker-sample.
harness: inviqa/spryker

harness.repository.source('name'): ./harnesses.json

attribute('app.build'): static

attribute('aws.bucket'): null
attribute('app.repository'): null
attribute('aws.access_key_id'): null
attribute('aws.secret_access_key'): null

attribute('spryker.oauth_client_secret'): '= decrypt("YTozOntpOjA7czo3OiJkZWZhdWx0IjtpOjE7czoyNDoi/ZxjAtTonBTdHCfPRmh3rlDOOTPZ8oaVIjtpOjI7czo2NDoiXHkN92FXiuuj/PVZKwzJEKtsQzRtAEvdPSYT/6mEA2GVtk+98N4ch+y+MVbg6REiwTAFXOZSb7lEyqZOJMEY+iI7fQ==")'
attribute('spryker.zed_request_token'): '= decrypt("YTozOntpOjA7czo3OiJkZWZhdWx0IjtpOjE7czoyNDoi5TNpTpnAi3Yjlstw46A63Pvn1nnGoE1VIjtpOjI7czo5NjoiFHj6M4K5I2pUBD5t2nnjzhR6jixzGOtQl/HSBWWyrD9TFmg+Qw82CLZlqBYgQXaCDiOB1GV9tVKAuvvr9ntHZ0KWeZLu5spfhdaqcVsJVm2kxNX6A1YKb5mw/g4V4NvAIjt9")'
attribute('aws.secret_access_key'): null
36 changes: 36 additions & 0 deletions .ci/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail
set -o xtrace

export path_test=".ci/tmp-test"

function setup()
(
local mode="$1"

if [ -d "${path_test}" ]; then
rm -rf "${path_test}"
fi

cp -ap ".ci/sample-${mode}" "${path_test}"
rsync --archive --exclude="**/.git" --exclude="**/.ci" ./ "${path_test}/.my127ws/"
)

function prepare_environment()
(
cd "${path_test}"
ws harness prepare
)

function main()
{
local mode="$1"

setup "$mode"
prepare_environment
}

main "$@"
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ To generate and encrypt secrets for pipeline environments:
https://github.com/inviqa/k8s-project-cluster/blob/0.1.x-dev/docs/cluster-management/sealed-secrets/README.md

[Workspace]: https://github.com/my127/workspace

## How to test?
There are two modes of this harness: static (for CI environment) and dynamic (for local environment).
Static mode is a fixed file system, and dynamic uses mutagen to sync file changes with the console and php-fpm containers.

You can test both of them using below command:
```sh
.ci/test static
.ci/test dynamic
```
It will create a new directory at `.ci/tmp-test` that will compile the harness and find any twig compilation errors.
6 changes: 6 additions & 0 deletions _twig/docker-compose.yml/service/rabbitmq.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
- traefik.port={{ @('rabbitmq.api_port') }}
- co.elastic.logs/module=rabbitmq
- co.elastic.metrics/module=rabbitmq
volumes:
- ./.my127ws/docker/image/rabbitmq/root/etc/rabbitmq/definitions.json:/etc/rabbitmq/definitions.json:ro
- ./.my127ws/docker/image/rabbitmq/root/etc/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins:ro
{% if @('app.build') != 'static' and @('rabbitmq.port_forward') is not empty %}
ports: {{ to_nice_yaml(@('rabbitmq.port_forward'), 2, 6) | raw }}
{% endif %}
39 changes: 39 additions & 0 deletions docker/image/rabbitmq/root/etc/rabbitmq/definitions.json.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% spaceless %}
{% set vhosts = [] %}
{% for vhost in @('rabbitmq.vhosts') %}
{% set vhosts = vhosts | merge([{"name": vhost,"metadata": {"description": "","tags": []}, "limits": []}]) %}
{% endfor %}
{% set users = [] %}
{% set permissions = [] %}
{% for user in @('rabbitmq.users') %}
{% set users = users | merge([{
"hashing_algorithm": "rabbit_password_hashing_sha256",
"name": user.username,
"password_hash": user.password_hash,
"tags": user.tags
}]) %}
{% for permission in user.permissions %}
{% set permissions = permissions | merge([{
"configure": permission.configure,
"read": permission.read,
"user": user.username,
"vhost": permission.vhost,
"write": permission.write
}]) %}
{% endfor %}
{% endfor %}
{% endspaceless %}
{
"bindings": [],
"exchanges": [],
"global_parameters": [],
"parameters": [],
"permissions": {{ permissions | json_encode(constant('JSON_UNESCAPED_SLASHES')) }},
"policies": [],
"queues": [],
"rabbit_version": "{{ @('rabbitmq.version') }}",
"rabbitmq_version": "{{ @('rabbitmq.version') }}",
"topic_permissions": [],
"users": {{ users | json_encode(constant('JSON_UNESCAPED_SLASHES')) }},
"vhosts": {{ vhosts | json_encode(constant('JSON_UNESCAPED_SLASHES')) }}
}
1 change: 1 addition & 0 deletions docker/image/rabbitmq/root/etc/rabbitmq/enabled_plugins
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[rabbitmq_management,rabbitmq_stream_management].
16 changes: 12 additions & 4 deletions harness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,18 @@ attributes:
user: spryker
password: spryker
vhosts:
default: 'de-spryker'
DE: = 'de-spryker'
AT: = 'at-spryker'
US: = 'us-spryker'
default: '/'
port_forward: []
users:
- username: spryker
password_hash: yRrkqC5fk0FMKj8psg3CmwF8K0YhQL5x6bfRXBtfve+BIq3g
tags:
- administrator
permissions:
- vhost: '/'
configure: '.*'
write: '.*'
read: '.*'
jenkins:
host: jenkins
port: 8080
Expand Down
3 changes: 2 additions & 1 deletion harness/attributes/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ attributes.default:

rabbitmq:
image: rabbitmq
tag: '3.8-management-alpine'
tag: '3.12-management-alpine'
version: '3.12.14'
api_port: 15672
erlang_cookie: TeTTiwT9y548yIcfw4peaOrqgtLItD6B
external_host: = 'rabbitmq-' ~ @('hostname')
Expand Down
4 changes: 4 additions & 0 deletions harness/attributes/docker-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,18 @@ attributes:
rabbitmq:
enabled: "= 'rabbitmq' in @('app.services')"
image: = @('rabbitmq.image') ~ ':' ~ @('rabbitmq.tag')
version:
environment:
RABBITMQ_DEFAULT_USER: = @('rabbitmq.user')
RABBITMQ_DEFAULT_VHOST: = @('rabbitmq.vhosts.default')
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: "-rabbitmq_management load_definitions '/etc/rabbitmq/definitions.json'"
environment_secrets:
RABBITMQ_DEFAULT_PASS: = @('rabbitmq.password')
RABBITMQ_ERLANG_COOKIE: = @('rabbitmq.erlang_cookie')
resources:
memory: "1024Mi"
chrome:
image: = 'yukinying/chrome-headless-browser-stable:125.0.6422.141'
redis:
image: redis:6-alpine
options:
Expand Down
1 change: 1 addition & 0 deletions harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ confd('harness:/'):
- { src: docker/image/elasticsearch/Dockerfile }
- { src: docker/image/lighthouse/Dockerfile }
- { src: docker/image/lighthouse/root/app/run.sh }
- { src: docker/image/rabbitmq/root/etc/rabbitmq/definitions.json }
- { src: docker/image/nginx/Dockerfile }
- { src: docker/image/nginx/root/docker-entrypoint.d/config_render.sh }
- { src: docker/image/nginx/root/etc/nginx/conf.d/0-nginx.conf }
Expand Down
5 changes: 5 additions & 0 deletions harnesses.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"type": "tar.gz",
"url": "https://github.com/teufelaudio/harness-spryker/archive/1.6.4.tar.gz",
"date": "2025-02-17"
},
"v1.6.5": {
"type": "tar.gz",
"url": "https://github.com/teufelaudio/harness-spryker/archive/1.6.5.tar.gz",
"date": "2025-02-26"
}
}
}

0 comments on commit 4f97f42

Please sign in to comment.