diff --git a/server/.env b/server/.env new file mode 100644 index 0000000..9877f6d --- /dev/null +++ b/server/.env @@ -0,0 +1,11 @@ +InfluxDatabaseName = 'env_data' +InfluxAdminUser = 'admin' +InfluxAdminPass = 'admin' +InfluxUser = 'flask' +InfluxUserPass = 'pass' + +GRAFANA_USERNAME = 'admin' +GRAFANA_PASSWORD = 'admin' + +MailUser = 'rpi.iot.weatherserver@gmail.com' +MailPass = '94gVQfbzP3nV48B' \ No newline at end of file diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..3908ca7 --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3 + +WORKDIR /usr/src/app + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +CMD [ "python", "./run_server.py" ] \ No newline at end of file diff --git a/server/docker-compose.yml b/server/docker-compose.yml new file mode 100644 index 0000000..95b5ff3 --- /dev/null +++ b/server/docker-compose.yml @@ -0,0 +1,57 @@ +version: '3.4' + +services: + + weather_station_server: + container_name: "weather_server" + environment: + TZ: Europe/Athens + build: . + environment: + MAILUSER: ${MailUser} + MAILPASS: ${MailPass} + INFLUXDB_DATABASE: ${InfluxDatabaseName} + INFLUXDB_USERNAME: ${InfluxUser} + INFLUXDB_PASSWORD: ${InfluxUserPass} + depends_on: + - influxdb + ports: + - 5000:80 + + grafana: + container_name: "grafana" + image: grafana/grafana:latest + depends_on: + - influxdb + environment: + GF_SECURITY_ADMIN_USER: ${GRAFANA_USERNAME} + GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD} + INFLUXDB_DATABASE: ${InfluxDatabaseName} + INFLUXDB_USERNAME: ${InfluxUser} + INFLUXDB_PASSWORD: ${InfluxUserPass} + ports: + - 3000:3000 + volumes: + - ./grafana-provisioning/:/etc/grafana/provisioning + - grafanadata:/var/lib/grafana + + influxdb: + environment: + INFLUXDB_DB: ${InfluxDatabaseName} + INFLUXDB_ADMIN_USER: ${InfluxAdminUser} + INFLUXDB_ADMIN_PASSWORD: ${InfluxAdminPass} + INFLUXDB_HTTP_AUTH_ENABLED: "true" + INFLUXDB_USER: ${InfluxUser} + INFLUXDB_USER_PASSWORD: ${InfluxUserPass} + container_name: "influxdb" + image: influxdb:latest + #ports: + # - 8086:8086 + volumes: + - influxdata:/var/lib/influxdb + +volumes: + influxdata: + driver: local + grafanadata: + driver: local diff --git a/server/requirements.txt b/server/requirements.txt new file mode 100644 index 0000000..d885256 --- /dev/null +++ b/server/requirements.txt @@ -0,0 +1,7 @@ +Flask==1.1.2 +Flask-RESTful==0.3.8 +Flask-PyMongo==2.3.0 +tweepy==3.10.0 +flask-PyMongo==2.3.0 +pymongo==3.11.2 +influxdb==5.3.1 \ No newline at end of file diff --git a/server/run_server.py b/server/run_server.py new file mode 100644 index 0000000..57826cb --- /dev/null +++ b/server/run_server.py @@ -0,0 +1,4 @@ +from app import app + + +app.run(host='0.0.0.0', port=80, debug=True) \ No newline at end of file