Files
gapido-grpc-auth/docker-compose.yml

111 lines
3.4 KiB
YAML

services:
auth-service:
build: .
command: python -m gapido_auth.transport.grpc.server
environment:
MONGO_URI: mongodb://mongo:27017
MONGO_DB_NAME: ${MONGO_DB_NAME:-gapido_auth}
REDIS_URL: redis://redis:6379/0
RABBITMQ_URL: amqp://guest:guest@rabbitmq:5672/
JWT_SECRET_KEY: ${JWT_SECRET_KEY:-change-me-use-a-long-random-secret}
JWT_ISSUER: ${JWT_ISSUER:-gapido-auth}
ACCESS_TOKEN_TTL_SECONDS: ${ACCESS_TOKEN_TTL_SECONDS:-900}
REFRESH_TOKEN_TTL_SECONDS: ${REFRESH_TOKEN_TTL_SECONDS:-604800}
OTP_TTL_SECONDS: ${OTP_TTL_SECONDS:-120}
OTP_MAX_ATTEMPTS: ${OTP_MAX_ATTEMPTS:-5}
OTP_REQUEST_LIMIT: ${OTP_REQUEST_LIMIT:-3}
OTP_REQUEST_WINDOW_SECONDS: ${OTP_REQUEST_WINDOW_SECONDS:-300}
SMS_PROVIDER: ${SMS_PROVIDER:-debug}
KAVENEGAR_LOGIN_TEMPLATE: ${KAVENEGAR_LOGIN_TEMPLATE:-login-otp}
SMS_IR_VERIFY_TEMPLATE_ID: ${SMS_IR_VERIFY_TEMPLATE_ID:-570574}
ADMIN_MOBILE: ${ADMIN_MOBILE:-989120000000}
GRPC_HOST: 0.0.0.0
GRPC_PORT: 50051
healthcheck:
test:
[
"CMD",
"python",
"-c",
"import grpc; from grpc_health.v1 import health_pb2, health_pb2_grpc; channel=grpc.insecure_channel('localhost:50051'); stub=health_pb2_grpc.HealthStub(channel); stub.Check(health_pb2.HealthCheckRequest(), timeout=3)",
]
interval: 10s
timeout: 5s
retries: 12
start_period: 20s
depends_on:
mongo:
condition: service_healthy
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
sms-worker:
build: .
command: python -m gapido_auth.infrastructure.worker
environment:
MONGO_URI: mongodb://mongo:27017
REDIS_URL: redis://redis:6379/0
RABBITMQ_URL: amqp://guest:guest@rabbitmq:5672/
SMS_PROVIDER: ${SMS_PROVIDER:-debug}
KAVENEGAR_API_KEY: ${KAVENEGAR_API_KEY:-replace-with-real-key}
SMS_IR_API_KEY: ${SMS_IR_API_KEY:-replace-with-real-key}
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_healthy
demo-app:
build: .
command: uvicorn gapido_demo.app:app --host 0.0.0.0 --port 8080
environment:
AUTH_GRPC_TARGET: auth-service:50051
REDIS_URL: redis://redis:6379/0
DEMO_ENABLE_DEBUG_OTP: ${DEMO_ENABLE_DEBUG_OTP:-true}
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/healthz', timeout=3).read()"]
interval: 10s
timeout: 5s
retries: 12
start_period: 10s
depends_on:
auth-service:
condition: service_healthy
redis:
condition: service_healthy
mongo:
image: ${MONGO_IMAGE:-mongo:4.4.29-focal}
volumes:
- mongo-data:/data/db
healthcheck:
test: ["CMD-SHELL", "mongosh --quiet --eval \"db.adminCommand('ping').ok\" || mongo --quiet --eval \"db.adminCommand('ping').ok\""]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s
redis:
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 20
rabbitmq:
image: rabbitmq:3.13-management-alpine
volumes:
- rabbitmq-data:/var/lib/rabbitmq
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "check_port_connectivity"]
interval: 5s
timeout: 5s
retries: 20
volumes:
mongo-data:
rabbitmq-data: