From 96fe2133dcc27b25ea746613850b0fd193ada500 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Wed, 31 Aug 2022 15:47:18 +0200 Subject: [PATCH 1/3] :memo: Document deployment via docker --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 78c38dc..52d39c8 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,19 @@ caught by the gateway and not emitted to the exchange. ## Deployment +Both deployment methods below expect the configuration in a `.env` file. +This file is part of the `.gitignore` and can safely be left in the local working copy. + +### Docker + +The gateway is intended to be run as a Docker container: +```bash +docker run --rm \ + -p 8080:8080 \ + --env-file .env \ + netz39/power-meter-pulse-gateway +``` + ### Development This project uses the [Micronaut Framework](https://micronaut.io/). @@ -67,13 +80,11 @@ Version numbers are determined with [jgitver](https://jgitver.github.io/). Please check your [IDE settings](https://jgitver.github.io/#_ides_usage) to avoid problems, as there are still some unresolved issues. If you encounter a project version `0` there is an issue with the jgitver generator. -For local execution the configuration can be provided in a `.env` file and made available using `dotenv`: +To use the configuration from a `.env` file, run using [dotenv](https://github.com/therootcompany/dotenv): ```bash dotenv ./mvnw mn:run ``` -Note that `.env` is part of the `.gitignore` and can be safely stored in the local working copy. - ## Build The build is split into two stages: From 12ca360f0beaaf84aba82fa42becc3056d58fdda Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Wed, 31 Aug 2022 15:50:36 +0200 Subject: [PATCH 2/3] :pencil2: Minior fixes in the README file --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 52d39c8..5ff0229 100644 --- a/README.md +++ b/README.md @@ -4,21 +4,21 @@ ## Configuration -Configuration is done using environment variables: +The service is configure with environment variables: -* `PORT`: Port for the HTTP endpoint (default `8080`, only change when running locally!) * `AMQP_HOST`: RabbitMQ host * `AMQP_USER`: RabbitMQ user * `AMQP_PASS`: RabbitMQ password * `AMQP_VHOST`: RabbitMQ virtual host, defaults to '/' * `PULSE_BINDING`: RabbitMQ routing key name for pulse messages * `API_TOKEN`: An API token for accessing the endpoint (default: empty, no authorization) +* `PORT`: Port for the HTTP endpoint (default `8080`, only change when running locally!) ## API ### Pulse Message -Pulses are encoded as messages with a [ISO 8601 timestamp](https://en.wikipedia.org/wiki/ISO_8601) in the JSON form +Pulses are encoded as messages with an [ISO 8601 timestamp](https://en.wikipedia.org/wiki/ISO_8601) in the JSON form ```json { "timestamp": "2022-08-23T16:54:23Z" @@ -42,8 +42,7 @@ This call returns one of the following codes: On return code `504` the call should be retried at a later point. In any other case the call should not be retried. -Please note that the gateway send any valid JSON message to the AMQP queue. -Idempotency is not considered by the gateway in the sense that an already sent timestamp will not be suppressed. +Please note that idempotency is not considered by the gateway in the sense that an already sent timestamp will not be suppressed. An [OAS3 schema ](https://swagger.io/specification/) can be obtained under the URL `/swagger/power-meter-pulse-gateway-0.1.yml`. From 58b503980b83c69c3a0ff2967624803ea55e5f3a Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Wed, 31 Aug 2022 15:54:42 +0200 Subject: [PATCH 3/3] :memo: Add status badges for CI workflows --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ff0229..7b8fca8 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # Power Meter Pulse Gateway +[![Maven Tests](https://github.com/netz39/power-meter-pulse-gateway/actions/workflows/maven-test.yml/badge.svg)](https://github.com/netz39/power-meter-pulse-gateway/actions/workflows/maven-test.yml) +[![Docker Publish](https://github.com/netz39/power-meter-pulse-gateway/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/netz39/power-meter-pulse-gateway/actions/workflows/docker-publish.yml) + > Gateway for Power Meter Pulses from an ESP32 (or another REST client) to RabbitMQ ## Configuration -The service is configure with environment variables: +The service is configured with environment variables: * `AMQP_HOST`: RabbitMQ host * `AMQP_USER`: RabbitMQ user