diff --git a/.app.config b/.app.config new file mode 100644 index 0000000..25c6444 --- /dev/null +++ b/.app.config @@ -0,0 +1,16 @@ +{ + "ID": "logger", + "Name": "logger", + "Address": "__IP__", + "Tags": ["api-logger", "logger", "tcp", "fluentd"], + "Port": 24224, + "Connect": { + "Native": true + }, + "Check": { + "TCP": "__IP__:24224", + "Interval": "10s", + "Timeout": "10s", + "DeregisterCriticalServiceAfter": "5m" + } +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a429fd5..9691a5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,14 @@ USER root RUN ["fluent-gem", "install", "fluent-plugin-rabbitmq"] USER fluent -COPY ./api-logger/etc /fluentd/etc - -CMD ["fluentd"] +COPY ./api-logger/etc /etc/fluent +COPY ./api-logger/entrypoint.sh / +COPY ./.app.config / EXPOSE 24224 + +USER root +ENTRYPOINT ["/entrypoint.sh"] + +# USER fluent +CMD ["fluentd"] diff --git a/Makefile b/Makefile index 1b190e9..62b562b 100644 --- a/Makefile +++ b/Makefile @@ -8,5 +8,8 @@ build-image-dev: build-image-prod: - sh ${DEPLOY_DIR}/image-build.sh +push-image-dev: + - sh ${DEPLOY_DIR}/image-push.sh dev + push-image-prod: - sh ${DEPLOY_DIR}/image-push.sh diff --git a/api-logger/entrypoint.sh b/api-logger/entrypoint.sh new file mode 100755 index 0000000..dc44185 --- /dev/null +++ b/api-logger/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +update-ca-certificates + +# su fluent +update-resolv # FIXME: lack of permissions to /etc/resolv.conf +register-service + +exec "$@" diff --git a/deploy/image-build.sh b/deploy/image-build.sh index e5e755a..a38bba2 100755 --- a/deploy/image-build.sh +++ b/deploy/image-build.sh @@ -1,7 +1,7 @@ #!/bin/sh # RUN IN REPO ROOT DIR !! -export IMAGE_NAME="git.pbiernat.dev/egommerce/api-logger" +export IMAGE_NAME="git.pbiernat.io/egommerce/api-logger" TARGET=${1:-latest} diff --git a/deploy/image-push.sh b/deploy/image-push.sh index 5ebf0c3..809438b 100755 --- a/deploy/image-push.sh +++ b/deploy/image-push.sh @@ -1,9 +1,12 @@ #!/bin/sh # RUN IN REPO ROOT DIR !! -export IMAGE_NAME="git.pbiernat.dev/egommerce/api-logger" +export IMAGE_NAME="git.pbiernat.io/egommerce/api-logger" TARGET=${1:-latest} -echo $DOCKER_PASSWORD | docker login git.pbiernat.dev -u $DOCKER_USERNAME --password-stdin +echo $DOCKER_PASSWORD | docker login git.pbiernat.io -u $DOCKER_USERNAME --password-stdin docker push "$IMAGE_NAME:$TARGET" + +# Restart container +curl -X POST http://127.0.0.1:9001/api/webhooks/14bae058-088f-4895-99ef-ec9383857c41