Build images. Reuse the parts.#
Coopr builds OCI container images from ordered .coopr definitions.
Reuse common build steps and files as components from your repository or an OCI registry.
Install Coopr#
See installation for requirements, release binaries, the Coopr container, and Nix.
Start with an image
Write a definition with familiar from, run, and copy steps. Build and tag the image locally.
Share a component
Share build steps and packaged files between images. Start with a local component, then package it for an OCI registry.
Define once, reuse#
Create a greeting during packaging, then copy it into each image that uses the component. Save this as components/greeting.coopr:
// Build this stage when packaging the component.
from "docker.io/redhat/ubi9:latest" as="builder" {
run "echo 'Hello, world!' > /hello.txt"
}
// Keep the greeting in the packaged component.
package as="greeting" {
copy "/hello.txt" "/hello.txt" from="builder"
}
// Start from the calling image when the component is used.
// Copy the saved greeting without rerunning the builder.
extend {
copy "/hello.txt" "/hello.txt" from="greeting"
}package captures the generated file. extend starts from the calling image and applies the instructions inside its block. Use the component in image.coopr:
from "docker.io/redhat/ubi9:latest" {
// Package and apply the local component.
component "./components/greeting.coopr"
// Print the greeting when the container starts.
cmd {
exec "cat" "/hello.txt"
}
}Build and run the image with Coopr and Podman:
No separate component build or upload is needed. Follow the local-component tutorial, or package a component for registry reuse.
Build the way your project needs#
- Local and OCI components. Use a file while developing, then package its transformations and files together for other repositories. Reuse components.
- Ordered, familiar instructions. Use
from,run,copy, named stages, and parameterized arguments. Definition syntax. - Instruction and package caches. Reuse unchanged build steps, cache dependency downloads, and share caches locally or through a registry. Caching.
- Control your layers. Keep ordinary instruction layers or group several steps into one net filesystem change with
layer { ... }. Layer groups. - Rootless builds and native storage. Build on Linux without a builder daemon. Images are available to Podman when both tools use the same user and storage settings. Storage ยท Host requirements.