This document walks through practical .abs examples and points to ready-to-run files under samples/.
File: samples/quickstart.abs
template hello_service() {
stage runtime {
from "alpine:3.20"
run "echo hello from abstack"
cmd ["/bin/sh", "-c", "echo hello"]
}
}
service hello {
use hello_service()
port "8080:8080"
}
File: samples/unified.abs
Highlights:
- Reusable Go template with parameter interpolation.
- Runtime overlays in service blocks.
depends_onbetween services.
File: samples/multi_use.abs
template diagnostics() {
stage diag {
from "alpine:3.20"
run "echo diagnostics enabled"
}
}
template app(name, service_port) {
stage build {
from "golang:1.22"
run "go build -o app ./cmd/${name}"
}
stage runtime {
from "alpine:3.20"
copy from build "/src/app" "/app"
expose service_port
cmd ["/app"]
}
}
service api {
use diagnostics()
use app("api", 8080)
entrypoint ["/app"]
cmd ["/app", "--serve"]
port "8080:8080"
}
Note: overlay statements apply to the final lowered stage, so app is placed last.
File: samples/microservices.abs
Includes:
- API service.
- Worker service.
- PostgreSQL service.
- Shared template reuse for build/runtime consistency.
File: samples/stdlib_stack.abs
Highlights:
- Uses bundled stdlib templates only (no local template declarations).
- API + postgres + redis stack.
- Works with explicit stdlib profile linkage (
--stdlib-profile default).
./build/native/abstack samples/microservices.abs --out-dir generated
./build/native/abstack build samples/stdlib_stack.abs --stdlib-profile default --out-dir generatedYou can then inspect:
generated/Dockerfile.apigenerated/Dockerfile.workergenerated/Dockerfile.dbgenerated/docker-compose.generated.yml
sed -n '1,200p' generated/Dockerfile.api
sed -n '1,200p' generated/docker-compose.generated.yml- Start with
quickstart.absfor syntax basics. - Move to
unified.absfor template/service layering. - Use
multi_use.absfor composition behavior. - Use
microservices.absas a realistic baseline for project layouts. - Use
stdlib_stack.abswhen you want compiler-bundled templates.