kontain.me icon indicating copy to clipboard operation
kontain.me copied to clipboard

Post build config to generate an image

Open imjasonh opened this issue 4 years ago • 4 comments

@jonjohnsonjr had an idea:

docker run $(curl -X POST --data-binary @image.yaml https://build.kontain.me)

Instead of trying to express the build config (what to build, how to build) in registry-API-compatible URL params, send the config in a POST to an API, which responds with the image URL where it will serve the built image when it's done, e.g., build.kontain.me/14213b68-9120-448e-a368-f267ec2524d5

That build config could be YAML, JSON, a tar file containing source, tons of stuff.

Good idea Jon.

imjasonh avatar May 26 '21 16:05 imjasonh

Off the top of my head, the request could be, based on Shipwright's API:

source:
  url: https://github.com/foo/bar
strategy:
  name: buildpacks-v3
async: true
  • If async:false, requests for build.kontain.me/<uuid> block until the image is built (or if it fails, serve an error)
  • If async:true, requests fail immediately with an error until the image is built, assuming the client (e.g., K8s) will ImagePullBackOff until the image can successfully be served.

imjasonh avatar May 27 '21 01:05 imjasonh

async: true

Could we rely on HTTP semantics instead, somehow?

jonjohnsonjr avatar May 28 '21 16:05 jonjohnsonjr

Could we rely on HTTP semantics instead, somehow?

How do you mean?

imjasonh avatar Jun 01 '21 14:06 imjasonh

This model could also be used to describe packages to include in the image using something like https://nixery.dev/,

packages:
- shell@v1
- git@v2
- htop@v3

...or to explicitly specify image content and augmentations on base images:

baseImage: gcr.io/distroless/static@sha256:deadbeef
files:
  /path/to/foo: i am foo
  /path/to/bar: i am bar

Instead of a UUID, the generated image name could be derived from the SHA of the input YAML description, e.g.:

build.kontain.me/<sha-of-the-yaml>

...so that pushing identical YAML immediately returns the previously built reference.

Users might also want some way to describe their own tags for the resulting image, e.g.:

curl -X POST build.kontain.me/custom/path:custom-tag

...but in general we can also just expect them to copy the resulting image to their own registry immediately after it's built:

crane cp $(curl -X POST https://build.kontain.me) gcr.io/my-project/my-image:my-tag

imjasonh avatar Jul 08 '21 15:07 imjasonh