{"id":28147001,"url":"https://github.com/hiroshi/cb","last_synced_at":"2025-05-14T23:15:59.115Z","repository":{"id":43610062,"uuid":"69462160","full_name":"hiroshi/cb","owner":"hiroshi","description":"Build container images locally using Google Cloud Container Builder compatible config file. 2017-08-22: Now there is official alternative https://github.com/GoogleCloudPlatform/container-builder-local.","archived":false,"fork":false,"pushed_at":"2016-10-30T03:14:19.000Z","size":15,"stargazers_count":22,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-04-13T08:26:52.076Z","etag":null,"topics":["container-builder","docker-image"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hiroshi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-28T12:45:14.000Z","updated_at":"2017-12-14T22:07:45.000Z","dependencies_parsed_at":"2022-08-19T16:01:36.836Z","dependency_job_id":null,"html_url":"https://github.com/hiroshi/cb","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroshi%2Fcb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroshi%2Fcb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroshi%2Fcb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiroshi%2Fcb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiroshi","download_url":"https://codeload.github.com/hiroshi/cb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243304,"owners_count":22038049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["container-builder","docker-image"],"created_at":"2025-05-14T23:15:23.319Z","updated_at":"2025-05-14T23:15:59.100Z","avatar_url":"https://github.com/hiroshi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cb - a Container Builder\n\nIt builds container images locally using [Google Cloud Container Builder config file](https://cloud.google.com/container-builder/docs/api/build-requests#build_steps).\n\nWhy not just do `docker build`? It will be useful to provide an easy way to manage multiple steps builds.\n- We love small docker images:\n  - Don't want to contain golang environment. We love a single go binary docker image.\n  - Don't Want to contain frontend js build environment for a web app.\n\n### What it looks like?\n\n```\nsteps:\n- name: gcr.io/cloud-builders/docker\n  args: [\"build\", \"-t\", \"cb-build\", \"-f\", \"Dockerfile.build\", \".\"]\n- name: cb-build\n  args: [\"cp\", \"/go/src/cb/cb\", \"/workspace\"]\n- name: gcr.io/cloud-builders/docker\n  args: [\"build\", \"-t\", \"cb\", \".\"]\n```\nThis is an example config file. It will build a golang single binary image of `cb` command itself (not useful though).\n- 1st step - Build a temporary image. It builds a go binary using `golang` base image as usual.\n- 2nd step - Run the resulted image of 1st step. It copies the golang binary in the image to workspace volume.\n- 3rd step - Build a final image from scratch. Just add the `cb` command from workplace volume.\n\n```\n$ docker images\nREPOSITORY      TAG          IMAGE ID            CREATED             SIZE\ncb              latest       05994f135ea4        2 days ago          3.208 MB\ncb-build        latest       61f9b946f604        2 days ago          680.9 MB\n...\n```\n\n## Install\n\n`go get -u github.com/hiroshi/cb`\n\nMake sure you have `$GOPATH/bin` in your `$PATH`.\n\n## Usage\n\n`cb SOURCE.tar.gz --config CONFIG.(json|yml)`\n\n### Notes\n- The [`source`](https://cloud.google.com/container-builder/docs/api/build-requests#source_location) field in config will be ignored as well as `gcloud alpha container builds create` do. Specify SOURCE as 1st argument.\n- The [`images`](https://cloud.google.com/container-builder/docs/api/build-requests#resulting_images) field in config will be ignored. The `cb` command is intended for local builds so always pushing images are not supposed to be welcome.\n\n## How it works\n- 1) Create a volume for `workspace` with `docker volume create`.\n- 2) Expand `SOURCE` into the `workspace` volume with `docker copy`.\n- 3) `docker run` an image with volumes `/var/run/docker.sock//var/run/docker.sock/`, `WORKSPACE_VOLUME:/workspace`.\n  - If the image have docker command like [this](https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/docker), you can do `docker build` or anything in container with SOURCE at hand.\n- 4) Repeat 3) with different image and args as you specifed in `steps` field of CONFIG.\n\nDo you get it? No? See and run examples, I hope it may help you understand.\n\n## Examples\n`make run-example`\n\n## TODO\n\n- Support `wait_for` and `id` fields of [`steps`](https://cloud.google.com/container-builder/docs/api/build-requests#build_steps)\n\n## References\n- [Build request - Google Cloud Container Builder](https://cloud.google.com/container-builder/docs/api/build-requests)\n- [gcloud alpha container builds create](https://cloud.google.com/sdk/gcloud/reference/alpha/container/builds/create)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiroshi%2Fcb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiroshi%2Fcb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiroshi%2Fcb/lists"}