Skip to content

Your First Package

Build a minimal Brane package, test it locally, and run it on an instance.

Terminal window
mkdir hello-world && cd hello-world

Create hello_world.sh:

#!/bin/bash
echo 'output: "Hello from Brane!"'

Brane reads output from stdout as YAML key-value pairs.

Create container.yml:

name: hello_world
version: 1.0.0
kind: ecu
files:
- hello_world.sh
entrypoint:
kind: task
exec: hello_world.sh
actions:
'hello_world':
command:
input:
output:
- name: output
type: string
Terminal window
brane package build ./container.yml
brane package list
brane package test hello_world
Terminal window
brane login http://<CENTRAL_NODE_ADDRESS> --username <YOUR_NAME>
brane package push hello_world
brane workflow repl --remote http://<CENTRAL_NODE_ADDRESS>:50053

In the REPL:

import hello_world;
println(hello_world());

Create analyze.py:

#!/usr/bin/env python3
import 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_hello
version: 1.0.0
kind: ecu
dependencies:
- python3
- python3-yaml
files:
- analyze.py
entrypoint:
kind: task
exec: analyze.py
actions:
'hello':
command:
input:
output:
- name: output
type: string

The dependencies field installs system packages via apt in the container.

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.

TypeBraneScriptDescription
string"text"Text values
integer42Whole numbers
real3.14Floating-point numbers
booleantrue / falseBoolean values
Array[T][1, 2, 3]Arrays of a single type