Repository navigation
Expand file tree
/
Copy pathcompose.yml
More file actions
147 lines (138 loc) · 5.16 KB
/
Copy pathcompose.yml
File metadata and controls
147 lines (138 loc) · 5.16 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
# The Flagsmith API the spec runs against. The runner runs on the host and starts the
# SDK under test in a container on this compose project's network (see README.md).
#
# The experimentation services mirror Flagsmith's own docker-compose.yml, so that `@events`
# scenarios run against the real ingestion and delivery path: an SDK posts events to the
# ingestion server, which writes them to Kafka, from where warehouse delivery inserts them
# into the environment's warehouse. The spec provisions ClickHouse as that warehouse and
# reads the events back out of it.
name: sdk-spec
volumes:
clickhouse-data:
services:
postgres:
image: postgres:15.5-alpine
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: flagsmith
healthcheck:
test: ['CMD-SHELL', 'pg_isready -d flagsmith -U postgres']
interval: 2s
timeout: 2s
retries: 30
flagsmith:
# The Flagsmith version a spec release is verified against.
image: ${FLAGSMITH_IMAGE:-docker.io/flagsmith/flagsmith:2.287.0}
command: migrate-and-serve
environment:
DATABASE_URL: postgresql://postgres:password@postgres:5432/flagsmith
DJANGO_ALLOWED_HOSTS: '*'
DJANGO_SECRET_KEY: sdk-spec
ENVIRONMENT: test
EXPERIMENTATION_ENABLED: 'true'
# Encrypts the warehouse connection's credentials; warehouse delivery decrypts them
# with the same value.
WAREHOUSE_CREDENTIALS_SECRET: &warehouse-credentials-secret sdk-spec
ports:
- ${FLAGSMITH_PORT:-8000}:8000
healthcheck:
test: ['CMD', 'python', '-c', 'import urllib.request; urllib.request.urlopen("http://localhost:8000/health/liveness/")']
interval: 3s
timeout: 3s
retries: 60
depends_on:
postgres:
condition: service_healthy
kafka:
image: apache/kafka:3.9.1
environment:
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:9093
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
healthcheck:
test: ['CMD-SHELL', '/opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092']
interval: 5s
timeout: 10s
retries: 30
kafka-init:
image: apache/kafka:3.9.1
entrypoint: ['/bin/sh', '-c']
command:
- |
for topic in flagsmith_warehouse_events external_warehouse_events external_warehouse_events_retry; do
/opt/kafka/bin/kafka-topics.sh --bootstrap-server kafka:9092 --create --if-not-exists --topic $$topic
done
depends_on:
kafka:
condition: service_healthy
# The environment's warehouse: where delivered events land and the runner reads them from.
clickhouse:
image: clickhouse/clickhouse-server:25.12
environment:
CLICKHOUSE_USER: flagsmith
CLICKHOUSE_PASSWORD: password
ulimits:
nofile:
soft: 262144
hard: 262144
volumes:
- clickhouse-data:/var/lib/clickhouse
ports:
- ${CLICKHOUSE_PORT:-8123}:8123
healthcheck:
test: ['CMD', 'wget', '--spider', '-q', 'http://localhost:8123/ping']
interval: 3s
timeout: 3s
retries: 30
# Creates the events table, from the schema the pinned Flagsmith version ships.
clickhouse-init:
image: clickhouse/clickhouse-server:25.12
entrypoint: ['/bin/sh', '-c']
command:
- |
set -e
wget -qO /tmp/events.sql https://raw.githubusercontent.com/Flagsmith/flagsmith/v2.287.0/experimentation/clickhouse/events.sql
clickhouse-client --host clickhouse --user flagsmith --password password --multiquery < /tmp/events.sql
depends_on:
clickhouse:
condition: service_healthy
# Flagsmith's events API: where SDKs send tracking and exposure events.
events:
image: flagsmith/events-ingestion-api:0.5.1
environment:
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
KAFKA_AUTH: none
KAFKA_TOPIC: flagsmith_warehouse_events
KAFKA_EXTERNAL_TOPIC: external_warehouse_events
DATABASE_URL: postgres://postgres:password@postgres:5432/flagsmith
ports:
- ${EVENTS_PORT:-8080}:8080
depends_on:
flagsmith:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
warehouse-delivery:
image: flagsmith/warehouse-delivery:0.4.0
environment:
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
KAFKA_AUTH: none
DATABASE_URL: postgresql://postgres:password@postgres:5432/flagsmith
WAREHOUSE_CREDENTIALS_SECRET: *warehouse-credentials-secret
# The spec asserts on events as soon as they are sent, so deliver them promptly.
BATCH_MAX_WAIT_MS: 1000
depends_on:
flagsmith:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
clickhouse-init:
condition: service_completed_successfully