You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
284 lines
8.5 KiB
284 lines
8.5 KiB
version: '3.8'
|
|
|
|
services:
|
|
# base image for building our python apps, used for speeding up the build process
|
|
web-base-image:
|
|
build:
|
|
context: ./docker-python/base
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements.txt
|
|
image: web-base
|
|
|
|
# generates random numbers and lists them
|
|
# uses healthcheck by making a curl request to a GET endpoint
|
|
web-random:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements.txt
|
|
image: web-standard
|
|
ports:
|
|
- "800:5000"
|
|
entrypoint: python /root/flask-mongodb-example/python/random_demo.py
|
|
depends_on:
|
|
- mongo
|
|
- web-base-image
|
|
healthcheck:
|
|
test: curl --silent --show-error --fail "http://localhost:5000/random?lower=0&upper10"
|
|
interval: 10s
|
|
start_period: 30s
|
|
|
|
# generates random numbers and lists them, it's faster thatn web-random because it's using pypy accelerator
|
|
web-random-pypy:
|
|
build:
|
|
context: ./docker-python-pypy
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements.txt
|
|
image: web-standard-pypy
|
|
ports:
|
|
- "801:5000"
|
|
entrypoint: pypy /root/flask-mongodb-example/python/random_demo.py
|
|
depends_on:
|
|
- mongo
|
|
|
|
# Create, read, update and delete operations over a user collection
|
|
web-users:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements.txt
|
|
image: web-standard
|
|
ports:
|
|
- "81:5000"
|
|
entrypoint: python /root/flask-mongodb-example/python/users.py
|
|
environment:
|
|
- REDIS_PASSWORD=/run/secrets/redis_password
|
|
- PYTHONUNBUFFERED=1
|
|
secrets:
|
|
- redis_password
|
|
depends_on:
|
|
- mongo
|
|
- web-base-image
|
|
- redis
|
|
|
|
# Uses an MQTT server (Mosquitto) to allow to publish sensor updates over MQTT
|
|
background-mqtt:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements-mqtt.txt
|
|
image: backgorund-mqtt-image
|
|
entrypoint: python /root/flask-mongodb-example/python/mqtt.py
|
|
environment:
|
|
- MQTT_USER=/run/secrets/mqtt_user
|
|
- MQTT_PASSWORD=/run/secrets/mqtt_password
|
|
- PYTHONUNBUFFERED=1
|
|
secrets:
|
|
- mqtt_user
|
|
- mqtt_password
|
|
depends_on:
|
|
- mongo
|
|
- mqtt
|
|
- influxdb
|
|
tty: true
|
|
|
|
# Fulltext search engine backed by fulltext MongoDb index
|
|
web-fulltext-search:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements.txt
|
|
image: web-standard
|
|
ports:
|
|
- "82:5000"
|
|
entrypoint: python /root/flask-mongodb-example/python/fulltext_search.py
|
|
depends_on:
|
|
- mongo
|
|
|
|
# Geospacial search service that supports adding places, and quering the placing by coordonates and distance
|
|
web-geolocation-search:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements.txt
|
|
image: web-geolocation-image
|
|
ports:
|
|
- "83:5000"
|
|
entrypoint: python /root/flask-mongodb-example/python/geolocation_search.py
|
|
depends_on:
|
|
- mongo
|
|
|
|
# Baesian average demo (https://en.wikipedia.org/wiki/Bayesian_average)
|
|
web-baesian:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements.txt
|
|
image: web-standard
|
|
ports:
|
|
- "84:5000"
|
|
entrypoint: python /root/flask-mongodb-example/python/baesian.py
|
|
depends_on:
|
|
- mongo
|
|
|
|
# A demo of working with file photo uploads, hash searching and using docker volumes
|
|
web-photo-process:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements-photo.txt
|
|
image: web-photo-image
|
|
ports:
|
|
- "85:5000"
|
|
entrypoint: python /root/flask-mongodb-example/python/photo_process.py
|
|
volumes:
|
|
- ./container-storage:/root/storage
|
|
depends_on:
|
|
- mongo
|
|
|
|
# A virtual book library
|
|
web-book-collection:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements-restplus.txt
|
|
image: web-bookcollection-image
|
|
environment:
|
|
- PYTHONUNBUFFERED=1
|
|
ports:
|
|
- "86:5000"
|
|
entrypoint: python /root/flask-mongodb-example/python/bookcollection.py
|
|
depends_on:
|
|
- mongo
|
|
- web-users
|
|
|
|
# Wame functionality as web-users but build with fastapi
|
|
# runs with gunicorn on two processor cores [-w 2]
|
|
web-users-fast-api:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements-fastapi.txt
|
|
image: web-users-fastapi-image
|
|
ports:
|
|
- "88:5000" # port 87 is restricted in browsers
|
|
entrypoint: gunicorn -w 2 -k uvicorn.workers.UvicornH11Worker --bind 0.0.0.0:5000 --log-level debug users-fastapi:app
|
|
depends_on:
|
|
- mongo
|
|
|
|
# A tic tac toe game written in flask using flask_session. It has a simple UI
|
|
web-tictactoe:
|
|
build:
|
|
context: ./docker-python
|
|
args:
|
|
requirements: /root/flask-mongodb-example/python/requirements.txt
|
|
image: web-standard
|
|
ports:
|
|
- "89:5000"
|
|
entrypoint: python /root/flask-mongodb-example/python/tictactoe.py
|
|
|
|
# Database for grafana
|
|
influxdb:
|
|
build: docker-influxdb
|
|
env_file: ./docker-influxdb/configuration.env
|
|
ports:
|
|
- '8086:8086'
|
|
volumes:
|
|
- influxdb_data:/var/lib/influxdb
|
|
|
|
# For showing graphs on sensors
|
|
grafana:
|
|
build: docker-grafana
|
|
env_file: ./docker-grafana/configuration.env
|
|
links:
|
|
- influxdb
|
|
ports:
|
|
- '3000:3000'
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
|
|
# Genaral purpose database
|
|
# uses healthcheck for replicasset rs.status().ok
|
|
mongo:
|
|
image: mongo:4.4.5-bionic
|
|
hostname: mongodb
|
|
ports:
|
|
- '27017:27017'
|
|
environment:
|
|
- MONGO_REPLICA_SET_NAME=dan
|
|
command:
|
|
- --storageEngine
|
|
- wiredTiger
|
|
- --replSet
|
|
- myrepl
|
|
healthcheck:
|
|
test: test $$(echo "rs.initiate().ok || rs.status().ok" | mongo --quiet) -eq 1
|
|
interval: 10s
|
|
start_period: 30s
|
|
|
|
# Redis server, used here for caching
|
|
# uses healthcheck with redis-cli ping
|
|
redis:
|
|
build:
|
|
context: ./docker-redis
|
|
ports:
|
|
- '6379:6379'
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
start_period: 30s
|
|
|
|
# Mosquitto MQTT broker
|
|
mqtt:
|
|
build:
|
|
context: ./docker-mosquitto
|
|
ports:
|
|
- "1883:1883"
|
|
|
|
# An api gateway
|
|
krakend:
|
|
image: devopsfaith/krakend
|
|
volumes:
|
|
- ${PWD}/krakend.json:/etc/krakend/krakend.json
|
|
ports:
|
|
- "8080:8080"
|
|
depends_on:
|
|
- web-random
|
|
- web-users
|
|
|
|
# Used to test services
|
|
web-test:
|
|
image: alpine
|
|
depends_on:
|
|
- web-base-image
|
|
- web-random
|
|
- web-random-pypy
|
|
- web-users
|
|
- background-mqtt
|
|
- web-fulltext-search
|
|
- web-geolocation-search
|
|
- web-baesian
|
|
- web-photo-process
|
|
- web-book-collection
|
|
- web-users-fast-api
|
|
- influxdb
|
|
- grafana
|
|
- mongo
|
|
- mqtt
|
|
- krakend
|
|
- web-tictactoe
|
|
- redis
|
|
|
|
|
|
volumes:
|
|
grafana_data: {}
|
|
influxdb_data: {}
|
|
|
|
secrets:
|
|
mqtt_user:
|
|
file: ./secrets/mqtt_user.txt
|
|
mqtt_password:
|
|
file: ./secrets/mqtt_pass.txt
|
|
redis_password:
|
|
file: ./secrets/redis_pass.txt
|
|
|