mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-24 13:48:49 +08:00
MF-998 - Add Twins service to Makefile and docker-compose.yml (#1035)
* Add separate twins mongodb Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Move twins docker compose file to addons Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add depends_on to mainflux-twins container Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Remove hard-coded vals from .env Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Add start explanation to README.md Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com> * Bump mongo image to latest version Signed-off-by: Darko Draskovic <darko.draskovic@gmail.com>
This commit is contained in:
parent
1c2c86b030
commit
51cd0524a1
17
.env
17
.env
@ -196,3 +196,20 @@ MF_POSTGRES_READER_DB_SSL_MODE=disable
|
||||
MF_POSTGRES_READER_DB_SSL_CERT=""
|
||||
MF_POSTGRES_READER_DB_SSL_KEY=""
|
||||
MF_POSTGRES_READER_DB_SSL_ROOT_CERT=""
|
||||
|
||||
# Twins
|
||||
MF_TWINS_LOG_LEVEL=debug
|
||||
MF_TWINS_HTTP_PORT=9021
|
||||
MF_TWINS_SERVER_CERT=""
|
||||
MF_TWINS_SERVER_KEY=""
|
||||
MF_TWINS_DB_NAME=mainflux-twins
|
||||
MF_TWINS_DB_HOST=twins-db
|
||||
MF_TWINS_DB_PORT=27018
|
||||
MF_TWINS_SINGLE_USER_EMAIL=""
|
||||
MF_TWINS_SINGLE_USER_TOKEN=""
|
||||
MF_TWINS_CLIENT_TLS=""
|
||||
MF_TWINS_CA_CERTS=""
|
||||
MF_TWINS_MQTT_URL=tcp://mqtt-adapter:1883
|
||||
MF_TWINS_THING_ID=
|
||||
MF_TWINS_THING_KEY=
|
||||
MF_TWINS_CHANNEL_ID=
|
||||
|
2
Makefile
2
Makefile
@ -4,7 +4,7 @@
|
||||
BUILD_DIR = build
|
||||
SERVICES = users things http ws coap lora influxdb-writer influxdb-reader mongodb-writer \
|
||||
mongodb-reader cassandra-writer cassandra-reader postgres-writer postgres-reader cli \
|
||||
bootstrap opcua authn
|
||||
bootstrap opcua authn twins
|
||||
DOCKERS = $(addprefix docker_,$(SERVICES))
|
||||
DOCKERS_DEV = $(addprefix docker_dev_,$(SERVICES))
|
||||
CGO_ENABLED ?= 0
|
||||
|
56
docker/addons/twins/docker-compose.yml
Normal file
56
docker/addons/twins/docker-compose.yml
Normal file
@ -0,0 +1,56 @@
|
||||
# Copyright (c) Mainflux
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# This docker-compose file contains optional opcua-adapter and opcua-redis services
|
||||
# for the Mainflux platform. Since this services are optional, this file is dependent on the
|
||||
# docker-compose.yml file from <project_root>/docker/. In order to run these services,
|
||||
# core services, as well as the network from the core composition, should be already running.
|
||||
|
||||
version: "3.7"
|
||||
|
||||
networks:
|
||||
docker_mainflux-base-net:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
mainflux-twins-db-volume:
|
||||
mainflux-twins-db-configdb-volume:
|
||||
|
||||
services:
|
||||
twins-db:
|
||||
image: mongo:bionic
|
||||
command: mongod --port ${MF_TWINS_DB_PORT}
|
||||
container_name: mainflux-twins-db
|
||||
restart: on-failure
|
||||
environment:
|
||||
MONGO_INITDB_DATABASE: ${MF_TWINS_DB_NAME}
|
||||
ports:
|
||||
- ${MF_TWINS_DB_PORT}:${MF_TWINS_DB_PORT}
|
||||
networks:
|
||||
docker_mainflux-base-net:
|
||||
volumes:
|
||||
- mainflux-twins-db-volume:/data/db
|
||||
- mainflux-twins-db-configdb-volume:/data/configdb
|
||||
|
||||
twins:
|
||||
image: mainflux/twins:latest
|
||||
container_name: mainflux-twins
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_TWINS_LOG_LEVEL: ${MF_TWINS_LOG_LEVEL}
|
||||
MF_TWINS_HTTP_PORT: ${MF_TWINS_HTTP_PORT}
|
||||
MF_TWINS_DB_NAME: ${MF_TWINS_DB_NAME}
|
||||
MF_TWINS_DB_HOST: ${MF_TWINS_DB_HOST}
|
||||
MF_TWINS_DB_PORT: ${MF_TWINS_DB_PORT}
|
||||
MF_TWINS_THING_ID: ${MF_TWINS_THING_ID}
|
||||
MF_TWINS_THING_KEY: ${MF_TWINS_THING_KEY}
|
||||
MF_TWINS_CHANNEL_ID: ${MF_TWINS_CHANNEL_ID}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_AUTHN_URL: authn:${MF_AUTHN_GRPC_PORT}
|
||||
MF_TWINS_MQTT_URL: ${MF_TWINS_MQTT_URL}
|
||||
ports:
|
||||
- ${MF_TWINS_HTTP_PORT}:${MF_TWINS_HTTP_PORT}
|
||||
networks:
|
||||
docker_mainflux-base-net:
|
||||
depends_on:
|
||||
- twins-db
|
@ -92,6 +92,29 @@ MF_TWINS_LOG_LEVEL: [Twins log level] MF_TWINS_HTTP_PORT: [Service HTTP port] MF
|
||||
|
||||
## Usage
|
||||
|
||||
### Starting twins service
|
||||
|
||||
The twins service publishes notifications on an mqtt topic of the format
|
||||
`channels/<MF_TWINS_CHANNEL_ID>/messages/<twinID>/<crudOp>`, where `crudOp`
|
||||
stands for the crud operation done on twin - create, update, delete or
|
||||
retrieve - or state - save state. In order to use twin service, one must
|
||||
inform it - via environment variables - about the Mainflux thing and
|
||||
channel used for mqtt notification publishing. You can use an already existing
|
||||
thing and channel - thing has to be connected to channel - or create new ones.
|
||||
|
||||
To set the environment variables, please go to `.env` file and set the following
|
||||
variables:
|
||||
|
||||
```
|
||||
MF_TWINS_THING_ID=
|
||||
MF_TWINS_THING_KEY=
|
||||
MF_TWINS_CHANNEL_ID=
|
||||
```
|
||||
|
||||
with the corresponding values of the desired thing and channel. If you are
|
||||
running mainflux natively, than do the same thing in the corresponding console
|
||||
environment.
|
||||
|
||||
For more information about service capabilities and its usage, please check out
|
||||
the [API documentation](swagger.yaml).
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user