Skip to main content

Build Tasks

Overview

Build tasks compile the unified infra.operator Go binary which contains both host-side (VM control) and guest-side (code execution) functionality.

build:all

Build all components in sequence.

Build all components
task build:all
Task definition
build:all:
desc: Build all components
cmds:
- task: build:infra-operator
- task: build:infra-operator-linux

Output:

Expected output
Built bin/infra.operator
Built bin/infra.operator-linux (amd64)

build:infra-operator

Build the unified CLI binary for the current operating system.

Build infra.operator for current OS
task build:infra-operator
Task definition
build:infra-operator:
desc: Build infra.operator for current OS
cmds:
- mkdir -p {{.BIN_DIR}}
- go build -ldflags="-s -w" -o {{.BIN_DIR}}/infra.operator ./cmd/infra.operator/...
- echo "Built {{.BIN_DIR}}/infra.operator"

What it does:

  1. Creates bin/ directory if it doesn't exist
  2. Compiles unified CLI with stripped debug info (-ldflags="-s -w")
  3. Outputs binary to bin/infra.operator

Output:

Expected output
Built bin/infra.operator
note

The binary is built for your current OS. For AWS deployment, use task build:infra-operator-linux which cross-compiles for Linux.


build:infra-operator-linux

Build the unified CLI binary for Linux, auto-detecting architecture.

Build infra.operator for Linux
task build:infra-operator-linux
Task definition
build:infra-operator-linux:
desc: Build infra.operator for Linux (auto-detect arch)
vars:
GOARCH:
sh: |
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then echo "amd64"
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then echo "arm64"
else echo "amd64"; fi
cmds:
- mkdir -p {{.BIN_DIR}}
- GOOS=linux GOARCH={{.GOARCH}} go build -ldflags="-s -w" -o {{.BIN_DIR}}/infra.operator-linux ./cmd/infra.operator/...
- echo "Built {{.BIN_DIR}}/infra.operator-linux ({{.GOARCH}})"

What it does:

  1. Detects current machine architecture (x86_64 → amd64, arm64 → arm64)
  2. Cross-compiles for Linux with detected architecture
  3. Outputs binary to bin/infra.operator-linux

Output:

Expected output
Built bin/infra.operator-linux (amd64)

build:infra-operator-amd64

Explicitly build for Linux x86_64.

Build for Linux/amd64
task build:infra-operator-amd64
Task definition
build:infra-operator-amd64:
desc: Build infra.operator for Linux/amd64
cmds:
- mkdir -p {{.BIN_DIR}}
- GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o {{.BIN_DIR}}/infra.operator-amd64 ./cmd/infra.operator/...
- echo "Built {{.BIN_DIR}}/infra.operator-amd64"

Use case: When building on ARM Mac for x86_64 EC2 instances.

Output:

Expected output
Built bin/infra.operator-amd64

build:infra-operator-arm64

Build for Linux ARM64.

Build for Linux/arm64
task build:infra-operator-arm64
Task definition
build:infra-operator-arm64:
desc: Build infra.operator for Linux/arm64
cmds:
- mkdir -p {{.BIN_DIR}}
- GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o {{.BIN_DIR}}/infra.operator-arm64 ./cmd/infra.operator/...
- echo "Built {{.BIN_DIR}}/infra.operator-arm64"

Use case: When building for ARM64 EC2 instances (Graviton).

Output:

Expected output
Built bin/infra.operator-arm64

Development Tasks

dev:tidy

Tidy Go module dependencies.

Tidy Go modules
task dev:tidy
Task definition
dev:tidy:
desc: Tidy Go modules
cmds:
- go mod tidy

dev:fmt

Format all Go code using go fmt.

Format Go code
task dev:fmt
Task definition
dev:fmt:
desc: Format Go code
cmds:
- go fmt ./...

dev:lint

Run go vet on all code.

Lint Go code
task dev:lint
Task definition
dev:lint:
desc: Lint Go code
cmds:
- go vet ./...

Clean Tasks

clean

Remove built binaries.

Clean built binaries
task clean
Task definition
clean:
desc: Clean built binaries
cmds:
- rm -rf {{.BIN_DIR}}
- echo "Cleaned"

Output:

Expected output
Cleaned

clean:all

Remove binaries and Go build cache.

Clean everything including Go cache
task clean:all
Task definition
clean:all:
desc: Clean everything including Go cache
cmds:
- task: clean
- go clean -cache
- echo "All cleaned"
warning

This clears the Go build cache, which will slow down subsequent builds.


Build Artifacts

After running task build:all, you'll have:

Build artifacts directory structure
runner-codes/
├── bin/
│ ├── infra.operator # Unified CLI for current OS
│ └── infra.operator-linux # Cross-compiled for Linux
├── cmd/
│ └── infra.operator/ # CLI entry point
├── pkg/
│ ├── host/ # Host-side VM control
│ └── guest/ # Guest-side code execution
└── internal/ # Internal packages

Binary Size

BinaryApproximate Size
infra.operator~10 MB
tip

The -ldflags="-s -w" flags strip debug info, reducing binary size by ~30%.


Cross-Compilation

The unified binary can be cross-compiled for different architectures:

Build for Linux x86_64
task build:infra-operator-amd64
Build for Linux ARM64
task build:infra-operator-arm64
Build for Linux with auto-detected architecture
task build:infra-operator-linux
note

The task aws:deploy command automatically cross-compiles for Linux/amd64, regardless of your host machine.


Unified CLI Subcommands

The single infra.operator binary contains all functionality:

SubcommandDescription
hostControls Firecracker VMs and executes code (host-side)
guestRuns inside microVM, listens on vsock:5000 (guest-side)
rootfsManages rootfs images (create, list, upload, download)
snapshotManages snapshots (create, list, upload, download)
apiStarts HTTP API server
runExecutes code in a microVM
benchmarkRuns performance benchmarks