Commit df0e7a78 authored by Federico Sismondi's avatar Federico Sismondi

Added WMS module example as a docker compose service implemented in Python

parent 94dc100c
......@@ -8,6 +8,8 @@ MONGO_DB_VERSION=3.6
# MongoDB dashboard
MONGO_DB_EXPRESS_PORT=8081
MONGO_DB_EXPRESS_USER=user
MONGO_DB_EXPRESS_PASS=pass
# Keyrock variables
KEYROCK_VERSION=7.8.1
......@@ -23,4 +25,4 @@ WILMA_VERSION=7.8.1
ORION_PROXY_PORT=1027
# WMS mock module
WMS_MODULE_PORT=8080
WMS_MODULE_PORT=5000
wms-example/__pycache__/
......@@ -117,17 +117,18 @@ services:
image: mongo-express
container_name: mongo-express
networks:
- default
default:
ipv4_address: 172.18.1.12
depends_on:
- mongo-db
expose:
- "8081"
- "${MONGO_DB_EXPRESS_PORT}"
ports:
- "8081:${MYSQL_DB_PORT}"
- "${MONGO_DB_EXPRESS_PORT}:${MONGO_DB_EXPRESS_PORT}"
environment:
- ME_CONFIG_OPTIONS_EDITORTHEME=ambiance
- ME_CONFIG_BASICAUTH_USERNAME=user
- ME_CONFIG_BASICAUTH_PASSWORD=pass
- ME_CONFIG_BASICAUTH_USERNAME=${MONGO_DB_EXPRESS_USER}
- ME_CONFIG_BASICAUTH_PASSWORD=${MONGO_DB_EXPRESS_PASS}
- ME_CONFIG_MONGODB_PORT=${MONGO_DB_PORT}
- ME_CONFIG_MONGODB_ENABLE_ADMIN=false
- ME_CONFIG_MONGODB_SERVER=mongo-db
......@@ -153,22 +154,28 @@ services:
secrets:
- my_secret_data
mock-wms-consumer:
image: mockserver/mockserver:mockserver-5.9.0
container_name: mock-wms-consumer
ports:
- 1080:${WMS_MODULE_PORT}
wms-app-example:
build:
context: ./wms-example
dockerfile: Dockerfile
image: wms-app-example:latest
hostname: wms-app-example
container_name: wms-app-example
environment:
- LC_ALL=C.UTF-8
- LANG=C.UTF-8
- FLASK_DEBUG=1
expose:
- ${WMS_MODULE_PORT}
environment:
LOG_LEVEL: "DEBUG"
SERVER_PORT: ${WMS_MODULE_PORT}
JVM_OPTIONS: -Dmockserver.sslSubjectAlternativeNameDomains='org.mock-server.com,mock-server.com'
ports:
- 5000:${WMS_MODULE_PORT}
volumes:
- ./wms-example:/code
networks:
default:
ipv4_address: 172.18.1.2
ipv4_address: 172.18.1.11
healthcheck:
test: curl --fail -s http://wms-app-example:${WMS_MODULE_PORT}/healthcheck || exit 1
networks:
default:
......
echo "Nothing to do here. WMS mock server already running in docker, check log with: `docker-compose logs mock-wms-consumer`"
echo "Nothing to do here. WMS-app-example shloud already be running in docker, check log with: <docker-compose logs wms-app-example>"
......@@ -17,7 +17,7 @@ curl -v localhost:1026/v2/subscriptions/ -s -S --header 'Content-Type: applicati
},
"notification": {
"http": {
"url": "http://172.18.1.2:8080/check_if_soilMoistureVwc_is_low"
"url": "http://172.18.1.11:5000/on_change_soilMoistureVwc"
},
"attrs": [
"soilMoistureVwc"
......
FROM python:3.6
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD python app.py
from flask import Flask
from flask import request
import logging
app = Flask(__name__)
logger = logging.getLogger(__name__)
@app.route('/')
@app.route('/healthcheck')
def healthcheck():
return 'This service is up and running!'
@app.route('/on_change_soilMoistureVwc',methods = ['POST'])
def on_change_soilMoistureVwc():
# if request.data:
# app.logger.info("Request data: %s" % request.data)
if request.json:
app.logger.info("Got new soil moisture value from context broker: %s" % request.json['data'])
return 'Got POST for /on_change_soilMoistureVwc, with body %s' % request.form
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True, port=5000)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment