-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
143 lines (130 loc) · 6.27 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
143 lines (130 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: eventsnap
x-env-file: &env-file
- .env
x-networks: &networks
- Eventsnap-Network
# - Infrastructure-Network
x-host-and-networks-config: &host-and-networks
extra_hosts:
- "host.docker.internal:host-gateway"
networks: *networks
x-main-api-and-celery-deps: &main-api-and-celery-deps
es-rabbitmq:
condition: service_healthy
es-db_migration:
condition: service_completed_successfully
es-inference_api:
condition: service_started
networks:
Eventsnap-Network:
name: Eventsnap-Network
driver: bridge
# Infrastructure-Network:
# external: true
volumes:
rabbitmq_data:
main_api_venv:
inference_api_venv:
services:
es-rabbitmq:
image: rabbitmq:3-management
container_name: es-rabbitmq
restart: unless-stopped
env_file: *env-file
ports:
- "5672:5672"
- "15672:15672"
volumes:
- rabbitmq_data:/var/lib/rabbitmq
- ./config/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks: *networks
es-inference_api:
build:
context: ./inference_api
dockerfile: Dockerfile.gpu
target: development
env_file: *env-file
volumes:
- ./inference_api:/app
- inference_api_venv:/app/.venv
ports:
- "5000:5000"
- "50051:50051"
restart: unless-stopped
command: >
bash -c 'if [ -n "$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" ] && [ -z "$$INFISICAL_TOKEN" ]; then export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id="$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" --client-secret="$$INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET" --plain --silent); fi; if [ -n "$$INFISICAL_TOKEN" ]; then infisical run --projectId "$$INFISICAL_PROJECT_ID" --env="$${INFISICAL_ENVIRONMENT:-dev}" -- uv run uvicorn presentation.api.main:app --host 0.0.0.0 --port 5000 --reload; else uv run uvicorn presentation.api.main:app --host 0.0.0.0 --port 5000 --reload; fi'
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
networks: *networks
es-db_migration:
build:
context: ./main_api
target: development
container_name: eventsnap_migration
command: >
bash -c 'if [ -n "$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" ] && [ -z "$$INFISICAL_TOKEN" ]; then export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id="$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" --client-secret="$$INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET" --plain --silent); fi; if [ -n "$$INFISICAL_TOKEN" ]; then infisical run --projectId "$$INFISICAL_PROJECT_ID" --env="$${INFISICAL_ENVIRONMENT:-dev}" -- alembic upgrade head; else alembic upgrade head; fi'
env_file: *env-file
volumes:
- ./main_api:/app
- main_api_venv:/app/.venv
restart: no
<<: *host-and-networks
es-main_api:
build:
context: ./main_api
target: development
env_file: *env-file
ports:
- "8000:8000"
volumes:
- ./main_api:/app
- main_api_venv:/app/.venv
command: >
bash -c 'if [ -n "$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" ] && [ -z "$$INFISICAL_TOKEN" ]; then export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id="$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" --client-secret="$$INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET" --plain --silent); fi; if [ -n "$$INFISICAL_TOKEN" ]; then infisical run --projectId "$$INFISICAL_PROJECT_ID" --env="$${INFISICAL_ENVIRONMENT:-dev}" -- uv run uvicorn presentation.api.main:app --host 0.0.0.0 --port 8000 --reload; else uv run uvicorn presentation.api.main:app --host 0.0.0.0 --port 8000 --reload; fi'
depends_on: *main-api-and-celery-deps
restart: unless-stopped
<<: *host-and-networks
es-celery_worker:
build:
context: ./main_api
target: development
env_file: *env-file
volumes:
- ./main_api:/app
- main_api_venv:/app/.venv
command: >
bash -c 'if [ -n "$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" ] && [ -z "$$INFISICAL_TOKEN" ]; then export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id="$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" --client-secret="$$INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET" --plain --silent); fi; if [ -n "$$INFISICAL_TOKEN" ]; then infisical run --projectId "$$INFISICAL_PROJECT_ID" --env="$${INFISICAL_ENVIRONMENT:-dev}" -- watchmedo auto-restart -q --debug-force-polling --directory=/app --pattern="*.py" --recursive -- celery -A infrastructure.queue.celery_app worker --loglevel=info --concurrency=4; else watchmedo auto-restart -q --debug-force-polling --directory=/app --pattern="*.py" --recursive -- celery -A infrastructure.queue.celery_app worker --loglevel=info --concurrency=4; fi'
depends_on: *main-api-and-celery-deps
restart: unless-stopped
<<: *host-and-networks
es-celery_flower:
build:
context: ./main_api
target: development
env_file: *env-file
ports:
- "5555:5555"
volumes:
- ./main_api:/app
- main_api_venv:/app/.venv
environment:
- FLOWER_UNAUTHENTICATED_API=true
command: >
bash -c 'if [ -n "$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" ] && [ -z "$$INFISICAL_TOKEN" ]; then export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id="$$INFISICAL_MACHINE_IDENTITY_CLIENT_ID" --client-secret="$$INFISICAL_MACHINE_IDENTITY_CLIENT_SECRET" --plain --silent); fi; if [ -n "$$INFISICAL_TOKEN" ]; then infisical run --projectId "$$INFISICAL_PROJECT_ID" --env="$${INFISICAL_ENVIRONMENT:-dev}" -- watchmedo auto-restart -q --debug-force-polling --directory=/app --pattern="*.py" --recursive -- celery -A infrastructure.queue.celery_app flower --port=5555 --broker_api=http://$$RABBITMQ_DEFAULT_USER:$$RABBITMQ_DEFAULT_PASS@es-rabbitmq:15672/api/; else watchmedo auto-restart -q --debug-force-polling --directory=/app --pattern="*.py" --recursive -- celery -A infrastructure.queue.celery_app flower --port=5555 --broker_api=http://$$RABBITMQ_DEFAULT_USER:$$RABBITMQ_DEFAULT_PASS@es-rabbitmq:15672/api/; fi'
depends_on:
es-rabbitmq:
condition: service_healthy
es-celery_worker:
condition: service_started
restart: unless-stopped
<<: *host-and-networks