From 15f7acb331fe204503d309798a6a03a27760e917 Mon Sep 17 00:00:00 2001 From: kerem Date: Thu, 8 Aug 2024 09:11:45 +0200 Subject: [PATCH] Added a starting point --- dockercompose.yml | 27 +++++++++++++++++++++++++++ iot-callback/Dockerfile | 10 ++++++++++ iot-callback/app.py | 12 ++++++++++++ iot-callback/requirements.txt | 1 + 4 files changed, 50 insertions(+) create mode 100644 dockercompose.yml create mode 100644 iot-callback/Dockerfile create mode 100644 iot-callback/app.py create mode 100644 iot-callback/requirements.txt diff --git a/dockercompose.yml b/dockercompose.yml new file mode 100644 index 0000000..242a4fb --- /dev/null +++ b/dockercompose.yml @@ -0,0 +1,27 @@ +version: '3.8' + +services: + iot-callback: + build: ./iot-callback/ + container_name: iot_callback_server + command: python3 app.py + volumes: + - ./iot-callback/:/app + networks: + - web + ports: + - 5002:5000 + labels: + - "traefik.enable=true" + - "traefik.http.routers.iot-callback.rule=Host(`iot.keydev.me`)" + - "traefik.http.routers.iot-callback.entrypoints=web" + - "traefik.http.routers.iot-callback.middlewares=redirect@file" + - "traefik.http.routers.iot-callback-secured.rule=Host(`iot.keydev.me`)" + - "traefik.http.routers.iot-callback-secured.entrypoints=web-secured" + - "traefik.http.routers.iot-callback-secured.tls.certresolver=mytlschallenge" + +networks: + database_network: + external: true + web: + external: true diff --git a/iot-callback/Dockerfile b/iot-callback/Dockerfile new file mode 100644 index 0000000..94305a1 --- /dev/null +++ b/iot-callback/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.9-slim + +WORKDIR /app + +COPY requirements.txt requirements.txt +RUN pip install -r requirements.txt + +COPY . . + +CMD ["python", "app.py"] diff --git a/iot-callback/app.py b/iot-callback/app.py new file mode 100644 index 0000000..6dd2e2d --- /dev/null +++ b/iot-callback/app.py @@ -0,0 +1,12 @@ +from flask import Flask, request + +app = Flask(__name__) + +@app.route('/callback', methods=['POST']) +def callback(): + data = request.json + # Process the data as needed + return 'Callback received', 200 + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) diff --git a/iot-callback/requirements.txt b/iot-callback/requirements.txt new file mode 100644 index 0000000..e3e9a71 --- /dev/null +++ b/iot-callback/requirements.txt @@ -0,0 +1 @@ +Flask