Skip to main content

Container Building (OCI SDK)

RBS includes a built-in OCI SDK for building container images as part of your build process. No Docker daemon or Dockerfile is required — images are assembled programmatically using RBS DSL primitives.

Why RBS for Containers?

Quick Start

Using High-Level Rules

The simplest way to build container images:

OCI SDK Primitives

For advanced use cases, the OCI SDK provides low-level primitives accessible via ctx.oci within custom rules.

ctx.oci.create_layer()

Creates a single OCI layer from files.

Layer Parameters

ctx.oci.pull()

Pulls a base image from a registry.

ctx.oci.write_docker_tar()

Assembles layers into a Docker-compatible image tarball.

ctx.oci.image_builder()

A fluent builder API for creating images step by step.

Complete Examples

Java Spring Boot Container

Node.js Express Container

Python Django Container

Multi-Stage Build (Custom Rule)

For maximum control over the image layout:

Image Optimization Tips

Place rarely-changing content (OS packages, runtime dependencies) in early layers and frequently-changing content (application code) in later layers. This maximizes layer cache reuse.
Use slim or distroless base images to reduce image size and attack surface:
  • eclipse-temurin:17-jre-alpine instead of eclipse-temurin:17-jdk
  • node:20-slim instead of node:20
  • python:3.11-slim instead of python:3.11
Build images for multiple platforms by specifying the target platform:
Always run containers as a non-root user:

Output

Built images are saved as Docker-compatible tarballs:

Loading into Docker

Pushing to a Registry