stack/deploy/docker/stack.yml
Piotr Biernat 35dd2d38bf Update
2024-12-06 17:08:55 +01:00

480 lines
14 KiB
YAML

version: "3.9"
services:
api-registry:
image: git.pbiernat.io/egommerce/api-registry:latest
command: [
"consul",
"agent",
"-config-file=/consul/config/server.hcl",
# "-config-dir=/consul/config",
"-node=registry",
"-bootstrap-expect=1"
]
environment:
- APP_DOMAIN
- APP_NAME=api-registry
- CONSUL_HTTP_ADDR=127.0.0.1:8501
- CONSUL_HTTP_SSL=true
- CONSUL_CACERT=/usr/share/pki/ca-trust-source/anchors/internalCA.crt
- CONSUL_CLIENT_CERT=/etc/certs/registry.crt
- CONSUL_CLIENT_KEY=/etc/certs/registry.key
volumes:
- registry_data:/consul/data
- ../certs/api-registry/registry.internal.crt:/etc/certs/registry.crt:ro
- ../certs/api-registry/registry.key:/etc/certs/registry.key:ro
- ../certs/ca/internalCA.crt:/usr/share/pki/ca-trust-source/anchors/internalCA.crt:ro
# - ../bin/register-service:/bin/register-service
# - ../bin/update-resolv.sh:/bin/update-resolv
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
api-gateway: # consul client running as api-gateway
image: git.pbiernat.io/egommerce/api-registry:latest
command: [
"consul",
"agent",
"-config-file=/consul/config/gateway.hcl",
# "-config-file=/consul/config/gateway-config.hcl",
# "-config-file=/consul/config/gateway-routes.hcl",
# "-config-dir=/consul/config",
"-node=gateway",
"-retry-join=api-registry"
]
environment:
- APP_DOMAIN
- APP_NAME=api-gateway
- CONSUL_HTTP_ADDR=127.0.0.1:8501
- CONSUL_HTTP_SSL=true
- CONSUL_CACERT=/usr/share/pki/ca-trust-source/anchors/internalCA.crt
- CONSUL_CLIENT_CERT=/etc/certs/gateway.crt
- CONSUL_CLIENT_KEY=/etc/certs/gateway.key
volumes:
- gateway_data:/consul/data
- ../certs/api-gateway/gateway.internal.crt:/etc/certs/gateway.crt:ro
- ../certs/api-gateway/gateway.key:/etc/certs/gateway.key:ro
- ../certs/catalog-svc/catalog-svc.crt:/etc/certs/catalog.crt:ro
- ../certs/catalog-svc/catalog-svc.key:/etc/certs/catalog.key:ro
- ../certs/ca/internalCA.crt:/usr/share/pki/ca-trust-source/anchors/internalCA.crt:ro
# - ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
api-vault:
image: git.pbiernat.io/egommerce/api-vault:latest
command: ["vault", "server", "-config=/vault/config/server.hcl"]
environment:
- APP_DOMAIN
- APP_NAME=api-vault
- API_REGISTRY_ADDR=api-registry
volumes:
- vault_data:/vault/data
- ../certs/api-vault/vault.internal.crt:/etc/certs/vault.crt:ro
- ../certs/api-vault/vault.key:/etc/certs/vault.key:ro
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
cap_add:
- IPC_LOCK
networks:
- egommerce-network
# cap_add:
# - IPC_LOCK
api-eventbus:
image: git.pbiernat.io/egommerce/api-eventbus:latest
environment:
# - RABBITMQ_NODENAME=api-eventbus
- RABBITMQ_ERLANG_COOKIE=rabbitmq
- APP_DOMAIN
- APP_NAME=api-eventbus
- API_REGISTRY_ADDR=api-registry
volumes:
- eventbus_data:/var/lib/rabbitmq
- eventbus_logs:/var/log/rabbitmq
- ../certs/api-eventbus/eventbus.internal.crt:/etc/certs/eventbus.crt:ro
- ../certs/api-eventbus/eventbus.key:/etc/certs/eventbus.key:ro
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
api-cache:
image: git.pbiernat.io/egommerce/api-cache:latest
environment:
- APP_DOMAIN
- APP_NAME=api-cache
- API_REGISTRY_ADDR=api-registry
volumes:
# - ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
api-logger:
image: git.pbiernat.io/egommerce/api-logger:latest
environment:
- APP_DOMAIN
- APP_NAME=api-logger
- API_REGISTRY_ADDR=api-registry
volumes:
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
# api-prometheus:
# image: prom/prometheus:latest # FIXME: create private image(prod/dev)...
# user: root
# environment:
# - APP_DOMAIN
# - APP_NAME=api-prometheus
# - API_REGISTRY_ADDR=api-registry
# volumes:
# - ../etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
# - ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
# - ../bin/register-service:/bin/register-service
# - ../bin/update-resolv.sh:/bin/update-resolv
# - /var/run/docker.sock:/var/run/docker.sock
# depends_on:
# - api-registry
# networks:
# - egommerce-network
# api-grafana:
# image: grafana/grafana-oss:latest # FIXME: create private image(prod/dev)...
# environment:
# - APP_DOMAIN
# - APP_NAME=api-grafana
# - API_REGISTRY_ADDR=api-registry
# volumes:
# - grafana-db:/var/lib/grafana
# - ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
# - ../bin/update-resolv.sh:/bin/update-resolv
# - ../bin/register-service:/bin/register-service
# depends_on:
# - api-registry
# networks:
# - egommerce-network
db-postgres:
image: git.pbiernat.io/egommerce/db-postgres:latest
environment:
- APP_DOMAIN
- APP_NAME=db-postgres
- API_REGISTRY_ADDR=api-registry
- POSTGRESQL_USERNAME=postgres
- POSTGRESQL_DATABASE=postgres
- POSTGRESQL_PASSWORD=H5Gd7^37*Hka*a72
volumes:
- postgres_data:/var/lib/postgresql/data
# - ./db_migrations/init/:/docker-entrypoint-initdb.d/
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
# db-mongo:
# image: mongo:5.0.14
# environment:
# - APP_DOMAIN
# - APP_NAME=mongo-db
# - API_REGISTRY_ADDR=api-registry
# - MONGO_INITDB_ROOT_USERNAME=mongodb
# - MONGO_INITDB_ROOT_PASSWORD
# volumes:
# - mongodb_data:/data/db
# - ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
# - ../bin/register-service:/bin/register-service
# - ../bin/update-resolv.sh:/bin/update-resolv
# depends_on:
# - api-registry
# deploy:
# mode: replicated
# replicas: 1
# extra_hosts:
# - "host.docker.internal:host-gateway"
# networks:
# - egommerce-network
# API micro-services
identity-svc:
image: git.pbiernat.io/egommerce/identity-svc:latest
environment:
- APP_NAME=identity-svc
- APP_PATH_PREFIX=/identity
- API_REGISTRY_ADDR=api-gateway
- APP_DOMAIN
- APP_KV_NAMESPACE
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/identity-svc/identity-svc.crt:/certs/client.crt:ro
- ../certs/identity-svc/identity-svc.key:/certs/client.key:ro
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../db_migrations/identity-svc:/migrations
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
catalog-svc:
image: git.pbiernat.io/egommerce/catalog-svc:latest
environment:
- APP_NAME=catalog-svc
- APP_PATH_PREFIX=/catalog
- API_REGISTRY_ADDR=api-gateway
- APP_DOMAIN
- APP_KV_NAMESPACE
- AUTH_HANDLER_URL
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/catalog-svc/catalog-svc.crt:/certs/client.crt:ro
- ../certs/catalog-svc/catalog-svc.key:/certs/client.key:ro
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../db_migrations/catalog-svc:/migrations
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
basket-svc:
image: git.pbiernat.io/egommerce/basket-svc:latest
environment:
- APP_NAME=basket-svc
- APP_PATH_PREFIX=/basket
- API_REGISTRY_ADDR=api-gateway
- APP_DOMAIN
- APP_KV_NAMESPACE
- AUTH_HANDLER_URL
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/basket-svc/basket-svc.crt:/certs/client.crt:ro
- ../certs/basket-svc/basket-svc.key:/certs/client.key:ro
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../db_migrations/basket-svc:/migrations
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
order-svc:
image: git.pbiernat.io/egommerce/order-svc:latest
environment:
- APP_NAME=order-svc
- APP_PATH_PREFIX=/order
- API_REGISTRY_ADDR=api-gateway
- APP_DOMAIN
- APP_KV_NAMESPACE
- AUTH_HANDLER_URL
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/order-svc/order-svc.crt:/certs/client.crt:ro
- ../certs/order-svc/order-svc.key:/certs/client.key:ro
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../db_migrations/order-svc:/migrations
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
pricing-svc:
image: git.pbiernat.io/egommerce/pricing-svc:latest
environment:
- APP_NAME=pricing-svc
- APP_PATH_PREFIX=/pricing
- API_REGISTRY_ADDR=api-gateway
- APP_DOMAIN
- APP_KV_NAMESPACE
- AUTH_HANDLER_URL
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/pricing-svc/pricing-svc.crt:/certs/client.crt:ro
- ../certs/pricing-svc/pricing-svc.key:/certs/client.key:ro
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../db_migrations/pricing-svc:/migrations
- ../bin/register-service:/bin/register-service
- ../bin/update-resolv.sh:/bin/update-resolv
depends_on:
- api-registry
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
# Workers (Eventbus)
basket-worker:
image: git.pbiernat.io/egommerce/basket-worker:latest
environment:
- APP_NAME=basket-worker
- APP_KV_NAMESPACE
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/update-resolv.sh:/bin/update-resolv
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
catalog-worker:
image: git.pbiernat.io/egommerce/catalog-worker:latest
environment:
- APP_NAME=catalog-worker
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/update-resolv.sh:/bin/update-resolv
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
pricing-worker:
image: git.pbiernat.io/egommerce/pricing-worker:latest
environment:
- APP_NAME=pricing-worker
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/update-resolv.sh:/bin/update-resolv
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
order-worker:
image: git.pbiernat.io/egommerce/order-worker:latest
environment:
- APP_NAME=order-worker
- DATABASE_URL
- MONGODB_URL
- EVENTBUS_URL
volumes:
- ../certs/ca/internalCA.crt:/usr/local/share/ca-certificates/internalCA.crt:ro
- ../bin/update-resolv.sh:/bin/update-resolv
deploy:
mode: replicated
replicas: 1
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- egommerce-network
volumes:
postgres_data: ~
mongodb_data: ~
registry_data: ~
gateway_data: ~
vault_data: ~
eventbus_data: ~
eventbus_logs: ~
# grafana-db: ~
networks:
# Infrastructure networks
egommerce-network:
driver: overlay