From 4e224c74c51dac2804b7d99f76185ee54d4f9487 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Sat, 30 Sep 2023 21:33:25 -0400 Subject: [PATCH] update README Signed-off-by: Jason Hall --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0165c70..507e279 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,20 @@ -# TODO +# TODO: `terraform-provider-melange` + +### Installing + +``` +terraform { + required_providers { + melange = { source = "imjasonh/melange" } + } +} +``` + +Then `terraform init -upgrade`. + +(This is not yet published; it will be published under `chainguard-dev` when it's ready) + +### Build a single package ``` provider "melange" { @@ -7,6 +23,23 @@ provider "melange" { extra_keyring = ["https://packages.wolfi.dev/os/wolfi-signing.rsa.pub"] } +data "melange_config" "config" { + config_contents = file("package.yaml") +} + +resource "melange_build" "package" { + config = data.melange_config.config.config + config_contents = data.melange_config.config.config_contents +} +``` + +After applying this config, `packages/$ARCH/package-0.0.1-rX.apk` will be built, and `packages/$ARCH/APKINDEX.tar.gz` will be updated. + +(This passes locally but currently fails in CI...) + +### Build a graph of inter-dependent Melange configs + +``` data "melange_graph" "graph" { files = fileset(path.module, "*.yaml") } @@ -15,6 +48,41 @@ resource "melange_build" "foo" { for_each = data.melange_graph.graph.configs depends_on = data.melange_graph.graph.deps[each.key] - config = each.key + config = each.key + config_contents = data.melange_graph.graph[each.key].config_contents } ``` + +This will crawl a collection of Melange config files, construct a graph of the order they should be built to ensure dependencies are met, and build them in that order with Terraform's configured concurrency. + +(This is not yet implemented) + +### Build a package locally, then build it into an image using `apko_build` + +``` +data "melange_config" "config" { + config_contents = file("package.yaml") +} + +resource "melange_build" "package" { + config = data.melange_config.config.config + config_contents = data.melange_config.config.config_contents +} + +provider "apko" { + archs = ["x86_64", "aarch64"] + extra_repositories = ["https://packages.wolfi.dev/os", "./packages"] + extra_keyring = ["https://packages.wolfi.dev/os/wolfi-signing.rsa.pub", "./local-signing.rsa.pub"] +} + +data "apko_config" "config" { + config_contents = file("image.yaml") + extra_packages = [data.melange_config.config.config.package.name] +} + +resource "apko_build" "image" { + config = data.apko_config.config.config +} +``` + +(This is not yet tested)