-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathdocker-compose-fleets-test.yaml
More file actions
156 lines (155 loc) · 5.34 KB
/
Copy pathdocker-compose-fleets-test.yaml
File metadata and controls
156 lines (155 loc) · 5.34 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# compose config for fleets integration tests (mock CE + MinIO)
x-gateway-env: &gateway-env
DEBUG: "1"
SETTINGS_AUTH_MECHANISM: mock_token
DATABASE_HOST: postgres
DATABASE_PORT: "5432"
DATABASE_NAME: serverlessdb
DATABASE_USER: serverlessuser
DATABASE_PASSWORD: serverlesspassword
FLEETS_MOCK_ENABLED: "1"
MINIO_ENDPOINT: http://minio:9000
# Host-relative: only valid for presigned URLs handed back to the host-side
# pytest client (where 127.0.0.1:9000 is the published MinIO port). The
# gateway itself must never fetch this — internal access uses MINIO_ENDPOINT.
MINIO_PUBLIC_ENDPOINT: http://127.0.0.1:9000
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
IBM_CLOUD_API_KEY: fake-api-key-for-test
CE_HMAC_SECRET_NAME: cos-hmac-secret
LIMITS_MAX_FLEETS: "10"
FLEETS_DEFAULT_IMAGE: python:3.11-slim
DEFAULT_COMPUTE_PROFILE: cx3d-4x16
CE_DEFAULT_PROJECT_NAME: test-project
CE_PROJECTS: '[{"project_id":"test-project-id","project_name":"test-project","region":"us-south","resource_group_id":"test-rg-id","subnet_pool_id":"test-subnet-pool-id","pds_name_state":"test-pds-state","pds_name_users":"test-pds-users","pds_name_providers":"test-pds-providers","cos_instance_name":"test-cos-instance","cos_key_name":"test-cos-key","cos_bucket_task_store_name":"task-store-bucket","cos_bucket_user_data_name":"user-data-bucket","cos_bucket_provider_data_name":"provider-data-bucket"}]'
CE_COS_USE_PUBLIC_ENDPOINT: "true"
FLEETS_GATEWAY_HOST: http://gateway:8000
# Explicit opt-out of OTEL span export (default is "0" — set for clarity).
OTEL_ENABLED: "0"
services:
postgres:
image: postgres:15
environment:
POSTGRES_DB: serverlessdb
POSTGRES_USER: serverlessuser
POSTGRES_PASSWORD: serverlesspassword
networks:
- safe-tier
ports:
- 5432:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U serverlessuser -d serverlessdb"]
interval: 1s
timeout: 5s
retries: 5
minio:
image: minio/minio:latest
command: server /data
environment:
- MINIO_ROOT_USER=minioadmin
- MINIO_ROOT_PASSWORD=minioadmin
networks:
- safe-tier
ports:
- 9000:9000
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:9000/minio/health/live || exit 1"]
interval: 5s
timeout: 5s
retries: 5
minio-init:
image: minio/mc:latest
depends_on:
minio:
condition: service_healthy
entrypoint: >
/bin/sh -c "
mc alias set local http://minio:9000 minioadmin minioadmin &&
mc mb --ignore-existing local/user-data-bucket &&
mc mb --ignore-existing local/provider-data-bucket &&
mc mb --ignore-existing local/task-store-bucket &&
mc mb --ignore-existing local/fleet-state &&
mc mb --ignore-existing local/fleet-state-archive &&
echo 'Buckets created successfully'
"
networks:
- safe-tier
gateway:
container_name: gateway
build:
context: ./
dockerfile: gateway/Dockerfile
command: python manage.py runserver 0.0.0.0:8000
ports:
- 8000:8000
user: "root" # root user is needed to write on volumes and sync files from local system (see the watch: section)
environment:
<<: *gateway-env
DJANGO_SUPERUSER_USERNAME: admin
DJANGO_SUPERUSER_PASSWORD: "123"
DJANGO_SUPERUSER_EMAIL: admin@noemail.com
SITE_HOST: http://gateway:8000
networks:
- safe-tier
volumes:
- media-data:/usr/src/app/media/
depends_on:
postgres:
condition: service_healthy
minio-init:
condition: service_completed_successfully
develop:
watch: &gateway-watch
- path: ./gateway
action: sync
target: /usr/src/app
scheduler:
user: "root" # root user is needed to write on volumes
container_name: scheduler
build:
context: ./
dockerfile: gateway/Dockerfile
# Skip sync_ce_project here — the gateway entrypoint already creates the
# CodeEngineProject row. Running it from both services races and can
# produce duplicate rows (MultipleObjectsReturned on the next call).
entrypoint: ["/bin/sh", "-c", "python manage.py migrate_with_lock && exec python manage.py run_scheduler"]
environment:
<<: *gateway-env
networks:
- safe-tier
volumes:
- media-data:/usr/src/app/media/
depends_on:
postgres:
condition: service_healthy
minio-init:
condition: service_completed_successfully
# The scheduler runs the same code and drives status transitions, so it must
# live-sync too; otherwise `docker compose watch` updates the gateway while
# the scheduler keeps running stale code.
develop:
watch: *gateway-watch
fleet-worker:
container_name: fleet-worker
build:
context: ./
dockerfile: tests/fleets/fleet-worker/Dockerfile
privileged: true
environment:
- MINIO_ENDPOINT=http://minio:9000
- MINIO_ACCESS_KEY=minioadmin
- MINIO_SECRET_KEY=minioadmin
- FLEET_STATE_BUCKET=fleet-state
- TASK_STORE_BUCKET=task-store-bucket
- USER_DATA_BUCKET=user-data-bucket
- PROVIDER_DATA_BUCKET=provider-data-bucket
- FLEET_WORKER_STARTUP_DELAY_SEC=2
networks:
- safe-tier
depends_on:
minio-init:
condition: service_completed_successfully
networks:
safe-tier:
volumes:
media-data: