commit e6261c6c6e4e397284df6c66eb16099628929459 Author: Piotr Biernat Date: Wed Nov 30 02:28:31 2022 +0100 Initial diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..6218503 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,36 @@ +kind: pipeline +type: docker +name: default + +steps: +- name: publish_image + image: plugins/docker + environment: + DOCKER_USERNAME: + from_secret: registry_username + DOCKER_PASSWORD: + from_secret: registry_password + commands: + - sleep 5 + - ./deploy/image-build.sh + - ./deploy/image-push.sh + volumes: + - name: docker-sock + path: /var/run + when: + branch: + - main + +services: +- name: docker + image: docker:dind + privileged: true + volumes: + - name: docker-sock + path: /var/run + +volumes: +- name: gopath + temp: {} +- name: docker-sock + temp: {} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dcc268c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM rabbitmq:3-management-alpine + +LABEL author="Piotr Biernat" +LABEL service="api-eventubus" +LABEL vendor="Egommerce" +LABEL version="1.0" + +COPY ./api-eventbus/etc /etc/rabbitmq + +RUN rabbitmq-plugins --offline enable rabbitmq_peer_discovery_consul + +EXPOSE 5672 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1b190e9 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +DEPLOY_DIR := ./deploy +SRC_DIR := ./src + +## DEPLOY PART +build-image-dev: + - sh ${DEPLOY_DIR}/image-build.sh dev + +build-image-prod: + - sh ${DEPLOY_DIR}/image-build.sh + +push-image-prod: + - sh ${DEPLOY_DIR}/image-push.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..e75f70c --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# api-eventbus + +API Eventbus - RabbitMQ Queue diff --git a/api-eventbus/etc/conf.d/40-logs-syslog.conf b/api-eventbus/etc/conf.d/40-logs-syslog.conf new file mode 100644 index 0000000..9484129 --- /dev/null +++ b/api-eventbus/etc/conf.d/40-logs-syslog.conf @@ -0,0 +1,5 @@ +log.syslog = true +log.syslog.host = api-logger +log.syslog.port = 5140 + +log.default.level = warning diff --git a/api-eventbus/etc/conf.d/50-plugin-consul.conf b/api-eventbus/etc/conf.d/50-plugin-consul.conf new file mode 100644 index 0000000..4c88b87 --- /dev/null +++ b/api-eventbus/etc/conf.d/50-plugin-consul.conf @@ -0,0 +1,7 @@ +cluster_formation.peer_discovery_backend = consul + +cluster_formation.consul.host = api-registry + +cluster_formation.consul.svc_addr_auto = false +cluster_formation.consul.svc = api-eventbus +cluster_formation.consul.svc_addr = api-eventbus diff --git a/deploy/image-build.sh b/deploy/image-build.sh new file mode 100755 index 0000000..63d2dbb --- /dev/null +++ b/deploy/image-build.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# RUN IN REPO ROOT DIR !! + +export IMAGE_NAME="git.pbiernat.dev/egommerce/api-eventbus" + +TARGET=${1:-latest} + +echo "Building: $IMAGE_NAME:$TARGET" +if [ $TARGET = "dev" ] +then + docker build --rm --no-cache -t "$IMAGE_NAME:dev" . # >/dev/null 2>&1 +else + docker build --rm --cache-from "$IMAGE_NAME:$TARGET" -t "$IMAGE_NAME:$TARGET" . >/dev/null 2>&1 +fi + +echo "Done." diff --git a/deploy/image-push.sh b/deploy/image-push.sh new file mode 100755 index 0000000..0c89126 --- /dev/null +++ b/deploy/image-push.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# RUN IN REPO ROOT DIR !! + +export IMAGE_NAME="git.pbiernat.dev/egommerce/api-eventbus" + +echo $DOCKER_PASSWORD | docker login git.pbiernat.dev -u $DOCKER_USERNAME --password-stdin +docker push "$IMAGE_NAME:latest"