From d1a82c29cb059c852a77af6aec2b927c097ade69 Mon Sep 17 00:00:00 2001 From: Federico Sismondi Date: Mon, 9 Nov 2020 13:57:11 +0100 Subject: [PATCH] Added docker-compose to handle DCA services independently from IoT platform --- .env | 1 + docker-compose.dca.yml | 243 +++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 4 +- 3 files changed, 246 insertions(+), 2 deletions(-) create mode 100755 docker-compose.dca.yml diff --git a/.env b/.env index d7c22f5..0837109 100644 --- a/.env +++ b/.env @@ -1,6 +1,7 @@ # Orion variables ORION_PORT=1026 ORION_VERSION=latest +ORION=5.53.108.182 # MongoDB variables MONGO_DB_PORT=27017 diff --git a/docker-compose.dca.yml b/docker-compose.dca.yml new file mode 100755 index 0000000..64f4dc7 --- /dev/null +++ b/docker-compose.dca.yml @@ -0,0 +1,243 @@ +# - + - + - + - + - + - + - + - + - + - + - + - + - + +# NAIADES IoT Platform and services # +# - + - + - + - + - + - + - + - + - + - + - + - + - + + + +# - + - + - + - + - + - + - + - + - + - + - + - + - + +# Notes # +# - + - + - + - + - + - + - + - + - + - + - + - + - + + +# ToDoS for PROD +# ============== +# - include let's encrypt in nginx +# - platform's FQDM ? +# - all services requests must pass through nginx +# - change secrets + + +# +# Authored by UDGA in the context of NAIADES E.U. PROJECT +# +# Received contributions from +# --------------------------- +# - ? +# +# inspired by https://smartsdk.github.io/smartsdk-recipes/ +# +# PRODUCTION ToDOs +# ---------------- +# - include let's encrypt in nginx +# - platform's FQDM ? +# - all services requests must pass through nginx +# +# +# +# DEPLOYMENT NOTES: +# ----------------- +# +# About Docker Volumes: +# --------------------- +# +# A data volume is a specially-designated directory within one or more containers that bypasses the Union File System. +# Data volumes provide several useful features for persistent or shared data: +# +# - Volumes are initialized when a container is created. +# If the container’s base image contains data at the specified mount point, +# that existing data is copied into the new volume upon volume +# initialization. +# (Note that this does not apply when mounting a host +# directory.) +# +# - Data volumes can be shared and reused among containers. +# +# - Changes to a data volume are made directly. +# +# - Changes to a data volume will not be included when you update an image. +# Data volumes persist even if the container itself is deleted. +# +# Into Dockerfile you can specify only destination of volume inside container. e.g. /usr/src/app. +# You may but -not necessary needed- specify mounting point (/opt) in host machine. +# Using the CLI that is `docker run --volume=/opt:/usr/src/app my_image` +# If you not specify --volume argument then mount point will be chosen automatically +# + + +version: "3.5" +services: + + # - + - + - + - + - + - + - + - + - + - + - + - + - + + # Reverse-proxy # + # - + - + - + - + - + - + - + - + - + - + - + - + - + + + # Reverse-proxy (entrypoint) + nginx: + image: nginx:latest + container_name: nginx + networks: + default: + ipv4_address: 172.18.2.250 + volumes: + #- ${PWD}/nginx/error.log:/var/log/nginx/error.log:rw + - ${PWD}/nginx/conf.d/:/etc/nginx/conf.d/ + - ${PWD}/nginx/cache/:/var/www/nginx/cache/ + - ${PWD}/nginx/logs/:/var/log/nginx/:rw + - ${PWD}/nginx/nginx.conf:/etc/nginx/nginx.conf:rw + - ${PWD}/nginx/htpasswd/:/etc/nginx/htpasswd/:rw + #- /etc/letsencrypt/:/etc/letsencrypt/ + ports: + - 80:80 + - 443:443 + depends_on: + - dca-carouge-watering + - dca-carouge-fountain + - dca-carouge-weather + - dca-carouge-weather-station + command: [nginx-debug, '-g', 'daemon off;'] # THIS IS FOR DEBUG ONLY! DO NOT USE IN PROD! + + + # - + - + - + - + - + - + - + - + - + - + - + - + - + + # DCA services # + # - + - + - + - + - + - + - + - + - + - + - + - + - + + + dca-carouge-weather: + build: + context: ./dca-carouge-weather + dockerfile: Dockerfile + image: dca-carouge-weather:latest + container_name: dca-carouge-weather + environment: + - LC_ALL=C.UTF-8 + - LANG=C.UTF-8 + - POST_DATA_PERIOD=900 #15mins + - ORION_HOST=${ORION} + - COLLECTION_DIR=/code/raw_data + volumes: + - ./dca-carouge-weather:/code:rw + networks: + default: + ipv4_address: 172.18.2.15 + command: ./weather_00_collect_raw_weather_data_carouge.py # no sensors, only 3rd party data for the moment +# healthcheck: +# test: curl --fail -s http://dca-carouge-weather:${WMS_MODULE_PORT}/healthcheck || exit 1 +# start_period: 40s +# interval: 15m00s +# timeout: 10s +# retries: 3 + + dca-carouge-watering: + build: + context: ./dca-carouge-watering + dockerfile: Dockerfile + image: dca-carouge-watering:latest + container_name: dca-carouge-watering + environment: + - LC_ALL=C.UTF-8 + - LANG=C.UTF-8 + - FLASK_ENV=development + - FLASK_DEBUG=1 + - FLASK_RUN_PORT=80 + - COLLECTION_DIR=/code/raw_data + - ORION_HOST=${ORION} + - LORA_PLATFORM_SECRET_FILE=/run/secrets/lora_platform_auth_header + - LORA_PLATFORM_URL=https://lora-ns.sig-ge.ch:443 + secrets: + - lora_platform_auth_header + expose: + - 80 + volumes: + - ./dca-carouge-watering:/code + networks: + default: + ipv4_address: 172.18.2.14 + healthcheck: + test: curl --fail -s http://dca-carouge-watering/healthcheck || exit 1 + start_period: 30s + interval: 5m00s + timeout: 10s + retries: 3 + + + dca-carouge-fountain: + build: + context: ./dca-carouge-fountain + dockerfile: Dockerfile + image: dca-carouge-fountain:latest + container_name: dca-carouge-fountain + environment: + - LC_ALL=C.UTF-8 + - LANG=C.UTF-8 + - FLASK_ENV=development + - FLASK_DEBUG=1 + - FLASK_RUN_PORT=80 + - COLLECTION_DIR=/code/raw_data + - ORION_HOST=${ORION} + - LORA_PLATFORM_SECRET_FILE=/run/secrets/lora_platform_auth_header + - LORA_PLATFORM_URL=https://eu.saas.orbiwise.com:443 + secrets: + - lora_platform_auth_header + expose: + - 80 + volumes: + - ./dca-carouge-fountain:/code + networks: + default: + ipv4_address: 172.18.2.16 + healthcheck: + test: curl --fail -s http://dca-carouge-fountain/healthcheck || exit 1 + start_period: 30s + interval: 5m00s + timeout: 10s + retries: 3 + + dca-carouge-weather-station: + build: + context: ./dca-carouge-weather-station + dockerfile: Dockerfile + image: dca-carouge-weather-station:latest + container_name: dca-carouge-weather-station + environment: + - LC_ALL=C.UTF-8 + - LANG=C.UTF-8 + - FLASK_ENV=development + - FLASK_DEBUG=1 + - FLASK_RUN_PORT=80 + - COLLECTION_DIR=/code/raw_data + - ORION_HOST=${ORION} + ports: + - 21:21 + volumes: + - ./dca-carouge-weather-station:/code + networks: + default: + ipv4_address: 172.18.2.17 +# healthcheck: +# test: curl --fail -s http://dca-carouge-fountain/healthcheck || exit 1 +# start_period: 30s +# interval: 5m00s +# timeout: 10s +# retries: 3 + +# - + - + - + - + - + - + - + - + - + - + - + - + - + +# Docker configs # +# - + - + - + - + - + - + - + - + - + - + - + - + - + + +networks: + default: + driver: bridge + driver_opts: + com.docker.network.driver.mtu: 1450 + com.docker.network.bridge.name: naiades-network + ipam: + config: + - subnet: 172.18.2.0/24 + +volumes: + mysql-db: ~ + mongo-db: ~ + crate-storage: ~ + +secrets: + db_password: + file: secrets + lora_platform_auth_header: + file: secret_carouge_lora diff --git a/docker-compose.yml b/docker-compose.yml index cf52d54..ca8e09d 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -435,8 +435,8 @@ services: - FLASK_RUN_PORT=80 - COLLECTION_DIR=/code/raw_data - ORION_HOST=orion - expose: - - 80 + ports: + - 21:21 volumes: - ./dca-carouge-weather-station:/code networks: -- 2.24.1