Skip to content

Commit b9281f0

Browse files
masterashuCopilot
andcommitted
Add support for customizing port using env, and ability to run multiple instances of tilt for peerdb
Co-authored-by: Copilot <copilot@github.com>
1 parent 20b169f commit b9281f0

4 files changed

Lines changed: 67 additions & 26 deletions

File tree

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ MINIO_ROOT_USER=_peerdb_minioadmin
5050
MINIO_ROOT_PASSWORD=_peerdb_minioadmin
5151

5252
TZ='UTC'
53+
54+
## Port Overrides for parallel tilt and docker-compose runs.
55+
# PEERDB_CATALOG_PORT=19901
56+
# PEERDB_NEXUS_PORT=19900
57+
# PEERDB_SWITCHBOARD_PORT=15732
58+
# PEERBD_UI_PORT=13030
59+
# TEMPORAL_PORT=17233
60+
# TEMPORAL_UI_PORT=18085
61+
# FLOW_API_PORT=18112
62+
# FLOW_API_HTTP_PORT=18113
63+
# DOCKER_GO_DEBUG_PORT_FLOW_WORKER=14001
64+
# DOCKER_GO_DEBUG_PORT_FLOW_SNAPSHOT_WORKER=14002
65+
# DOCKER_GO_DEBUG_PORT_FLOW_API=14003
66+
# MINIO_PORT=19001
67+
# MINIO_CONSOLE_PORT=19002

Tiltfile

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,44 @@ update_settings(max_parallel_updates=10)
22

33
allow_k8s_contexts(k8s_context()) # to unblock local() in local set-ups with a Kubernetes context configured, like Docker Desktop
44

5-
docker_compose('./docker-compose-dev.yml')
6-
75
def resolve_env(var_name, default=None):
86
for line in str(read_file('.env')).splitlines():
97
if line.startswith(var_name + '='):
108
return line.strip().split('=', 1)[1]
119
return default
1210

11+
docker_compose('./docker-compose-dev.yml', project_name='peerdb-' + resolve_env('DEFAULT_TILT_PORT', '10350'), env_file='.env')
12+
13+
peerbd_ui_port = resolve_env('PEERBD_UI_PORT', '3030')
14+
temporal_port = resolve_env('TEMPORAL_PORT', '7233')
15+
temporal_ui_port = resolve_env('TEMPORAL_UI_PORT', '8085')
16+
flow_api_grpc_port = resolve_env('FLOW_API_PORT', '8112')
17+
flow_api_http_port = resolve_env('FLOW_API_HTTP_PORT', '8113')
18+
docker_go_debug_port_flow_worker = resolve_env('DOCKER_GO_DEBUG_PORT_FLOW_WORKER', '4001')
19+
docker_go_debug_port_flow_snapshot_worker = resolve_env('DOCKER_GO_DEBUG_PORT_FLOW_SNAPSHOT_WORKER', '4002')
20+
docker_go_debug_port_flow_api = resolve_env('DOCKER_GO_DEBUG_PORT_FLOW_API', '4003')
21+
1322
flow_ignore = ['flow/e2e/', 'flow/**/*_test.go']
1423

1524
docker_build('flow-api', '.',
1625
dockerfile='stacks/flow.Dockerfile',
17-
target='flow-api-debug' if resolve_env('DOCKER_GO_DEBUG_FLOW_API') == '1' else 'flow-api',
26+
target='flow-api-debug' if resolve_env('DOCKER_GO_DEBUG_FLOW_API') in ('1', 'true') else 'flow-api',
1827
only=['flow/', 'stacks/flow.Dockerfile'],
1928
ignore=flow_ignore,
2029
build_args={'DEBUG_BUILD': resolve_env('DOCKER_GO_DEBUG_FLOW_API',''),'PEERDB_VERSION_SHA_SHORT': os.getenv('PEERDB_VERSION_SHA_SHORT', 'unknown')},
2130
)
2231

2332
docker_build('flow-worker', '.',
2433
dockerfile='stacks/flow.Dockerfile',
25-
target='flow-worker-debug' if resolve_env('DOCKER_GO_DEBUG_FLOW_WORKER') == '1' else 'flow-worker',
34+
target='flow-worker-debug' if resolve_env('DOCKER_GO_DEBUG_FLOW_WORKER') in ('1', 'true') else 'flow-worker',
2635
only=['flow/', 'stacks/flow.Dockerfile'],
2736
build_args={'DEBUG_BUILD': resolve_env('DOCKER_GO_DEBUG_FLOW_WORKER','')},
2837
ignore=flow_ignore,
2938
)
3039

