Your First Package
Your First Package
Section titled “Your First Package”Build a minimal Brane package, test it locally, and run it on an instance.
1. Write the Code
Section titled “1. Write the Code”mkdir hello-world && cd hello-worldCreate hello_world.sh:
#!/bin/bashecho 'output: "Hello from Brane!"'Brane reads output from stdout as YAML key-value pairs.
2. Define the Package Interface
Section titled “2. Define the Package Interface”Create container.yml:
name: hello_worldversion: 1.0.0kind: ecu
files: - hello_world.sh
entrypoint: kind: task exec: hello_world.sh
actions: 'hello_world': command: input: output: - name: output type: string3. Build and Test
Section titled “3. Build and Test”brane package build ./container.ymlbrane package listbrane package test hello_world4. Push and Run
Section titled “4. Push and Run”brane login http://<CENTRAL_NODE_ADDRESS> --username <YOUR_NAME>brane package push hello_worldbrane workflow repl --remote http://<CENTRAL_NODE_ADDRESS>:50053In the REPL:
import hello_world;println(hello_world());Python Example
Section titled “Python Example”Create analyze.py:
#!/usr/bin/env python3import yaml
def main(): result = {"output": "Hello from Python!"} print(yaml.dump(result, default_flow_style=True).strip())
if __name__ == "__main__": main()And container.yml:
name: python_helloversion: 1.0.0kind: ecu
dependencies: - python3 - python3-yaml
files: - analyze.py
entrypoint: kind: task exec: analyze.py
actions: 'hello': command: input: output: - name: output type: stringThe dependencies field installs system packages via apt in the container.
How Inputs Work
Section titled “How Inputs Work”When Brane calls a function, it passes inputs via environment variables (variable name = parameter name) and the function name as sys.argv[1].
Output must be printed to stdout as YAML with keys matching the declared output names.
Supported Input Types
Section titled “Supported Input Types”| Type | BraneScript | Description |
|---|---|---|
string | "text" | Text values |
integer | 42 | Whole numbers |
real | 3.14 | Floating-point numbers |
boolean | true / false | Boolean values |
Array[T] | [1, 2, 3] | Arrays of a single type |
Next Steps
Section titled “Next Steps”- Write workflows with BraneScript
- See the CLI reference for all package commands