From 746d54eb959c53effc2686ce01ab1c741211c09d Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 29 Jan 2026 16:38:40 +0100 Subject: [PATCH 1/6] Changes --- Dockerfile => app/Dockerfile | 0 app.py => app/app.py | 13 +++++++++++-- requirements.txt => app/requirements.txt | 0 docker-compose.yml | 11 +++++++++++ logs_dummy_api.sh | 5 +++++ start_dummy_api.sh | 6 ++++-- stops_dummy_api.sh | 5 +++++ 7 files changed, 36 insertions(+), 4 deletions(-) rename Dockerfile => app/Dockerfile (100%) rename app.py => app/app.py (53%) rename requirements.txt => app/requirements.txt (100%) create mode 100644 docker-compose.yml create mode 100755 logs_dummy_api.sh create mode 100755 stops_dummy_api.sh diff --git a/Dockerfile b/app/Dockerfile similarity index 100% rename from Dockerfile rename to app/Dockerfile diff --git a/app.py b/app/app.py similarity index 53% rename from app.py rename to app/app.py index 5d920c5..142d513 100644 --- a/app.py +++ b/app/app.py @@ -1,5 +1,6 @@ import os -from flask import Flask, jsonify +from flask import Flask, jsonify, request +import logging app = Flask(__name__) @@ -7,11 +8,19 @@ app = Flask(__name__) # Default to 'World' if the variable isn't set app_name = os.getenv("APP_NAME", "World") +# Set up logging +app.logger.setLevel(logging.INFO) + + @app.route("/hello", methods=["GET"]) def hello(): # return f"Hello {app_name}" + # Flask intenta parsear el token automáticamente + token = request.authorization.token if request.authorization else None + app.logger.info(f"JWT detected: {token}") return jsonify(f"Hello, {app_name}!") + if __name__ == "__main__": port = int(os.getenv("PORT", 8000)) - app.run(host='0.0.0.0', port=port) \ No newline at end of file + app.run(host='0.0.0.0', port=port) diff --git a/requirements.txt b/app/requirements.txt similarity index 100% rename from requirements.txt rename to app/requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..557c741 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +name: dummy +services: + aef: + image: flask-hello-service + build: + context: ./app + restart: unless-stopped + ports: + - 8000:8000 + environment: + - APP_NAME=${APP_NAME} diff --git a/logs_dummy_api.sh b/logs_dummy_api.sh new file mode 100755 index 0000000..70dae5f --- /dev/null +++ b/logs_dummy_api.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Stop dummy service for user: $1" + +APP_NAME=$1 docker compose logs diff --git a/start_dummy_api.sh b/start_dummy_api.sh index 9ed383f..7a38329 100755 --- a/start_dummy_api.sh +++ b/start_dummy_api.sh @@ -1,5 +1,7 @@ #!/bin/bash echo "Create dummy service for user: $1" -docker build -t flask-hello-service . -docker run -it --rm --name "$1" -p 8000:8000 -e APP_NAME=$1 flask-hello-service \ No newline at end of file +# docker build -t flask-hello-service . +# docker run -it --rm --name "$1" -p 8000:8000 -e APP_NAME=$1 flask-hello-service + +APP_NAME=$1 docker compose up --detach --build --force-recreate diff --git a/stops_dummy_api.sh b/stops_dummy_api.sh new file mode 100755 index 0000000..aa6e35b --- /dev/null +++ b/stops_dummy_api.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Stop dummy service for user: $1" + +APP_NAME=$1 docker compose down -- GitLab From 54c9d73e96b345ea24876fb7c0e398a434c324e2 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 29 Jan 2026 17:01:45 +0100 Subject: [PATCH 2/6] add -f option to logs --- logs_dummy_api.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logs_dummy_api.sh b/logs_dummy_api.sh index 70dae5f..bf1e401 100755 --- a/logs_dummy_api.sh +++ b/logs_dummy_api.sh @@ -2,4 +2,4 @@ echo "Stop dummy service for user: $1" -APP_NAME=$1 docker compose logs +APP_NAME=$1 docker compose logs -f -- GitLab From 8e65624dc1d859d81a8ce7ecb799df6b582eb036 Mon Sep 17 00:00:00 2001 From: Jorge Moratinos Salcines Date: Thu, 29 Jan 2026 17:06:31 +0100 Subject: [PATCH 3/6] add minor check --- start_dummy_api.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/start_dummy_api.sh b/start_dummy_api.sh index 7a38329..c6d0c77 100755 --- a/start_dummy_api.sh +++ b/start_dummy_api.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + echo "Create dummy service for user: $1" # docker build -t flask-hello-service . # docker run -it --rm --name "$1" -p 8000:8000 -e APP_NAME=$1 flask-hello-service -- GitLab From 36bb58bcf7f46af65083b58f79a0babc63064158 Mon Sep 17 00:00:00 2001 From: Stavros Charismiadis Date: Fri, 30 Jan 2026 09:12:34 +0200 Subject: [PATCH 4/6] Add new commands to README.md --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d7a9df7..735852e 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,9 @@ GET /hello ## Getting started To deploy the service, run the following command in an Ubuntu or MacOS terminal. - ``` ./start_dummy_api.sh ``` - The above command will deploy a docker container with the name or username inserted The API of this AEF, during the tutorial, has to be accessible via the [CAPIF Provider Gateway](https://labs.etsi.org/rep/ocf/provider-gateway) @@ -29,3 +27,15 @@ The neccesary files to configure the Provider Gateway with the AEF API are: First fill the fields starting with <> with the correct information and then copy them to the Provider Gateway folder. + +To check the logs, run the following command. +``` + ./logs_dummy_api.sh +``` + +To stop the service, run the following command. +``` + ./stops_dummy_api.sh +``` + + -- GitLab From 250dbbc53e7d2bf5ed4d038af9c9e1d0e18f114d Mon Sep 17 00:00:00 2001 From: Stavros Charismiadis Date: Fri, 30 Jan 2026 13:18:53 +0200 Subject: [PATCH 5/6] add username argument in the additional scripts --- README.md | 6 ++++-- app/app.py | 2 +- logs_dummy_api.sh | 7 ++++++- start_dummy_api.sh | 4 +--- stops_dummy_api.sh | 5 +++++ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 735852e..5fd8f58 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,9 @@ GET /hello ## Getting started To deploy the service, run the following command in an Ubuntu or MacOS terminal. ``` - ./start_dummy_api.sh + cd dummy-aef + chmod +x start_dummy_api.sh + ./start_dummy_api.sh ``` The above command will deploy a docker container with the name or username inserted @@ -30,7 +32,7 @@ First fill the fields starting with <> with the correct information and then cop To check the logs, run the following command. ``` - ./logs_dummy_api.sh + ./logs_dummy_api.sh ``` To stop the service, run the following command. diff --git a/app/app.py b/app/app.py index 142d513..7fe7b46 100644 --- a/app/app.py +++ b/app/app.py @@ -15,7 +15,7 @@ app.logger.setLevel(logging.INFO) @app.route("/hello", methods=["GET"]) def hello(): # return f"Hello {app_name}" - # Flask intenta parsear el token automáticamente + # Flask attempts to parse the token automatically token = request.authorization.token if request.authorization else None app.logger.info(f"JWT detected: {token}") return jsonify(f"Hello, {app_name}!") diff --git a/logs_dummy_api.sh b/logs_dummy_api.sh index bf1e401..1048207 100755 --- a/logs_dummy_api.sh +++ b/logs_dummy_api.sh @@ -1,5 +1,10 @@ #!/bin/bash -echo "Stop dummy service for user: $1" +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +echo "Logs of dummy service for user: $1" APP_NAME=$1 docker compose logs -f diff --git a/start_dummy_api.sh b/start_dummy_api.sh index c6d0c77..f6292fd 100755 --- a/start_dummy_api.sh +++ b/start_dummy_api.sh @@ -1,12 +1,10 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi echo "Create dummy service for user: $1" -# docker build -t flask-hello-service . -# docker run -it --rm --name "$1" -p 8000:8000 -e APP_NAME=$1 flask-hello-service APP_NAME=$1 docker compose up --detach --build --force-recreate diff --git a/stops_dummy_api.sh b/stops_dummy_api.sh index aa6e35b..58d167b 100755 --- a/stops_dummy_api.sh +++ b/stops_dummy_api.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + echo "Stop dummy service for user: $1" APP_NAME=$1 docker compose down -- GitLab From 0104bca0b7de8088792db5844151f5626d7bbec1 Mon Sep 17 00:00:00 2001 From: Stavros Charismiadis Date: Fri, 30 Jan 2026 14:13:58 +0200 Subject: [PATCH 6/6] Minor changes in messages, same uri for NB and SB API --- logs_dummy_api.sh | 2 +- northbound.yaml | 2 +- southbound.yaml | 2 +- start_dummy_api.sh | 2 +- stops_dummy_api.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/logs_dummy_api.sh b/logs_dummy_api.sh index 1048207..9d59ee0 100755 --- a/logs_dummy_api.sh +++ b/logs_dummy_api.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi diff --git a/northbound.yaml b/northbound.yaml index 3a06398..876398b 100644 --- a/northbound.yaml +++ b/northbound.yaml @@ -27,7 +27,7 @@ northbound: description: Example API for demonstration version: 1.0.0 paths: - /greet: + /hello: get: summary: Say hello description: Returns a greeting message. diff --git a/southbound.yaml b/southbound.yaml index 62a4496..03986ae 100644 --- a/southbound.yaml +++ b/southbound.yaml @@ -6,6 +6,6 @@ southbound: credentials: jwt: "example-token" paths: - - northbound_path: "/greet" + - northbound_path: "/hello" southbound_path: "/hello" method: GET diff --git a/start_dummy_api.sh b/start_dummy_api.sh index f6292fd..19e0fa4 100755 --- a/start_dummy_api.sh +++ b/start_dummy_api.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi diff --git a/stops_dummy_api.sh b/stops_dummy_api.sh index 58d167b..7ac4427 100755 --- a/stops_dummy_api.sh +++ b/stops_dummy_api.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ $# -ne 1 ]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi -- GitLab