| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  | config.define_bool("use-zig") | 
					
						
							|  |  |  | cfg = config.parse() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use_zig = cfg.get('docker-builder', False) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  | # --- Frontend processes | 
					
						
							|  |  |  | local_resource( | 
					
						
							|  |  |  |   'yarn install', | 
					
						
							|  |  |  |   cmd='yarn install', | 
					
						
							|  |  |  |   deps=[ | 
					
						
							|  |  |  |     'yarn.lock', | 
					
						
							|  |  |  |   ], | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |   labels=["local"] | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | local_resource( | 
					
						
							|  |  |  |   'yarn start', | 
					
						
							|  |  |  |   cmd='rm -rf public/build/assets-manifest.json', | 
					
						
							|  |  |  |   serve_cmd='yarn start:noLint', | 
					
						
							|  |  |  |   resource_deps=['yarn install'], | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # Note: this doesn't seem to work as expected - the assets-manifest is somehow created before | 
					
						
							|  |  |  |   # the webpack build is complete? | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |   readiness_probe=probe( | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |     initial_delay_secs=10, | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |     period_secs=1, | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |     exec=exec_action(["bash", "-c", "stat public/build/assets-manifest.json"]), | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |   ), | 
					
						
							|  |  |  |   allow_parallel=True, | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |   labels=["local"] | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | build_backend_env = {} | 
					
						
							|  |  |  | if use_zig: | 
					
						
							|  |  |  |   build_backend_env['USE_ZIG'] = "true" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | local_resource( | 
					
						
							|  |  |  |   'backend-build', | 
					
						
							|  |  |  |   "bash ./build-grafana.sh", | 
					
						
							|  |  |  |   deps=[ | 
					
						
							|  |  |  |     '../../pkg', | 
					
						
							|  |  |  |     '../../apps', | 
					
						
							|  |  |  |     '../../kinds', | 
					
						
							|  |  |  |     '../../kindsv2', | 
					
						
							|  |  |  |     '../../local', | 
					
						
							|  |  |  |     '../../scripts', | 
					
						
							|  |  |  |     '../../conf', | 
					
						
							|  |  |  |     '../../go.sum', | 
					
						
							|  |  |  |     '../../go.mod', | 
					
						
							|  |  |  |   ], | 
					
						
							|  |  |  |   env=build_backend_env, | 
					
						
							|  |  |  |   allow_parallel=True, | 
					
						
							|  |  |  |   labels=["local"] | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # --- Docker Compose | 
					
						
							|  |  |  | docker_compose("./docker-compose.yaml") | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  | dc_resource("proxy", | 
					
						
							| 
									
										
										
										
											2025-08-06 16:40:48 +08:00
										 |  |  |   resource_deps=["grafana-api", "frontend-service"], | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |   labels=["services"] | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2025-08-06 16:40:48 +08:00
										 |  |  | dc_resource("grafana-api", | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |   resource_deps=["yarn start", "backend-build"], | 
					
						
							|  |  |  |   labels=["services"] | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | dc_resource("frontend-service", | 
					
						
							|  |  |  |   resource_deps=["yarn start", "backend-build"], | 
					
						
							|  |  |  |   labels=["services"], | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2025-08-06 16:40:48 +08:00
										 |  |  | dc_resource("alloy", labels=["observability"]) | 
					
						
							| 
									
										
										
										
											2025-08-28 19:02:09 +08:00
										 |  |  | dc_resource("prometheus", labels=["observability"]) | 
					
						
							| 
									
										
										
										
											2025-08-06 16:40:48 +08:00
										 |  |  | dc_resource("loki", labels=["observability"]) | 
					
						
							| 
									
										
										
										
											2025-08-15 18:59:43 +08:00
										 |  |  | dc_resource("tempo", labels=["observability"]) | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-28 19:02:09 +08:00
										 |  |  | dc_resource("postgres", labels=["misc"]) | 
					
						
							|  |  |  | dc_resource("tempo-init", labels=["misc"]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  | # paths in tilt files are confusing.... | 
					
						
							|  |  |  | # - if tilt is dealing the the path, it is relative to the Tiltfile | 
					
						
							|  |  |  | # - if docker is dealing with the path, it is relative to the context | 
					
						
							|  |  |  | docker_build('grafana-fs-dev', | 
					
						
							|  |  |  |   # Set the docker context to the root of the repo | 
					
						
							|  |  |  |   context='../..', | 
					
						
							|  |  |  |   dockerfile='grafana-fs-dev.dockerfile', | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |   # Paths relative to the docker context (root of the repo) | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |   only=[ | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |     'devenv/frontend-service/build/grafana', | 
					
						
							| 
									
										
										
										
											2025-08-05 16:56:30 +08:00
										 |  |  |     'devenv/frontend-service/provisioning', | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |     'conf/defaults.ini', | 
					
						
							|  |  |  |     'public/emails', | 
					
						
							|  |  |  |     'public/views', | 
					
						
							|  |  |  |     'public/dashboards', | 
					
						
							|  |  |  |     'public/app/plugins', | 
					
						
							|  |  |  |     'public/build/assets-manifest.json', | 
					
						
							| 
									
										
										
										
											2025-08-29 23:29:57 +08:00
										 |  |  |     'public/gazetteer', | 
					
						
							|  |  |  |     'public/maps', | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |   ], | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # Sync paths are relative to the Tiltfile | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |   live_update = [ | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  |     sync('./build/grafana', '/grafana/bin/grafana'), | 
					
						
							|  |  |  |     sync('../../conf/defaults.ini', '/grafana/conf/defaults.ini'), | 
					
						
							|  |  |  |     sync('../../public/emails', '/grafana/public/emails'), | 
					
						
							|  |  |  |     sync('../../public/views', '/grafana/public/views'), | 
					
						
							|  |  |  |     sync('../../public/dashboards', '/grafana/public/dashboards'), | 
					
						
							|  |  |  |     sync('../../public/app/plugins', '/grafana/public/app/plugins'), | 
					
						
							| 
									
										
										
										
											2025-07-17 19:49:16 +08:00
										 |  |  |     sync('../../public/build/assets-manifest.json', '/grafana/public/build/assets-manifest.json'), | 
					
						
							| 
									
										
										
										
											2025-08-05 16:56:30 +08:00
										 |  |  |     sync('./provisioning', '/ignore/provisioning'),  # Just to trigger a restart instead of rebuild | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |     restart_container() | 
					
						
							|  |  |  |   ] | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  | docker_build('grafana-proxy', | 
					
						
							|  |  |  |   # Set the docker context to this frontend-service folder | 
					
						
							|  |  |  |   context='.', | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |   dockerfile='proxy.dockerfile', | 
					
						
							| 
									
										
										
										
											2025-08-01 00:22:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # Path relative to the docker context (this folder) | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |   only=[ | 
					
						
							| 
									
										
										
										
											2025-08-15 18:59:43 +08:00
										 |  |  |     "./configs/nginx.conf", | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |   ], | 
					
						
							|  |  |  |   live_update = [ | 
					
						
							| 
									
										
										
										
											2025-08-15 18:59:43 +08:00
										 |  |  |     sync('./configs/nginx.conf', '/etc/nginx/conf.d/default.conf'), | 
					
						
							| 
									
										
										
										
											2025-07-17 01:28:28 +08:00
										 |  |  |     restart_container() | 
					
						
							|  |  |  |   ] | 
					
						
							|  |  |  | ) |