From d01fd99d6faa17f355def93cfdb0fdfb00b229bd Mon Sep 17 00:00:00 2001 From: Pavel Dmitriev Date: Mon, 9 Jan 2023 18:30:35 +0300 Subject: [PATCH] Added samples and CI --- .drone.yml | 24 ++++++++++++++++++++++++ sample/docker-compose.yml | 26 ++++++++++++++++++++++++++ sample/rabbitmq/rabbitmq.config | 31 +++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 .drone.yml create mode 100644 sample/docker-compose.yml create mode 100644 sample/rabbitmq/rabbitmq.config diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..e9f8d17 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,24 @@ +kind: pipeline +name: Build image +image_pull_secrets: + - dockerconfig +steps: + - name: Build docker image + image: mxfox.ru/mxfox/docker-dind.buildx:latest + privileged: true + environment: + DOCKER_AUTH: + from_secret: dockerconfig + IMAGE_PREFIX: mxfox.ru/mxfox/rabbitmq + + commands: + - buildx-bgstart.sh + - echo $${DOCKER_AUTH} > ~/.docker/config.json + - | + if [ -n "${DRONE_TAG}" ] + then + export xBuildSuffix=" -t $${IMAGE_PREFIX}:${DRONE_TAG} -t $${IMAGE_PREFIX}:latest --push" + else + export xBuildSuffix=" -t $${IMAGE_PREFIX}:${CI_COMMIT_BRANCH}-${CI_BUILD_NUMBER}-${DRONE_COMMIT_SHA:0:10} -t $${IMAGE_PREFIX}:${CI_COMMIT_BRANCH} --push" + fi + - docker buildx build --platform linux/amd64,linux/arm64,linux/arm . $${xBuildSuffix} diff --git a/sample/docker-compose.yml b/sample/docker-compose.yml new file mode 100644 index 0000000..40eb235 --- /dev/null +++ b/sample/docker-compose.yml @@ -0,0 +1,26 @@ +version: "2" + +services: + + rabbitmq: + image: "mxfox.ru/mxfox/rabbitmq:main" + networks: + - interlink + volumes: + - ./rabbitmq/rabbitmq.config:/etc/rabbitmq/rabbitmq.config + + ports: + - "5672:5672" + - "15672:15672" + environment: + - RABBITMQ_DEFAULT_USER=${RABBITMQ_ADMIN_USER:-guest} + - RABBITMQ_DEFAULT_PASS=${RABBITMQ_ADMIN_PASS:-guest} + + rabbitmq-tcprelay: + restart: "on-failure" + image: "cloudamqp/websocket-tcp-relay" + networks: + - interlink + command: "--upstream tcp://rabbitmq:5672" + ports: + - "15670:15670" \ No newline at end of file diff --git a/sample/rabbitmq/rabbitmq.config b/sample/rabbitmq/rabbitmq.config new file mode 100644 index 0000000..89b59a1 --- /dev/null +++ b/sample/rabbitmq/rabbitmq.config @@ -0,0 +1,31 @@ +[ + %% Enable rabbit_auth_backend_oauth2 + {rabbit, [ + {auth_backends, [rabbit_auth_backend_oauth2, rabbit_auth_backend_internal]} + ]}, + + {rabbitmq_management, [ + {enable_uaa, true}, + {uaa_client_id, "rabbit_user_client"}, + {uaa_location, "http://localhost:8080/uaa"} + ]}, + + %% Set a resource server ID. Will require all scopes to be prefixed with `rabbitmq.` + {rabbitmq_auth_backend_oauth2, [ + {resource_server_id, <<"rabbitmq">>}, + % Set up a legacy signing key + {key_config, [ + {default_key, <<"legacy-token-key">>}, + {signing_keys, #{ + <<"legacy-token-key">> => + {map, #{ + <<"alg">> => <<"HS256">>, + <<"value">> => <<"rabbit_signing_key">>, + <<"kty">> => <<"MAC">>, + <<"use">> => <<"sig">>} + } + } + } %% signing keys + ]} % key_config + ]} % rabbitmq_auth_backend_oauth2 +].