3140
docker_build('flow-snapshot-worker', '.',
3241
dockerfile='stacks/flow.Dockerfile',
33-
target='flow-snapshot-worker-debug' if resolve_env('DOCKER_GO_DEBUG_FLOW_SNAPSHOT_WORKER') == '1' else 'flow-snapshot-worker',
42+
target='flow-snapshot-worker-debug' if resolve_env('DOCKER_GO_DEBUG_FLOW_SNAPSHOT_WORKER') in ('1', 'true') else 'flow-snapshot-worker',
3443
only=['flow/', 'stacks/flow.Dockerfile'],
3544
build_args={'DEBUG_BUILD': resolve_env('DOCKER_GO_DEBUG_FLOW_SNAPSHOT_WORKER','')},
3645
ignore=flow_ignore,
@@ -59,14 +68,14 @@ local_resource(
5968
)
6069

6170
dc_resource('peerdb-ui', resource_deps=['proto-gen'], labels=['PeerDB'], links=[
62-
link('http://localhost:3030', 'PeerDB UI'),
71+
link('http://localhost:' + str(peerbd_ui_port), 'PeerDB UI'),
6372
])
6473
dc_resource('flow-api', resource_deps=['proto-gen'], labels=['PeerDB'], links=[
65-
link('http://localhost:8112', 'Flow API gRPC'),
66-
link('http://localhost:8113', 'Flow API HTTP'),
74+
link('http://localhost:' + str(flow_api_grpc_port), 'Flow API gRPC'),
75+
link('http://localhost:' + str(flow_api_http_port), 'Flow API HTTP'),
6776
])
6877
dc_resource('temporal-ui', labels=['PeerDB'], links=[
69-
link('http://localhost:8085', 'Temporal UI'),
78+
link('http://localhost:' + str(temporal_ui_port), 'Temporal UI'),
7079
])
7180
dc_resource('catalog', labels=['PeerDB'])
7281
dc_resource('temporal', labels=['PeerDB'])

ancillary-docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,5 @@ volumes:
193193

194194
networks:
195195
default:
196-
name: peerdb_network
196+
name: peerdb_network_${DEFAULT_TILT_PORT:-default}
197197
external: true

docker-compose-dev.yml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
name: peerdb-quickstart-dev
22

3+
# Public facing ports for services to prevent conflicts.
4+
# Overridable using environment variables for flexibility when using multiple tilt environments
5+
x-ports:
6+
- &peerdb-catalog-port ${PEERDB_CATALOG_PORT:-9901}:5432
7+
- &peerdb-nexus-port ${PEERDB_NEXUS_PORT:-9900}:9900
8+
- &peerdb-switchboard-port ${PEERDB_SWITCHBOARD_PORT:-5732}:5732
9+
- &peerdb-ui-port ${PEERBD_UI_PORT:-3030}:3000
10+
- &temporal-port ${TEMPORAL_PORT:-7233}:7233
11+
- &temporal-ui-port ${TEMPORAL_UI_PORT:-8085}:8080
12+
- &flow-api-grpc-port ${FLOW_API_PORT:-8112}:8112
13+
- &flow-api-http-port ${FLOW_API_HTTP_PORT:-8113}:8113
14+
- &flow-worker-debug-port ${DOCKER_GO_DEBUG_PORT_FLOW_WORKER:-4001}:40000
15+
- &flow-snapshot-worker-debug-port ${DOCKER_GO_DEBUG_PORT_FLOW_SNAPSHOT_WORKER:-4002}:40000
16+
- &flow-api-debug-port ${DOCKER_GO_DEBUG_PORT_FLOW_API:-4003}:40000
17+
- &minio-port ${MINIO_PORT:-9001}:9000
18+
- &minio-console-port ${MINIO_CONSOLE_PORT:-9002}:36987
19+
320
x-minio-config: &minio-config
421
PEERDB_CLICKHOUSE_AWS_CREDENTIALS_AWS_ACCESS_KEY_ID: _peerdb_minioadmin
522
MINIO_ROOT_USER: _peerdb_minioadmin
623
PEERDB_CLICKHOUSE_AWS_CREDENTIALS_AWS_SECRET_ACCESS_KEY: _peerdb_minioadmin
724
MINIO_ROOT_PASSWORD: _peerdb_minioadmin
825
PEERDB_CLICKHOUSE_AWS_CREDENTIALS_AWS_REGION: us-east-1
9-
PEERDB_CLICKHOUSE_AWS_CREDENTIALS_AWS_ENDPOINT_URL_S3: http://host.docker.internal:9001
26+
PEERDB_CLICKHOUSE_AWS_CREDENTIALS_AWS_ENDPOINT_URL_S3: http://host.docker.internal:${MINIO_PORT:-9001}
1027
PEERDB_CLICKHOUSE_AWS_S3_BUCKET_NAME: peerdb
1128

1229
x-catalog-config: &catalog-config
@@ -44,7 +61,7 @@ services:
4461
image: postgres:18-alpine@sha256:54451ecb8ab38c24c3ec123f2fd501303a3a1856a5c66e98cecf2460d5e1e9d7
4562
command: -c config_file=/etc/postgresql.conf
4663
ports:
47-
- 9901:5432
64+
- *peerdb-catalog-port
4865
environment:
4966
PGUSER: postgres
5067
POSTGRES_PASSWORD: postgres
@@ -53,7 +70,7 @@ services:
5370
extra_hosts:
5471
- "host.docker.internal:host-gateway"
5572
volumes:
56-
- pgdata:/var/lib/postgresql/data
73+
- pgdata:/var/lib/postgresql
5774
- ./volumes/postgresql.conf:/etc/postgresql.conf
5875
- ./volumes/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
5976
healthcheck:
@@ -77,7 +94,7 @@ services:
7794
- DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development-sql.yaml
7895
image: temporalio/auto-setup:1.29@sha256:d33d1402e8b895329e27a0d0e7cc2f034e0aa70f0dab6aa95b306d7ae2716f67
7996
ports:
80-
- 7233:7233
97+
- *temporal-port
8198
volumes:
8299
- ./volumes/temporal-dynamicconfig:/etc/temporal/config/dynamicconfig
83100
labels:
@@ -114,7 +131,7 @@ services:
114131
- TEMPORAL_CSRF_COOKIE_INSECURE=true
115132
image: temporalio/ui:2.49.1@sha256:a066bdf5c4de689cabaf80cc357871f1db5e6d750a6bcfc42e877b913e31ef24
116133
ports:
117-
- 8085:8080
134+
- *temporal-ui-port
118135

119136
flow-api:
120137
container_name: flow_api
@@ -126,10 +143,10 @@ services:
126143
args:
127144
PEERDB_VERSION_SHA_SHORT: ${PEERDB_VERSION_SHA_SHORT:-}
128145
ports:
129-
- 8112:8112
130-
- 8113:8113
131-
- 5732:5732
132-
- 4003:40000
146+
- *flow-api-grpc-port
147+
- *flow-api-http-port
148+
- *peerdb-switchboard-port
149+
- *flow-api-debug-port
133150
environment:
134151
<<: [*catalog-config, *flow-worker-env, *minio-config]
135152
PEERDB_ALLOWED_TARGETS:
@@ -150,7 +167,7 @@ services:
150167
dockerfile: stacks/flow.Dockerfile
151168
target: flow-snapshot-worker
152169
ports:
153-
- 4002:40000
170+
- *flow-snapshot-worker-debug-port
154171
environment:
155172
<<: [*catalog-config, *flow-worker-env, *minio-config]
156173
depends_on:
@@ -165,7 +182,7 @@ services:
165182
dockerfile: stacks/flow.Dockerfile
166183
target: flow-worker
167184
ports:
168-
- 4001:40000
185+
- *flow-worker-debug-port
169186
# The below options were mentioned to be required, but it works without them, so leaving them commented out for now. If you run into issues with Delve, try uncommenting these.
170187
# security_opt:
171188
# - "seccomp:unconfined" # Required for Delve
@@ -196,7 +213,7 @@ services:
196213
RUST_LOG: info
197214
RUST_BACKTRACE: 1
198215
ports:
199-
- 9900:9900
216+
- *peerdb-nexus-port
200217
depends_on:
201218
catalog:
202219
condition: service_healthy
@@ -209,7 +226,7 @@ services:
209226
dockerfile: stacks/peerdb-ui.Dockerfile
210227
target: dev
211228
ports:
212-
- 3030:3000
229+
- *peerdb-ui-port
213230
volumes:
214231
# Mount local ui/ directory for hot reload
215232
- ./ui:/app
@@ -239,8 +256,8 @@ services:
239256
volumes:
240257
- minio-data:/data
241258
ports:
242-
- "9001:9000"
243-
- "9002:36987"
259+
- *minio-port
260+
- *minio-console-port
244261
environment:
245262
<<: *minio-config
246263
entrypoint: >
@@ -258,4 +275,4 @@ volumes:
258275

259276
networks:
260277
default:
261-
name: peerdb_network
278+
name: peerdb_network_${DEFAULT_TILT_PORT:-default}

0 commit comments

Comments
 (0)