-
-
Save lcbm/170fc82440153a8077c04f7941e1b04c to your computer and use it in GitHub Desktop.
cs-biblioteca-service's docker-compose file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Orion variables | |
ORION_PORT=1026 | |
ORION_VERSION=2.2.0 | |
# IoT Agent Ultralight Variables | |
IOTA_NORTH_PORT=4041 | |
IOTA_SOUTH_PORT=7896 | |
ULTRALIGHT_VERSION=1.9.0 | |
# MongoDB variables | |
MONGO_DB_PORT=27017 | |
MONGO_DB_VERSION=3.6 | |
# Mosquitto variables | |
MQTT_PORT=1883 | |
MQTT_HTTP_WEBSOCKET_PORT=9001 | |
# RabbitMQ variables | |
AMQP_PORT=5672 | |
MANAGEMENT_CONSOLE_PORT=15672 | |
# login: guest, password: guest | |
# cs-biblioteca-service variables | |
SERVICE_PORT=8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"logger": { | |
"level": "info" | |
}, | |
"server": { | |
"port": 8080 | |
}, | |
"database": "MONGO", | |
"databaseConfig": { | |
"hostname": "db-mongo", | |
"port": 27017, | |
"name": "knot_storage" | |
}, | |
"cloud": "FIWARE", | |
"cloudConfig": { | |
"hostname": "orion", | |
"port": "1026", | |
"notificationUrl": "http://cs-biblioteca-service:8080" | |
}, | |
"deviceConfig": { | |
"tagReaderDeviceId": "dc40e09a73cebf69", | |
"tagReaderSensorId": "0", | |
"authResponseSensorId": "1", | |
"barcodeScannerDeviceId": "fbe64efa6c7f718e", | |
"barcodeScannerSensorId": "3", | |
"rentalResponseSensorId": "2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This docker-compose.yml was based on: github.com/FIWARE/tutorials.IoT-Agent/blob/master/docker-compose.yml | |
# | |
# WARNING: Do not deploy this tutorial configuration directly to a production environment | |
# | |
# The tutorial docker-compose files have not been written for production deployment and will not | |
# scale. A proper architecture has been sacrificed to keep the narrative focused on the learning | |
# goals, they are just used to deploy everything onto a single Docker machine. All FIWARE components | |
# are running at full debug and extra ports have been exposed to allow for direct calls to services. | |
# They also contain various obvious security flaws - passwords in plain text, no load balancing, | |
# no use of HTTPS and so on. | |
# | |
# This is all to avoid the need of multiple machines, generating certificates, encrypting secrets | |
# and so on, purely so that a single docker-compose file can be read as an example to build on, | |
# not use directly. | |
# | |
# When deploying to a production environment, please looking at the SmartSDK Recipes | |
# in order to scale up to a proper architecture: | |
# | |
# see: https://smartsdk.github.io/smartsdk-recipes/ | |
# | |
version: "3.7" | |
services: | |
# Orion is the context broker | |
orion: | |
image: fiware/orion:${ORION_VERSION} | |
hostname: orion | |
container_name: fiware-orion | |
depends_on: | |
- mongo-db | |
networks: | |
- default | |
expose: | |
- "${ORION_PORT}" | |
ports: | |
- "${ORION_PORT}:${ORION_PORT}" # localhost:1026 | |
command: -dbhost mongo-db -logLevel DEBUG | |
healthcheck: | |
test: curl --fail -s http://orion:${ORION_PORT}/version || exit 1 | |
# IoT-Agent configured for the UltraLight Protocol | |
iot-agent: | |
image: fiware/iotagent-ul:${ULTRALIGHT_VERSION} | |
hostname: iot-agent | |
container_name: fiware-iot-agent | |
depends_on: | |
- mongo-db | |
networks: | |
- default | |
expose: | |
- "${IOTA_NORTH_PORT}" | |
- "${IOTA_SOUTH_PORT}" | |
ports: | |
- "${IOTA_NORTH_PORT}:${IOTA_NORTH_PORT}" # localhost:4041 | |
- "${IOTA_SOUTH_PORT}:${IOTA_SOUTH_PORT}" # localhost:7896 | |
environment: | |
- IOTA_CB_HOST=orion # Name of the context broker to update context | |
- IOTA_CB_PORT=${ORION_PORT} # Port the context broker listens on to update context | |
- IOTA_CB_NGSI_VERSION=v2 # Use NGSIv2 when sending updates for active attributes | |
- IOTA_NORTH_HOST=iot-agent # Hostname of the iotagent to update context * | |
- IOTA_NORTH_PORT=${IOTA_NORTH_PORT} # Port used for Configuring the IoT Agent and receiving context updates from the context broker | |
- IOTA_REGISTRY_TYPE=mongodb # Whether to hold IoT device info in memory or in a database | |
- IOTA_MONGO_HOST=mongo-db # The host name of MongoDB | |
- IOTA_MONGO_PORT=${MONGO_DB_PORT} # The port mongoDB is listening on | |
- IOTA_MONGO_DB=iotagentul # The name of the database used in mongoDB | |
- IOTA_LOG_LEVEL=DEBUG # The log level of the IoT Agent | |
- IOTA_TIMESTAMP=true # Supply timestamp information with each measurement | |
- IOTA_AUTOCAST=true # Ensure Ultralight number values are read as numbers not strings | |
- IOTA_MQTT_HOST=mosquitto # Hostname of the MQTT Broker | |
- IOTA_MQTT_PORT=${MQTT_PORT} # Port the MQTT Broker is listening on to receive topics | |
- IOTA_AMQP_HOST=rabbitmq # Hostname of the rabbitmq service | |
- IOTA_AMQP_PORT=${AMQP_PORT} # Port rabbitmq is listening on | |
- IOTA_HTTP_PORT=${IOTA_SOUTH_PORT} # The port used for device traffic over HTTP | |
- IOTA_DEFAULT_RESOURCE=/iot/d | |
- IOTA_PROVIDER_URL=http://iot-agent:${IOTA_NORTH_PORT} | |
healthcheck: | |
test: curl --fail -s http://iot-agent:${IOTA_NORTH_PORT}/iot/about || exit 1 | |
# Database | |
mongo-db: | |
image: mongo:${MONGO_DB_VERSION} | |
hostname: mongo-db | |
container_name: db-mongo | |
expose: | |
- "${MONGO_DB_PORT}" | |
ports: | |
- "${MONGO_DB_PORT}:${MONGO_DB_PORT}" # localhost:27017 | |
networks: | |
- default | |
command: --bind_ip_all --smallfiles | |
volumes: | |
- mongo-db:/data | |
# MQTT message broker | |
mosquitto: | |
image: eclipse-mosquitto | |
hostname: mosquitto | |
container_name: mosquitto | |
networks: | |
- default | |
expose: | |
- "${MQTT_PORT}" | |
- "${MQTT_HTTP_WEBSOCKET_PORT}" | |
ports: | |
- "${MQTT_PORT}:${MQTT_PORT}" # localhost:1883 | |
- "${MQTT_HTTP_WEBSOCKET_PORT}:${MQTT_HTTP_WEBSOCKET_PORT}" # localhost:9001 | |
# AMQP message broker | |
rabbitmq: | |
image: library/rabbitmq | |
hostname: rabbitmq | |
container_name: rabbitmq | |
networks: | |
- default | |
expose: | |
- "${AMQP_PORT}" | |
- "${MANAGEMENT_CONSOLE_PORT}" | |
ports: | |
- "${AMQP_PORT}:${AMQP_PORT}" # localhost:5672 | |
- "${MANAGEMENT_CONSOLE_PORT}:${MANAGEMENT_CONSOLE_PORT}" # localhost:15672 | |
cs-biblioteca-service: | |
image: cesarbr/cs-biblioteca-service:dev | |
hostname: cs-biblioteca-service | |
container_name: cs-biblioteca-service | |
build: | |
context: . | |
dockerfile: Dockerfile-dev | |
depends_on: | |
- orion | |
- iot-agent | |
- mongo-db | |
- mosquitto | |
- rabbitmq | |
# - knot-fog-connector | |
networks: | |
- default | |
expose: | |
- "${SERVICE_PORT}" | |
ports: | |
- "${SERVICE_PORT}:${SERVICE_PORT}" # localhost:8080 | |
volumes: | |
- .:/usr/src/app | |
# knot-fog-connector: | |
# image: cesarbr/knot-fog-connector:dev | |
# hostname: knot-fog-connector | |
# container_name: knot-fog-connector | |
# build: | |
# context: ../knot-fog-connector | |
# dockerfile: Dockerfile-dev | |
# depends_on: | |
# - orion | |
# - iot-agent | |
# - rabbitmq | |
# network_mode: host | |
# volumes: | |
# - ../knot-fog-connector:/usr/src/app | |
networks: | |
default: | |
ipam: | |
config: | |
- subnet: 172.18.1.0/24 | |
volumes: | |
mongo-db: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cloudType": "FIWARE", | |
"cloud": { | |
"orion": { | |
"hostname": "localhost", | |
"port": 1026 | |
}, | |
"iota": { | |
"hostname": "localhost", | |
"port": 4041 | |
} | |
}, | |
"rabbitMQ": { | |
"hostname": "localhost", | |
"port": 5672 | |
}, | |
"runAs": { | |
"user": "knot", | |
"group": "knot" | |
}, | |
"log": { | |
"console": true, | |
"syslog": false, | |
"level": "debug" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
curl () { | |
docker run --network fiware --rm appropriate/curl -s \ | |
"$@" | |
printf "." | |
} | |
echo -e "⏳ Waiting for Context Broker to be available\n" | |
while [ `docker run --network fiware --rm appropriate/curl -s -o /dev/null -w %{http_code} 'http://orion:1026/version'` -eq 000 ] | |
do | |
echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://orion:1026/version'` " (waiting for 200)" | |
sleep 1 | |
done | |
# Subscribe to a devices' sensors, via orion | |
# printf "⏳ Subscribing to authentication sensor...\n" | |
# curl -iX POST \ | |
# 'http://orion:1026/v2/subscriptions?options=skipInitialNotification' \ | |
# -H 'Content-type: application/json' \ | |
# -H 'fiware-service: knot' \ | |
# -H 'fiware-servicepath: /device/a9dd55c79324f7c4' \ | |
# -g -d '{ | |
# "description": "Notify when device updates the sensor value for badgeId.", | |
# "subject": { | |
# "entities": [ | |
# { | |
# "id": "1000", | |
# "type": "sensor" | |
# } | |
# ], | |
# "condition": { | |
# "attrs": [ "value" ] | |
# } | |
# }, | |
# "notification": { | |
# "http": { | |
# "url": "http://cs-biblioteca-service:8080/api/auth" | |
# } | |
# } | |
# }' | |
# printf "⏳ Subscribing to book rental sensor...\n" | |
# curl -iX POST \ | |
# 'http://orion:1026/v2/subscriptions?options=skipInitialNotification' \ | |
# -H 'Content-type: application/json' \ | |
# -H 'fiware-service: knot' \ | |
# -H 'fiware-servicepath: /device/a9dd55c79324f7c4' \ | |
# -g -d '{ | |
# "description": "Notify when device updates the sensor value for bookId.", | |
# "subject": { | |
# "entities": [ | |
# { | |
# "idPattern": "0", | |
# "type": "sensor" | |
# } | |
# ], | |
# "condition": { | |
# "attrs": [ "value" ] | |
# } | |
# }, | |
# "notification": { | |
# "http": { | |
# "url": "http://cs-biblioteca-service:8080/api/books" | |
# } | |
# } | |
# }' | |
# Check subscriptions | |
# printf "⏳ Retrieving device's subscriptions...\n" | |
# curl -iX GET \ | |
# 'http://orion:1026/v2/subscriptions' \ | |
# -H 'fiware-service: knot' \ | |
# -H 'fiware-servicepath: /device/a9dd55c79324f7c4' | |
# Delete subscription | |
# curl -iX DELETE \ | |
# 'http://orion:1026/v2/subscriptions/5da4ea69917c3f7c2df4e8c4' \ | |
# -H 'fiware-service: knot' \ | |
# -H 'fiware-servicepath: /device/a9dd55c79324f7c4' | |
# Send 'setData' command to sensor | |
# curl -iX PATCH \ | |
# 'http://orion:1026/v2/entities/0/attrs?type=sensor' \ | |
# -H 'Content-Type: application/json' \ | |
# -H 'fiware-service: knot' \ | |
# -H 'fiware-servicepath: /device/a9dd55c79324f7c4' \ | |
# -d '{ | |
# "setData": { | |
# "type" : "command", | |
# "value" : "true" | |
# } | |
# }' | |
# Send 'getData' command to sensor | |
# curl -iX PATCH \ | |
# 'http://orion:1026/v2/entities/0/attrs?type=sensor' \ | |
# -H 'Content-Type: application/json' \ | |
# -H 'fiware-service: knot' \ | |
# -H 'fiware-servicepath: /device/a9dd55c79324f7c4' \ | |
# -d '{ | |
# "getData": { | |
# "type" : "command", | |
# "value" : "" | |
# } | |
# }' | |
# Check command status | |
# curl -iX GET \ | |
# 'http://orion:1026/v2/entities/0?options=keyValues' \ | |
# -H 'fiware-service: knot' \ | |
# -H 'fiware-servicepath: /device/a9dd55c79324f7c4' | |
echo -e " \033[1;32mdone\033[0m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment