Privacy friendly framework for IoT Cloud.
- Install Mosquitto broker
sudo apt install mosquitto
- and make it listen on specified port e.g.:
mosquitto -p 1883
- install
docker-compose
- from root directory run:
CURRENT_UID=$(id -u):$(id -g) docker-compose up
- NOTE:
CURRENT_UID=$(id -u):$(id -g)
is necessary because test container needs to run under current user to write reports
- NOTE:
- to clean up _pycache_ and .pytest_cache directories created by docker use following commands:
sudo find . -path '*/__pycache__*' ! -path "./venv*" -delete
sudo find . -path '*/.pytest_cache*' ! -path "./venv*" -delete
- NOTE: run commands first without
-delete
flag to test, to make sure you don't damage your system
- export path to flask application factory method -
export FLASK_APP="app.app_setup:create_app('development')"
- run from
./IoT-Cloud/app
directory with commandflask run
- When running tests make sure you set environment variable
TESTING_ENV
tohost_testing
(defaults totesting
), so the application usesconfig.env
variables needed for running tests on docker host. If not set, tests will run as if they were inside docker container ( = with different URLs).
- install
sudo apt install mosquitto-clients
- publish to topics to which application is subscribed to by using
mosquitto_pub -h <host> -p <port> -t <topic_name> -m "message"
It is recommended to use dockerized Postgres database, which is included here (in ./postgres). You can bring it by running docker-compose up
in that directory. It listens on port 5430
instead of 5432
to make sure it does not interfere with any host services, therefore you need to make sure that URLs in config.env
correct this port.
NOTE: there is also another Postgres database inside main applications docker-compose, however that is used only for running tests.
- you can access database using pgadmin4
- login to
psql
usingsudo -u postgres psql
- find
postgresql.conf
andpg_hba.conf
usingshow config_file;
andshow hba_file;
respectively - in
postgresql.conf
set listen address tolisten_addresses = '*'
to allow remote access - in
pg_hba.conf
add after localhost line:host all all 0.0.0.0/0 md5
- restart postgres service -
sudo service postgresql stop
andsudo service postgresql start
- steps based on This blog
-
docker exec -it $(docker-compose ps -q db ) psql -Upostgres -c '\z'
to show all tables in the database. In another terminal, talk to the container's Postgres -
docker exec -it $(docker-compose ps -q db ) psql -Upostgres -c 'create table user()'
to write queries directly -
docker exec -it $(docker-compose ps -q db ) pg_dump -Upostgres > backup.sql
to dump (backup) data to host -
docker exec -i $(docker-compose ps -q db ) psql -Upostgres < backup.sql
to restore backed up data -
based on StackOverflow answer
-
Preferably access using pgadmin4 should be used with username postgres and exposed port from docker-compose.override (by default:
5431
)
It's necessary to provide certificates to use application. When using Mosquitto, please use steps at Mosquitto website
- Files created in previous steps should be placed in
certs
folder both for Mosquitto and application, replacing*.dummy
files - Application currently does not require client certificates, to change that, you need to set
require_certificate true
inmosquitto.conf
and provide clientcertfile
andkeyfile
toclient.tls_set
increate_app.py
throughCLIENT_CERTFILE_PATH
andCLIENT_KEYFILE_PATH
config attributes - in production
SSL_INSECURE
attribute in config should be set to False, so when generating certificates, make sure that broker name (hostname) matches name on certificate
- You need to provide certificate and key for Nginx server to be accessible - this should be done by replacing dummy files in ./webserver/ssl folder
- To generate self-signed certificate:
- change directory to ./webserver/ssl
- run
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./private/webserver.key -out ./certs/webserver.crt
- To start Node-RED with prepared
settings.js
file go to./node-red
directory and run in using:./node_modules/node-red/bin/node-red-pi -s ./settings.js
if you have Node-RED installed innode_modules
node-red -s ./settings.js
if installed globally
- If you have issues running tests inside container (there are some tests that need to be excluded when running inside container), try
docker container prune
anddocker-compose up
again - If
testing
DB inside docker container is not being created bycreate_db.sh
, you need to first remove persistent volume (docker volume rm iotcloud_data
) and prune containers (docker container prune
) - if you encounter this error message:
libpbc.so.1: cannot open shared object file: No such file or directory
, make sure you runldconfig
after installing pbc, if that doesn't help:- check whether path to pbc is in
LD_LIBRARY_PATH
(echo $LD_LIBRARY_PATH
) - if not, then run
sudo find / -name libpbc.so
- add path outputted by previous command to
LD_LIBRARY_PATH
- e.g.LD_LIBRARY_PATH=/usr/local/lib
and export it - if that solves the issue, add
LD_LIBRARY_PATH
to~/.bashrc
andsource
it
- check whether path to pbc is in
- if you encounter error message when installing Charm (running
./configure.sh
) stating that you don't have python3-dev or python3-config:- check whether you have any other version installed e.g python3.6-config, if yes, replace occurrence(s) of python3-config in
./configure.sh
with the one you have installed and run it again
- check whether you have any other version installed e.g python3.6-config, if yes, replace occurrence(s) of python3-config in