Skip to content

Commit

Permalink
Update Scorpio
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Jan 3, 2024
1 parent 08aa0e2 commit 8165ede
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 55 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
55 changes: 12 additions & 43 deletions docker-compose/scorpio-aaio.yml → docker-compose/scorpio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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: ~
22 changes: 11 additions & 11 deletions services
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -68,22 +68,22 @@ waitForScorpio () {
while [ "${response}" -eq 000 ]
do
echo -e "Context Broker HTTP state: ${response} (waiting for 500)"
pause 60
pause 6
getHeartbeat "${SCORPIO}"
done
}

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 ..."
Expand All @@ -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
}

Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down

0 comments on commit 8165ede

Please sign in to comment.