diff --git a/.env b/.env index e7f7ff6..40877f1 100644 --- a/.env +++ b/.env @@ -19,6 +19,8 @@ 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 JSON Variables JSON_VERSION=2.4.0-distroless diff --git a/docker-compose/scorpio-aaio.yml b/docker-compose/scorpio.yml similarity index 73% rename from docker-compose/scorpio-aaio.yml rename to docker-compose/scorpio.yml index c76d523..bd7bfcc 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,20 +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 is configured for the JSON Protocol and connects to the Scorpio Broker iot-agent: @@ -102,3 +67,5 @@ services: - DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov - 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 f3dca9b..d7b7908 100755 --- a/services +++ b/services @@ -47,7 +47,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 () { @@ -67,7 +67,7 @@ waitForScorpio () { while [ "${response}" -eq 000 ] do echo -e "Context Broker HTTP state: ${response} (waiting for 500)" - pause 60 + pause 6 getHeartbeat "${SCORPIO}" done } @@ -75,14 +75,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 ..." @@ -92,12 +92,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 } @@ -137,7 +137,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 () { @@ -230,13 +230,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 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 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 JSON 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 @@ -277,8 +277,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."