From 8165ede6b76dd09d060f573727a2c77fe964f58e Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Wed, 3 Jan 2024 14:46:31 +0100 Subject: [PATCH] Update Scorpio --- .env | 4 +- .../{scorpio-aaio.yml => scorpio.yml} | 55 ++++--------------- services | 22 ++++---- 3 files changed, 26 insertions(+), 55 deletions(-) rename docker-compose/{scorpio-aaio.yml => scorpio.yml} (72%) diff --git a/.env b/.env index 1054dd9..088543d 100644 --- a/.env +++ b/.env @@ -19,9 +19,11 @@ STELLIO_DOCKER_TAG=2.10.2 STELLIO_PORT=8080 STELLIO_TIMESCALE_POSTGIS=14-2.11.1-3.3 +# Curl variables +CURL_VERSION=8.4.0 # IoT Agent Ultralight Variables -ULTRALIGHT_VERSION=2.4.2-distroless +ULTRALIGHT_VERSION=3.0.0-distroless IOTA_NORTH_PORT=4041 IOTA_SOUTH_PORT=7896 diff --git a/docker-compose/scorpio-aaio.yml b/docker-compose/scorpio.yml similarity index 72% rename from docker-compose/scorpio-aaio.yml rename to docker-compose/scorpio.yml index 051f8b2..a0426ad 100644 --- a/docker-compose/scorpio-aaio.yml +++ b/docker-compose/scorpio.yml @@ -17,43 +17,20 @@ # see: https://github.com/FIWARE/helm-charts/ # version: "3.9" - services: - zookeeper: - labels: - org.fiware: 'tutorial' - image: zookeeper - hostname: zookeeper - container_name: zookeeper - networks: - - default - ports: - - "2181" - logging: - driver: none - kafka: + # Scorpio is the context broker + scorpio: labels: org.fiware: 'tutorial' - image: bitnami/kafka - hostname: kafka - container_name: kafka + image: quay.io/fiware/scorpio:java-${SCORPIO_VERSION} + hostname: scorpio + container_name: fiware-scorpio networks: - default ports: - - "9092" - environment: - KAFKA_ADVERTISED_HOST_NAME: kafka - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_PORT: 9092 - KAFKA_LOG_RETENTION_MS: 10000 - KAFKA_LOG_RETENTION_CHECK_INTERVAL_MS: 5000 - ALLOW_PLAINTEXT_LISTENER: "yes" - volumes: - - /var/run/docker.sock:/var/run/docker.sock + - "${EXPOSED_PORT}:${SCORPIO_PORT}" depends_on: - - zookeeper - logging: - driver: none + - postgres postgres: labels: org.fiware: 'tutorial' @@ -70,19 +47,8 @@ services: POSTGRES_DB: ngb logging: driver: none - scorpio: - labels: - org.fiware: 'tutorial' - image: scorpiobroker/all-in-one-runner:java-kafka-${SCORPIO_VERSION} - hostname: scorpio - container_name: fiware-scorpio - networks: - - default - ports: - - ${EXPOSED_PORT:-1026}:${SCORPIO_PORT:-9090} - depends_on: - - postgres - - kafka + volumes: + - postgres-db:/var/lib/postgresql/data # IoT-Agent connects to the Scorpio Broker @@ -101,3 +67,6 @@ services: - DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov - DUMMY_DEVICES_PAYLOAD=ULTRALIGHT - CONTEXT_BROKER=http://scorpio:${SCORPIO_PORT}/ngsi-ld/v1 # URL of the context broker to update context + +volumes: + postgres-db: ~ \ No newline at end of file diff --git a/services b/services index 836e741..6d013ce 100755 --- a/services +++ b/services @@ -48,7 +48,7 @@ pause(){ } getHeartbeat(){ - eval "response=$(docker run --network fiware_default --rm quay.io/curl/curl -s -o /dev/null -w "%{http_code}" "$1")" + eval "response=$(docker run --network fiware_default --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w "%{http_code}" "$1")" } waitForOrion () { @@ -68,7 +68,7 @@ waitForScorpio () { while [ "${response}" -eq 000 ] do echo -e "Context Broker HTTP state: ${response} (waiting for 500)" - pause 60 + pause 6 getHeartbeat "${SCORPIO}" done } @@ -76,14 +76,14 @@ waitForScorpio () { waitForStellio () { echo -e "\n⏳ Waiting for \033[1;34mStellio\033[0m to respond\n" waitSeconds=30 - while [ `docker run --network fiware_default --rm quay.io/curl/curl -s -o /dev/null -w %{http_code} 'http://stellio:8080/ngsi-ld/v1/entities/?type=X'` -eq 000 ] + while [ `docker run --network fiware_default --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w %{http_code} 'http://stellio:8080/ngsi-ld/v1/entities/?type=X'` -eq 000 ] do echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:8080/ngsi-ld/v1/entities/?type=X'` " (waiting for 500)" echo -e "Waiting for ${waitSeconds} seconds ..." sleep ${waitSeconds} done echo -e "\n⏳ Waiting for all \033[1;34mStellio\033[0m services to be available\n" - while [ `docker run --network fiware_default --rm quay.io/curl/curl -s -o /dev/null -w %{http_code} 'http://stellio:8080/ngsi-ld/v1/entities/?type=X'` -eq 500 ] + while [ `docker run --network fiware_default --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w %{http_code} 'http://stellio:8080/ngsi-ld/v1/entities/?type=X'` -eq 500 ] do echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:8080/ngsi-ld/v1/entities/?type=X'` " (waiting for 200)" echo -e "Waiting for ${waitSeconds} seconds ..." @@ -93,12 +93,12 @@ waitForStellio () { waitForCoreContext () { echo -e "\n⏳ Checking availability of \033[1m core @context\033[0m from ETSI\n" - eval "response=$(docker run --rm quay.io/curl/curl -s -o /dev/null -w "%{http_code}" "$CORE_CONTEXT")" + eval "response=$(docker run --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w "%{http_code}" "$CORE_CONTEXT")" while [ "${response}" -eq 000 ] do echo -e "\n@context HTTP state: ${response} (waiting for 200)" pause 3 - eval "response=$(docker run --rm quay.io/curl/curl -s -o /dev/null -w "%{http_code}" "$CORE_CONTEXT")" + eval "response=$(docker run --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w "%{http_code}" "$CORE_CONTEXT")" done } @@ -138,7 +138,7 @@ loadData () { --network fiware_default \ -e CONTEXT_BROKER=${CONTEXT_BROKER} \ -e TUTORIAL_DATA_MODELS_CONTEXT=${CONTEXT} \ - --entrypoint /bin/ash quay.io/curl/curl /import-data + --entrypoint /bin/ash quay.io/curl/curl:${CURL_VERSION} /import-data } addDatabaseIndex () { @@ -231,13 +231,13 @@ case "${command}" in export $(cat .env | grep "#" -v) stoppingContainers waitForCoreContext - echo -e "Starting containers: \033[1;34mScorpio\033[0m, \033[1mKafka\033[0m, \033[1mZookeeper\033[0m and a \033[1mPostgres\033[0m database, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m, a linked data \033[1mContext\033[0m and a \033[1mMongoDB\033[0m database." + echo -e "Starting containers: \033[1;34mScorpio\033[0m, and a \033[1mPostgres\033[0m database, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m, a linked data \033[1mContext\033[0m and a \033[1mMongoDB\033[0m database." echo -e "- \033[1;34mScorpio\033[0m is the context broker" echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol" echo -e "- \033[1mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP" echo -e "- Data models \033[1m@context\033[0m (Smart Farm) is supplied externally" echo "" - ${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio-aaio.yml up -d --remove-orphans --renew-anon-volumes + ${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio.yml up -d --remove-orphans --renew-anon-volumes displayServices "scorpio|fiware" waitForMongo addIoTDatabaseIndex @@ -278,8 +278,8 @@ case "${command}" in "create") export $(cat .env | grep "#" -v) echo "Pulling Docker images" - docker pull -q quay.io/curl/curl - ${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio-aaio.yml -f docker-compose/orion-ld.yml -f docker-compose/stellio.yml pull + docker pull -q quay.io/curl/curl:${CURL_VERSION} + ${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio.yml -f docker-compose/orion-ld.yml -f docker-compose/stellio.yml pull ;; *) echo "Command not Found."