|
| 1 | +# WARNING: Do not deploy this tutorial configuration directly to a production environment |
| 2 | +# |
| 3 | +# The tutorial docker-compose files have not been written for production deployment and will not |
| 4 | +# scale. A proper architecture has been sacrificed to keep the narrative focused on the learning |
| 5 | +# goals, they are just used to deploy everything onto a single Docker machine. All FIWARE components |
| 6 | +# are running at full debug and extra ports have been exposed to allow for direct calls to services. |
| 7 | +# They also contain various obvious security flaws - passwords in plain text, no load balancing, |
| 8 | +# no use of HTTPS and so on. |
| 9 | +# |
| 10 | +# This is all to avoid the need of multiple machines, generating certificates, encrypting secrets |
| 11 | +# and so on, purely so that a single docker-compose file can be read as an example to build on, |
| 12 | +# not use directly. |
| 13 | +# |
| 14 | +# When deploying to a production environment, please refer to the Helm Repository |
| 15 | +# for FIWARE Components in order to scale up to a proper architecture: |
| 16 | +# |
| 17 | +# see: https://github.com/FIWARE/helm-charts/ |
| 18 | +# |
| 19 | +version: "3.8" |
| 20 | +services: |
| 21 | + # Orion is the context broker |
| 22 | + orion: |
| 23 | + labels: |
| 24 | + org.fiware: 'tutorial' |
| 25 | + image: fiware/orion:${ORION_VERSION} |
| 26 | + hostname: orion |
| 27 | + container_name: fiware-orion |
| 28 | + depends_on: |
| 29 | + - mongo-db |
| 30 | + networks: |
| 31 | + default: |
| 32 | + ipv4_address: 172.18.1.9 |
| 33 | + expose: |
| 34 | + - "${ORION_PORT}" |
| 35 | + ports: |
| 36 | + - "${ORION_PORT}:${ORION_PORT}" # localhost:1026 |
| 37 | + command: -dbhost mongo-db -logLevel DEBUG |
| 38 | + healthcheck: |
| 39 | + test: curl --fail -s http://orion:${ORION_PORT}/version || exit 1 |
| 40 | + interval: 15s |
| 41 | + |
| 42 | + # IoT-Agent is configured for the UltraLight Protocol |
| 43 | + iot-agent: |
| 44 | + labels: |
| 45 | + org.fiware: 'tutorial' |
| 46 | + image: fiware/iotagent-ul:${ULTRALIGHT_VERSION} |
| 47 | + hostname: iot-agent |
| 48 | + container_name: fiware-iot-agent |
| 49 | + depends_on: |
| 50 | + - mongo-db |
| 51 | + - orion |
| 52 | + networks: |
| 53 | + - default |
| 54 | + ports: |
| 55 | + - "${IOTA_NORTH_PORT}:${IOTA_NORTH_PORT}" # localhost:4041 |
| 56 | + - "${IOTA_SOUTH_PORT}:${IOTA_SOUTH_PORT}" # localhost:7896 |
| 57 | + environment: |
| 58 | + - IOTA_CB_HOST=orion # name of the context broker to update context |
| 59 | + - IOTA_CB_PORT=${ORION_PORT} # port the context broker listens on to update context |
| 60 | + - IOTA_NORTH_PORT=${IOTA_NORTH_PORT} |
| 61 | + - IOTA_REGISTRY_TYPE=mongodb #Whether to hold IoT device info in memory or in a database |
| 62 | + - IOTA_LOG_LEVEL=DEBUG # The log level of the IoT Agent |
| 63 | + - IOTA_TIMESTAMP=true # Supply timestamp information with each measurement |
| 64 | + - IOTA_CB_NGSI_VERSION=v2 # use NGSIv2 when sending updates for active attributes |
| 65 | + - IOTA_AUTOCAST=true # Ensure Ultralight number values are read as numbers not strings |
| 66 | + - IOTA_MONGO_HOST=mongo-db # The host name of MongoDB |
| 67 | + - IOTA_MONGO_PORT=${MONGO_DB_PORT} # The port mongoDB is listening on |
| 68 | + - IOTA_MONGO_DB=iotagentul # The name of the database used in mongoDB |
| 69 | + - IOTA_HTTP_PORT=${IOTA_SOUTH_PORT} # The port used for device traffic over HTTP |
| 70 | + - IOTA_PROVIDER_URL=http://iot-agent:${IOTA_NORTH_PORT} |
| 71 | + healthcheck: |
| 72 | + interval: 15s |
| 73 | + |
| 74 | + |
| 75 | + # Keyrock is an Identity Management Front-End |
| 76 | + keyrock: |
| 77 | + labels: |
| 78 | + org.fiware: 'tutorial' |
| 79 | + image: fiware/idm:${KEYROCK_VERSION} |
| 80 | + container_name: fiware-keyrock |
| 81 | + hostname: keyrock |
| 82 | + networks: |
| 83 | + default: |
| 84 | + ipv4_address: 172.18.1.5 |
| 85 | + depends_on: |
| 86 | + - mysql-db |
| 87 | + ports: |
| 88 | + - "${KEYROCK_PORT}:${KEYROCK_PORT}" # localhost:3005 |
| 89 | + environment: |
| 90 | + - DEBUG=idm:* |
| 91 | + - IDM_DB_HOST=mysql-db |
| 92 | + - IDM_DB_PASS_FILE=/run/secrets/my_secret_data |
| 93 | + - IDM_DB_USER=root |
| 94 | + - IDM_HOST=http://localhost:${KEYROCK_PORT} |
| 95 | + - IDM_PORT=${KEYROCK_PORT} |
| 96 | + - IDM_HTTPS_ENABLED=${IDM_HTTPS_ENABLED} |
| 97 | + - IDM_HTTPS_PORT=${KEYROCK_HTTPS_PORT} |
| 98 | + - IDM_ADMIN_USER=alice |
| 99 | + - IDM_ADMIN_EMAIL=alice-the-admin@test.com |
| 100 | + - IDM_ADMIN_PASS=test |
| 101 | + - IDM_CSP_FORM_ACTION=* |
| 102 | + secrets: |
| 103 | + - my_secret_data |
| 104 | + healthcheck: |
| 105 | + interval: 5s |
| 106 | + |
| 107 | + |
| 108 | + # PEP Proxy for Orion |
| 109 | + kong-api-gateway: |
| 110 | + labels: |
| 111 | + org.fiware: 'tutorial' |
| 112 | + image: quay.io/fiware/kong:${KONG_VERSION} |
| 113 | + container_name: fiware-orion-kong |
| 114 | + hostname: orion-proxy |
| 115 | + networks: |
| 116 | + default: |
| 117 | + ipv4_address: 172.18.1.10 |
| 118 | + depends_on: |
| 119 | + keyrock: |
| 120 | + condition: service_started |
| 121 | + deploy: |
| 122 | + restart_policy: |
| 123 | + condition: on-failure |
| 124 | + ports: |
| 125 | + - "8000:8000/tcp" |
| 126 | + environment: |
| 127 | + - KONG_DATABASE=off |
| 128 | + - KONG_DECLARATIVE_CONFIG=/etc/kong/kong.yaml |
| 129 | + - KONG_PLUGINS=bundled,pep-plugin |
| 130 | + - KONG_PLUGINSERVER_NAMES= pep-plugin |
| 131 | + - "KONG_PLUGINSERVER_PEP_PLUGIN_QUERY_CMD=/go-plugins/pep-plugin -dump" |
| 132 | + - "KONG_PLUGINSERVER_PEP_PLUGIN_START_CMD=/go-plugins/pep-plugin" |
| 133 | + - KONG_LOG_LEVEL=debug |
| 134 | + |
| 135 | + volumes: |
| 136 | + - ../kong/kong.yaml:/etc/kong/kong.yaml |
| 137 | + |
| 138 | + |
| 139 | + # Tutorial acts as a series of dummy IoT Sensors over HTTP |
| 140 | + tutorial: |
| 141 | + labels: |
| 142 | + org.fiware: 'tutorial' |
| 143 | + image: fiware/tutorials.context-provider |
| 144 | + hostname: iot-sensors |
| 145 | + container_name: fiware-tutorial |
| 146 | + depends_on: |
| 147 | + iot-agent: |
| 148 | + condition: service_started |
| 149 | + keyrock: |
| 150 | + condition: service_started |
| 151 | + networks: |
| 152 | + default: |
| 153 | + ipv4_address: 172.18.1.7 |
| 154 | + aliases: |
| 155 | + - tutorial |
| 156 | + - context-provider |
| 157 | + expose: |
| 158 | + - "${TUTORIAL_APP_PORT}" |
| 159 | + - "${TUTORIAL_DUMMY_DEVICE_PORT}" |
| 160 | + ports: |
| 161 | + - "${TUTORIAL_APP_PORT}:${TUTORIAL_APP_PORT}" # localhost:3000 |
| 162 | + - "${TUTORIAL_DUMMY_DEVICE_PORT}:${TUTORIAL_DUMMY_DEVICE_PORT}" # localhost:3001 |
| 163 | + environment: |
| 164 | + - "MONGO_URL=mongodb://mongo-db:27017" |
| 165 | + - "DEBUG=tutorial:*" |
| 166 | + - "WEB_APP_PORT=${TUTORIAL_APP_PORT}" # Port used by the content provider proxy and web-app for viewing data |
| 167 | + - "IOTA_HTTP_HOST=iot-agent" |
| 168 | + - "IOTA_HTTP_PORT=${IOTA_SOUTH_PORT}" |
| 169 | + - "IOTA_DEFAULT_RESOURCE=/iot/d" |
| 170 | + - "DUMMY_DEVICES_PORT=${TUTORIAL_DUMMY_DEVICE_PORT}" # Port used by the dummy IOT devices to receive commands |
| 171 | + - "DUMMY_DEVICES_TRANSPORT=HTTP" # Default transport used by dummy Io devices |
| 172 | + - "CONTEXT_BROKER=http://orion-proxy:${ORION_PROXY_PORT}/v2" # URL of the PEP Proxy to update context |
| 173 | + - "OPENWEATHERMAP_KEY_ID=<ADD_YOUR_KEY_ID>" |
| 174 | + - "TWITTER_CONSUMER_KEY=<ADD_YOUR_CONSUMER_KEY>" |
| 175 | + - "TWITTER_CONSUMER_SECRET=<ADD_YOUR_CONSUMER_SECRET>" |
| 176 | + - "NGSI_LD_PREFIX=" |
| 177 | + - "SECURE_ENDPOINTS=true" |
| 178 | + - "KEYROCK_URL=http://localhost" |
| 179 | + - "KEYROCK_IP_ADDRESS=http://172.18.1.5" |
| 180 | + - "KEYROCK_PORT=${KEYROCK_PORT}" |
| 181 | + - "KEYROCK_CLIENT_ID=tutorial-dckr-site-0000-xpresswebapp" |
| 182 | + - "KEYROCK_CLIENT_SECRET=tutorial-dckr-site-0000-clientsecret" |
| 183 | + - "CALLBACK_URL=http://localhost:${TUTORIAL_APP_PORT}/login" |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | + # Databases |
| 188 | + mongo-db: |
| 189 | + labels: |
| 190 | + org.fiware: 'tutorial' |
| 191 | + image: mongo:${MONGO_DB_VERSION} |
| 192 | + hostname: mongo-db |
| 193 | + container_name: db-mongo |
| 194 | + expose: |
| 195 | + - "${MONGO_DB_PORT}" |
| 196 | + ports: |
| 197 | + - "${MONGO_DB_PORT}:${MONGO_DB_PORT}" # localhost:27017 |
| 198 | + networks: |
| 199 | + - default |
| 200 | + volumes: |
| 201 | + - mongo-db:/data |
| 202 | + healthcheck: |
| 203 | + test: | |
| 204 | + host=`hostname --ip-address || echo '127.0.0.1'`; |
| 205 | + mongo --quiet $host/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' && echo 0 || echo 1 |
| 206 | + interval: 5s |
| 207 | + |
| 208 | + |
| 209 | + mysql-db: |
| 210 | + restart: always |
| 211 | + labels: |
| 212 | + org.fiware: 'tutorial' |
| 213 | + image: mysql:${MYSQL_DB_VERSION} |
| 214 | + hostname: mysql-db |
| 215 | + container_name: db-mysql |
| 216 | + expose: |
| 217 | + - "${MYSQL_DB_PORT}" |
| 218 | + ports: |
| 219 | + - "${MYSQL_DB_PORT}:${MYSQL_DB_PORT}" # localhost:3306 |
| 220 | + networks: |
| 221 | + default: |
| 222 | + ipv4_address: 172.18.1.6 |
| 223 | + environment: |
| 224 | + - "MYSQL_ROOT_PASSWORD_FILE=/run/secrets/my_secret_data" |
| 225 | + - "MYSQL_ROOT_HOST=172.18.1.5" # Allow Keyrock to access this database |
| 226 | + volumes: |
| 227 | + - mysql-db:/var/lib/mysql |
| 228 | + - ../mysql-data:/docker-entrypoint-initdb.d/:ro |
| 229 | + secrets: |
| 230 | + - my_secret_data |
| 231 | +networks: |
| 232 | + default: |
| 233 | + labels: |
| 234 | + org.fiware: 'tutorial' |
| 235 | + ipam: |
| 236 | + config: |
| 237 | + - subnet: 172.18.1.0/24 |
| 238 | +volumes: |
| 239 | + mysql-db: ~ |
| 240 | + mongo-db: ~ |
| 241 | + |
| 242 | +secrets: |
| 243 | + my_secret_data: |
| 244 | + file: ../secrets.txt |
0 commit comments