From 480006cfb153886355052299545096e9bbfca029 Mon Sep 17 00:00:00 2001 From: 5okin Date: Sun, 24 Jan 2021 17:32:32 +0000 Subject: [PATCH] Upload files to 'server' --- server/.env | 11 ++++++++ server/Dockerfile | 10 +++++++ server/docker-compose.yml | 57 +++++++++++++++++++++++++++++++++++++++ server/requirements.txt | 7 +++++ server/run_server.py | 4 +++ 5 files changed, 89 insertions(+) create mode 100644 server/.env create mode 100644 server/Dockerfile create mode 100644 server/docker-compose.yml create mode 100644 server/requirements.txt create mode 100644 server/run_server.py 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