Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
97 lines (93 loc) · 5.91 KB
/
Copy pathdocker-compose.yml
File metadata and controls
97 lines (93 loc) · 5.91 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
services:
# --- Unified Server (API + Frontend) ---
server:
build:
context: .
dockerfile: Dockerfile
args:
TARGET: server
ports:
- "8080:8080"
environment:
- PROJECT_ID=${PROJECT_ID}
- REGION=${REGION}
- LOG_LEVEL=DEBUG
- SERVER_PORT=8080
- GEMINI_API_KEY=${GEMINI_API_KEY}
- PUBSUB_EMULATOR_HOST=pubsub:8085
- PUBSUB_TOPIC_SCAN_REQUESTS=scan-requests
- PUBSUB_SUB_SCAN_REQUESTS=scan-requests-sub
- DATABASE_TYPE=SQLITE_MEM
- GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/application_default_credentials.json
volumes:
- /home/ikogan/.config/gcloud/application_default_credentials.json:/tmp/keys/application_default_credentials.json:ro
depends_on:
pubsub:
condition: service_healthy
setup-pubsub:
condition: service_completed_successfully
# --- Worker Service ---
# worker:
# build:
# context: .
# dockerfile: Dockerfile
# args:
# TARGET: worker
# environment:
# - PROJECT_ID=${PROJECT_ID}
# - REGION=${REGION}
# - LOG_LEVEL=DEBUG
# - GEMINI_API_KEY=${GEMINI_API_KEY}
# - PUBSUB_EMULATOR_HOST=pubsub:8085
# - PUBSUB_TOPIC_SCAN_REQUESTS=scan-requests
# - PUBSUB_SUB_SCAN_REQUESTS=scan-requests-sub
# - DATABASE_TYPE=SQLITE_MEM
# - PORT=8080 # For health checks
# - GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/application_default_credentials.json
# volumes:
# - /home/ikogan/.config/gcloud/application_default_credentials.json:/tmp/keys/application_default_credentials.json:ro
# depends_on:
# pubsub:
# condition: service_healthy
# setup-pubsub:
# condition: service_completed_successfully
# --- Infrastructure Emulators ---
pubsub:
image: gcr.io/google.com/cloudsdktool/google-cloud-cli:560.0.0-emulators
command: gcloud beta emulators pubsub start --project=$PROJECT_ID --host-port=0.0.0.0:8085 --quiet
ports:
- "8085:8085"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8085/"]
interval: 5s
timeout: 10s
retries: 5
setup-pubsub:
image: gcr.io/google.com/cloudsdktool/google-cloud-cli:560.0.0-emulators
environment:
- PROJECT_ID=${PROJECT_ID}
- PUBSUB_EMULATOR_HOST=pubsub:8085
command: >
sh -c "echo 'Waiting for Pub/Sub emulator...' &&
until curl -s http://$$PUBSUB_EMULATOR_HOST; do sleep 2; done &&
echo 'Creating topics and subscriptions...' &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/topics/scan-requests || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/subscriptions/scan-requests-sub -H 'Content-Type: application/json' -d \"{\\\"topic\\\": \\\"projects/$${PROJECT_ID}/topics/scan-requests\\\", \\\"pushConfig\\\": {\\\"pushEndpoint\\\": \\\"http://server:8080/pubsub/scan-requests\\\"}}\" || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/topics/aggregator-tasks || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/subscriptions/aggregator-tasks-sub -H 'Content-Type: application/json' -d \"{\\\"topic\\\": \\\"projects/$${PROJECT_ID}/topics/aggregator-tasks\\\", \\\"pushConfig\\\": {\\\"pushEndpoint\\\": \\\"http://server:8080/pubsub/aggregator\\\"}}\" || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/topics/modeler-tasks || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/subscriptions/modeler-tasks-sub -H 'Content-Type: application/json' -d \"{\\\"topic\\\": \\\"projects/$${PROJECT_ID}/topics/modeler-tasks\\\", \\\"pushConfig\\\": {\\\"pushEndpoint\\\": \\\"http://server:8080/pubsub/modeler\\\"}}\" || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/topics/validator-tasks || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/subscriptions/validator-tasks-sub -H 'Content-Type: application/json' -d \"{\\\"topic\\\": \\\"projects/$${PROJECT_ID}/topics/validator-tasks\\\", \\\"pushConfig\\\": {\\\"pushEndpoint\\\": \\\"http://server:8080/pubsub/validator\\\"}}\" || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/topics/reviewer-tasks || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/subscriptions/reviewer-tasks-sub -H 'Content-Type: application/json' -d \"{\\\"topic\\\": \\\"projects/$${PROJECT_ID}/topics/reviewer-tasks\\\", \\\"pushConfig\\\": {\\\"pushEndpoint\\\": \\\"http://server:8080/pubsub/reviewer\\\"}}\" || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/topics/tagger-tasks || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/subscriptions/tagger-tasks-sub -H 'Content-Type: application/json' -d \"{\\\"topic\\\": \\\"projects/$${PROJECT_ID}/topics/tagger-tasks\\\", \\\"pushConfig\\\": {\\\"pushEndpoint\\\": \\\"http://server:8080/pubsub/tagger\\\"}}\" || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/topics/reporter-tasks || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/subscriptions/reporter-tasks-sub -H 'Content-Type: application/json' -d \"{\\\"topic\\\": \\\"projects/$${PROJECT_ID}/topics/reporter-tasks\\\", \\\"pushConfig\\\": {\\\"pushEndpoint\\\": \\\"http://server:8080/pubsub/reporter\\\"}}\" || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/topics/monitoring-events || true &&
curl -s -X PUT http://$$PUBSUB_EMULATOR_HOST/v1/projects/$${PROJECT_ID}/subscriptions/monitoring-events-sub -H 'Content-Type: application/json' -d \"{\\\"topic\\\": \\\"projects/$${PROJECT_ID}/topics/monitoring-events\\\"}\" || true &&
echo 'Pub/Sub resources created.'"
depends_on:
pubsub:
condition: service_healthy