From b73b36e6680e42bc1d83321fbac32a9be8ef6803 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Wed, 30 Nov 2022 02:25:25 +0100 Subject: [PATCH] Initial --- .drone.yml | 36 ++++++++++++++++++++++++++++++++++++ Dockerfile | 20 ++++++++++++++++++++ Makefile | 12 ++++++++++++ README.md | 12 ++++++++++++ api-logger/etc/fluent.conf | 22 ++++++++++++++++++++++ deploy/image-build.sh | 16 ++++++++++++++++ deploy/image-push.sh | 7 +++++++ 7 files changed, 125 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 README.md create mode 100644 api-logger/etc/fluent.conf create mode 100755 deploy/image-build.sh create mode 100755 deploy/image-push.sh 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..2828ee2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM fluent/fluentd:v1.15.3-1.0 + +LABEL author="Piotr Biernat" +LABEL service="api-logger" +LABEL vendor="Egommerce" +LABEL version="1.0" + +USER root +RUN ["fluent-gem", "install", "fluent-plugin-rabbitmq"] +# RUN ["gem", "install", "fluent-plugin-rabbitmq"] + +USER fluent +COPY ./api-logger/etc /fluentd/etc + + + +CMD ["fluentd"] +# ENTRYPOINT ["/traefik"] # FIXME stack->stack config.yml + +EXPOSE 24224 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..c050492 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# apigw-service + +API Gateway - simple Nginx image with pre-configured reverse proxy's + +Generowanie Klucza autoryzacji +$ openssl rand -base64 24 + +Budowanie obrazu: +$ sh deploy/image-build.sh + +Opublikowanie obrazu: +$ sh deploy/image-push.sh diff --git a/api-logger/etc/fluent.conf b/api-logger/etc/fluent.conf new file mode 100644 index 0000000..3adf24e --- /dev/null +++ b/api-logger/etc/fluent.conf @@ -0,0 +1,22 @@ + + @type forward + port 24224 + bind 0.0.0.0 + + + @type stdout + + + + @type syslog + port 5140 + bind 0.0.0.0 + tag syslog + + + @type stdout + # + # expression /\A\<(?[0-9]{1,3})\>[1-9]\d{0,2} (? + diff --git a/deploy/image-build.sh b/deploy/image-build.sh new file mode 100755 index 0000000..e5e755a --- /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-logger" + +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..3320c3c --- /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-logger" + +echo $DOCKER_PASSWORD | docker login git.pbiernat.dev -u $DOCKER_USERNAME --password-stdin +docker push "$IMAGE_NAME:latest"