Skip to main content
Glama
Tiltfile10.5 kB
# Set args to "True" if we want to allow positional arguments config.define_string_list("to-run", args = True) config.define_bool("standard-rustc-build-mode") config.define_bool("debug-rustc-build-mode") config.define_bool("debug-no-rebaser-rustc-build-mode") cfg = config.parse() # Define groups of services groups = { "platform": [ "nats", "otelcol", "postgres", "spicedb", "versitygw", ], "backend": [ "auth-api", "edda", "forklift", "module-index", "pinga", "rebaser", "rust-initial-build", "sdf", "veritech", ], "frontend": [ "auth-portal", "docs", "luminork", "web", ], "testing": [ "bedrock", "db-test", "localstack", "postgres-test", ], "telemetry": [ "grafana", "jaeger", "loki", "node_exporter", "prometheus", "promtail", ], } # Parse the CLI args to enable group names and/or individual service names enabled_resources = [] for arg in cfg.get("to-run", []): if arg == "all": enabled_resources += [service for services in groups.values() for service in services] elif arg in groups: enabled_resources += groups[arg] else: enabled_resources.append(arg) config.set_enabled_resources(enabled_resources) RUST_RESOURCE_ARGS = { "serve_env": { "SI_FORCE_COLOR": "true", "SI_LOG_FILE_DIRECTORY": "../log", }, "trigger_mode": TRIGGER_MODE_MANUAL, } # Get build mode for Buck2 commands # # TODO(nick): The Tiltfile logic for writing arguments out does not know how to group string # ("config.define_string") arguments with the argument call (i.e. it thinks "--foo bar" is one # argument rather than having argument "--foo" be passed value "bar"). Thus, we use two booleans to # get around this. If we get both, greedily choose the standard mode. def buck2_mode_and_targets(targets): targets_str = " ".join(targets) if cfg.get("standard-rustc-build-mode", False): return targets_str if cfg.get("debug-rustc-build-mode", False): return "@//mode/debug {}".format(targets_str) if cfg.get("debug-no-rebaser-rustc-build-mode", False) and "//bin/rebaser:rebaser" not in targets: return "@//mode/debug {}".format(targets_str) return "@//mode/release {}".format(targets_str) def buck2_build_deps(build_targets): return [ dep for build_target in build_targets for dep in str( local( "buck2 uquery \"inputs(deps('{}'))\"".format(build_target), quiet = True, ), ).splitlines() ] def resource_labels(name): return [group for group in groups if group != "all" and name in groups[group]] def si_buck2_resource( target, *, name = None, allow_parallel = True, buck2_serve_args = None, **kwargs): # Figure name from build command: //app/web:dev -> web if name == None: name = target.split("/")[-1].split(":")[0] # Get Buck2 build command mode_and_targets = buck2_mode_and_targets([target]) cmd = "buck2 build {}".format(mode_and_targets) # Get Buck2 run command serve_cmd = "buck2 run {}".format(mode_and_targets) if buck2_serve_args != None: serve_cmd += " -- {}".format(buck2_serve_args) # Compute Buck2 source inputs to populate Tilt local_resource/deps deps = buck2_build_deps([target]) # Lookup group and add to labels group_names = resource_labels(name) print("local_resource(") print(" name = \"{}\"".format(name)) print(" cmd = \"{}\"".format(cmd)) print(" serve_cmd = \"{}\"".format(serve_cmd)) print(")") print("") local_resource( name, allow_parallel = allow_parallel, labels = group_names, cmd = cmd, serve_cmd = serve_cmd, deps = deps, **kwargs ) # From the Tilt docs: # # > By default, Tilt will not let you develop against a remote cluster. # # The implication appears to be that if Tilt finds a configured Kubernetes setup on your system # **and** it's a remote cluster, despite the fact that we are not using any Kubernetes features or # capabilities, it will still try to connect and fail. Instead, we're going to disable this check # and continue. # # - https://docs.tilt.dev/choosing_clusters.html#remote # - https://docs.tilt.dev/api.html#api.allow_k8s_contexts allow_k8s_contexts(k8s_context()) # Use Docker Compose to provide the platform services docker_compose("./docker-compose.platform.yml") compose_services = { "db-test": {}, "grafana": { "links": [ link("http://localhost:3000", "grafana-ui"), ], }, "jaeger": { "links": [ link("http://localhost:16686", "jaeger-ui"), ], }, "localstack": { "links": [ link("http://localhost:4566", "localstack-api"), ], }, "loki": {}, "nats": {}, "node_exporter": {}, "otelcol": {}, "postgres": {}, "postgres-test": {}, "prometheus": {}, "promtail": {}, "spicedb": {}, "versitygw": {}, } for service, kwargs in compose_services.items(): dc_resource(service, labels = resource_labels(service), **kwargs) # Locally build and run `rebaser` si_buck2_resource( "//bin/rebaser:rebaser", resource_deps = [ "rust-initial-build", "nats", "otelcol", "postgres", ], **RUST_RESOURCE_ARGS ) # Locally build and run `edda` si_buck2_resource( "//bin/edda:edda", resource_deps = [ "rust-initial-build", "nats", "otelcol", ], **RUST_RESOURCE_ARGS ) # Locally build and run `forklift` si_buck2_resource( "//bin/forklift:forklift", resource_deps = [ "rust-initial-build", "nats", "otelcol", ], **RUST_RESOURCE_ARGS ) # Locally build and run `pinga` si_buck2_resource( "//bin/pinga:pinga", resource_deps = [ "rust-initial-build", "nats", "otelcol", "veritech", ], **RUST_RESOURCE_ARGS ) # Locally build and run `veritech` si_buck2_resource( "//bin/veritech:veritech", # buck2_serve_args = "--cyclone-local-firecracker --cyclone-pool-size 10", # This ^ is the serve command you might need if you want to execute on firecracker for 10 # function executions. # # NB: BUCK2 MUST RUN AS ROOT OR THIS WILL NOT WORK resource_deps = [ "rust-initial-build", "nats", "otelcol", ], **RUST_RESOURCE_ARGS ) # Locally build and run `sdf` si_buck2_resource( "//bin/sdf:sdf", resource_deps = [ "rust-initial-build", "spicedb", "nats", "otelcol", "pinga", "postgres", "veritech", "rebaser", "edda", "forklift", ], readiness_probe = probe( period_secs = 5, http_get = http_get_action( port = 5156, path = "/api/", ), ), links = [ link("http://127.0.0.1:5156", "api"), ], **RUST_RESOURCE_ARGS ) # Locally build and run `luminork` si_buck2_resource( "//bin/luminork:luminork", resource_deps = [ "rust-initial-build", "spicedb", "nats", "otelcol", "pinga", "postgres", "veritech", "rebaser", "edda", "forklift", ], readiness_probe = probe( period_secs = 5, http_get = http_get_action( port = 5380, path = "/", ), ), links = [ link("http://127.0.0.1:5380/swagger-ui", "swagger-ui"), ], **RUST_RESOURCE_ARGS ) # Locally build and run `web` in dev mode si_buck2_resource( "//app/web:dev", resource_deps = [ "sdf", ], readiness_probe = probe( period_secs = 5, http_get = http_get_action( port = 8080, ), ), links = [ link("http://127.0.0.1:8080", "web"), link("https://auth.systeminit.com/workspaces", "workspaces"), link("https://auth.systeminit.com", "auth-prod"), ], ) si_buck2_resource( "//app/docs:dev", auto_init = False, resource_deps = [], readiness_probe = probe( period_secs = 5, http_get = http_get_action( port = 5173, ), ), ) # Locally build and run `bedrock` si_buck2_resource( "//bin/bedrock:bedrock", resource_deps = [ "nats", ], readiness_probe = probe( period_secs = 5, http_get = http_get_action( port = 3020, path = "/", ), ), **RUST_RESOURCE_ARGS ) # Locally build and run `module-index` si_buck2_resource( "//bin/module-index:module-index", auto_init = False, resource_deps = [ "otelcol", "postgres", ], readiness_probe = probe( period_secs = 5, http_get = http_get_action( port = 5157, path = "/", ), ), **RUST_RESOURCE_ARGS ) # Locally build and run `auth-api` si_buck2_resource( "//bin/auth-api:dev", auto_init = False, resource_deps = [ "postgres", ], # readiness_probe = probe( # period_secs = 5, # http_get = http_get_action( # port = 9001, # path = "/", # ), # ), trigger_mode = TRIGGER_MODE_MANUAL, ) # Locally build and run `auth-portal` in dev mode si_buck2_resource( "//app/auth-portal:dev", auto_init = False, resource_deps = [ "auth-api", ], readiness_probe = probe( period_secs = 5, http_get = http_get_action( port = 9000, ), ), links = [ link("http://127.0.0.1:9000", "auth"), ], ) rust_build_targets = [ "//bin/edda:edda", "//bin/forklift:forklift", "//bin/pinga:pinga", "//bin/rebaser:rebaser", "//bin/sdf:sdf", "//bin/veritech:veritech", "//bin/luminork:luminork", ] local_resource( "rust-initial-build", allow_parallel = True, labels = resource_labels("rust-initial-build"), cmd = "buck2 build {}".format(buck2_mode_and_targets(rust_build_targets)), deps = buck2_build_deps(rust_build_targets), **RUST_RESOURCE_ARGS )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server