{"id":13582535,"url":"https://github.com/smartrecruiters/docker-bakery","last_synced_at":"2025-06-22T17:07:07.656Z","repository":{"id":51242888,"uuid":"124234479","full_name":"smartrecruiters/docker-bakery","owner":"smartrecruiters","description":"Dockerfile hierarchy management tool with automatic rebuilding of dependent images when parent changes","archived":false,"fork":false,"pushed_at":"2024-12-18T14:44:50.000Z","size":31367,"stargazers_count":41,"open_issues_count":2,"forks_count":2,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-04-14T05:51:50.395Z","etag":null,"topics":["bakery","builder","docker","docker-hierarchy","dockerfile-generator","dockerfile-goodness","dockerfile-templating","dockerfiles","dockerfiles-management","dockerfiles-tree","images","templating","tree-structure"],"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/smartrecruiters.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-03-07T12:43:34.000Z","updated_at":"2024-12-18T14:42:15.000Z","dependencies_parsed_at":"2025-04-14T06:01:46.661Z","dependency_job_id":null,"html_url":"https://github.com/smartrecruiters/docker-bakery","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/smartrecruiters/docker-bakery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartrecruiters%2Fdocker-bakery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartrecruiters%2Fdocker-bakery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartrecruiters%2Fdocker-bakery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartrecruiters%2Fdocker-bakery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartrecruiters","download_url":"https://codeload.github.com/smartrecruiters/docker-bakery/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartrecruiters%2Fdocker-bakery/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261330126,"owners_count":23142482,"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":["bakery","builder","docker","docker-hierarchy","dockerfile-generator","dockerfile-goodness","dockerfile-templating","dockerfiles","dockerfiles-management","dockerfiles-tree","images","templating","tree-structure"],"created_at":"2024-08-01T15:02:48.543Z","updated_at":"2025-06-22T17:07:02.627Z","avatar_url":"https://github.com/smartrecruiters.png","language":"Go","readme":"\u003cp align=\"center\"\u003e\n\t\u003ch1 align=\"center\"\u003edocker-bakery\u003c/h1\u003e\n\t\u003cp align=\"center\"\u003e\n\t\t\u003ca href=\"https://travis-ci.org/smartrecruiters/docker-bakery\"\u003e\u003cimg alt=\"Build\" src=\"https://travis-ci.org/smartrecruiters/docker-bakery.svg?branch=master\"\u003e\u003c/a\u003e\t\n\t\t\u003ca href=\"/LICENSE.md\"\u003e\u003cimg alt=\"Software License\" src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\t\n\t\t\u003ca href=\"https://goreportcard.com/report/github.com/smartrecruiters/docker-bakery\"\u003e\u003cimg alt=\"Go Report Card\" src=\"https://goreportcard.com/badge/github.com/smartrecruiters/docker-bakery?style=flat-square\"\u003e\u003c/a\u003e\n\t\t\u003ca href=\"http://godoc.org/github.com/smartrecruiters/docker-bakery\"\u003e\u003cimg alt=\"Go Doc\" src=\"https://img.shields.io/badge/godoc-reference-brightgreen.svg?style=flat-square\"\u003e\u003c/a\u003e\n\t\u003c/p\u003e\n\u003c/p\u003e\n\u003c!-- MarkdownTOC  depth=\"4\" autolink=\"true\" bracket=\"round\" autoanchor=\"true\" --\u003e\n\n- [Purpose](#purpose)\n- [Features](#features)\n- [Example usage](#example-usage)\n- [Example project](#example-project)\n- [Assumptions](#assumptions)\n- [Config](#config)\n  - [Properties config section](#properties-config-section)\n  - [Commands config section](#commands-config-section)\n  - [Other config attributes](#other-config)\n- [Dockerfile.template](#dockerfiletemplate)\n- [Usage](#usage)\n  - [Command help](#command-help)\n  - [Command fill-template](#command-fill-template)\n  - [Command build](#command-build)\n  - [Command push](#command-push)\n  - [Command copy-images-hierarchy](#command-copy-images-hierarchy)\n\n- [How to apply it to your project](#how-to-apply-it-to-your-project)\n- [Limitations](#limitations)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n\u003ca id=\"purpose\"\u003e\u003c/a\u003e\n# Purpose\nAim of the `docker-bakery` is to provide simple solution for automatic rebuilding of dependent images when parent image changes. \n\n\n\u003ca id=\"features\"\u003e\u003c/a\u003e\n# Features\n- Automatic triggering of dependant images builds when parent changes\n- Support for Dockerfile templating with usage of [golang template engine](https://golang.org/pkg/text/template/)\n- Support for [semantic versioning](https://semver.org) scope changes\n- Possibility to `build` and `push` docker images to custom registries\n- Possibility of providing custom `build` and `push` commands\n- Versioning with `git` tags\n- Written in `golang`\n\n\u003ca id=\"example-usage\"\u003e\u003c/a\u003e\n# Example usage\n![\"Example usage\"](docker-bakery-demo.gif)\n\n\u003ca id=\"example-project\"\u003e\u003c/a\u003e\n# Example project\nSee [docker-bakery-example](https://github.com/smartrecruiters/docker-bakery-example) to check how this tool works in action.\n\n\u003ca id=\"assumptions\"\u003e\u003c/a\u003e\n# Assumptions\n - convention: image name is equal to the parent directory name\n - presence of Dockerfile.template will qualify image for automatic updates triggered by base images (`FROM` clause is analyzed)\n - first line in the dockerfile must start with `FROM ` otherwise dependency will not be determined for that file\n - scope change in the base image is propagated to the child images\n - to benefit from dependency updates the child image must use in template variable according to the convention: `{{.BASE_IMAGE_NAME_VERSION}}` where `BASE_IMAGE_NAME` should be substituted with uppercase directory name of the base image. \n \n \tAny hyphens (`-`) or dots (`.`) should be replaced with the underscores (`_`) in the variable name. \n \t\n \tFor example the correct variable name for image/directory named `jdk8-gradle2.14` is `{{.JDK8_GRADLE2_14_VERSION}}`  \n - docker file templates need to be placed in `git` repository (with defined remote) in order versioning of the images could work (versioning is done via `git tags`)\n - additional dynamic variables will be accessible for build templating\n       \n        \n\u003ca id=\"config\"\u003e\u003c/a\u003e\n# Config\n`docker-bakery` needs `config.json` to be provided. Config is used for templating `Dockerfile.template` files and build commands\nStructure of the `config.json` file is as follows:\n\n```\n {\n\t\"properties\": {\n\t\t\"DEFAULT_PULL_REGISTRY\": \"some-private-registry.com:9084\",\n\t\t\"DEFAULT_PUSH_REGISTRY\": \"some-private-registry.com:9082\",\n\t\t\"DOCKERFILE_DIR\": \"Reserved dynamic property, contain path to currently build image. Can be used in template.\",\n\t\t\"IMAGE_NAME\": \"Reserved dynamic property, represents image name. Can be used in template.\",\n\t\t\"IMAGE_VERSION\": \"Reserved dynamic property, represents new version of the image. Can be used in template.\"\n\t},\n\t\"commands\": {\n\t\t\"defaultBuildCommand\": \"docker build --tag {{.IMAGE_NAME}}:{{.IMAGE_VERSION}} --tag {{.DEFAULT_PUSH_REGISTRY}}/{{.IMAGE_NAME}}:{{.IMAGE_VERSION}} --tag {{.DEFAULT_PULL_REGISTRY}}/{{.IMAGE_NAME}}:{{.IMAGE_VERSION}} {{.DOCKERFILE_DIR}}\",\n\t\t\"defaultPushCommand\": \"docker push {{.DEFAULT_PUSH_REGISTRY}}/{{.IMAGE_NAME}}:{{.IMAGE_VERSION}}\"\n\t},\n\t\"reportFileName\": \"custom-report-filename.json\",\n\t\"verbose\": false,\n\t\"autoBuildExcludes\": [\n\t\t\"some-image-name-that-will-be-excluded-from-build-when-parent-changes\"\n\t]\n }\n```\n \n\u003ca id=\"properties-config-section\"\u003e\u003c/a\u003e\n## Properties config section\n This section is dedicated for storing any custom properties that may be available for usage in `Dockerfile.template` files. \n Feel free to modify this section and provide properties according to your needs. Flat structure should be preserved.\n \n This section will also be updated with dynamic properties during runtime. Dynamic properties do not have to be defined \n in config as they are automatically added during runtime.\n \n Following properties belong to dynamic ones:\n - `DOCKERFILE_DIR` - will be replaced with currently processed dockerfile dir\n - `IMAGE_NAME` - will be replaced with currently processed image name\n - `IMAGE_VERSION` - will be replaced with currently processed image version\n - `*_VERSION` - where `*` is the image name. There will be that many properties of this kind as many images are in hierarchy. Initially those properties will be filled with latest versions of pushed images.\n - `BAKERY_BUILDER_NAME` - will be replaced with the git user name (taken from `git config user.name`)  \n - `BAKERY_BUILDER_EMAIL` - will be replaced with the git user email (taken from `git config user.email`)\n - `BAKERY_BUILDER_HOST` - will be replaced with hostname of the machine where build is executed\n - `BAKERY_BUILD_DATE` - will be replaced with current build date \n - `BAKERY_IMAGE_HIERARCHY` - will be replaced with the path representing image hierarchy in the following format: \n \n `parent1:versionOfParent1-\u003eparent2:versionOfParent2-\u003eimageName:imageVersion` \n \n Hierarchy is built automatically given that parent images are exporting the same `ENV` variable that can be accessed in child images. Check the example project for references.\n - `BAKERY_SIGNATURE_VALUE` - will be replaced with a one liner string value embedding other `BAKERY*` variables together. Can be used in templates to create for example `ENV` variable. Example:\n  \n  `SINGATURE=Builder Name;builder@email.com;builder-host-name;2018-03-16 15:47:58;alpine-java:8u144b01_jdk-\u003emammal:3.2.0-\u003edog:4.0.0-\u003edobermann:4.0.0-\u003esmaller-dobermann:4.0.0` \n - `BAKERY_SIGNATURE_ENVS` - will be replaced with embedded `BAKERY*` variables in a `key=value` format. Convenient if you wish to have all `BAKERY*` variables in a dockerfile under single key. \n Check the example project for references. \n\n\u003ca id=\"commands-config-section\"\u003e\u003c/a\u003e\n## Commands config section\nThis section contains two templates used for building and pushing docker images. It allows for specifying custom parameters. \nCommands defined here as templates will be filled with available defined properties from the config section + the dynamic properties set during runtime. \n\n\u003ca id=\"other-config\"\u003e\u003c/a\u003e\n## Other config attributes\n  `reportFileName` - if set it will be used as a file name to store information (in JSON format) about successfully built images. \n\n\u003ca id=\"dockerfiletemplate\"\u003e\u003c/a\u003e\n# Dockerfile.template\nPresence of the `Dockerfile.template` file qualifies the image for the place in hierarchy and therefore allows for triggering builds that depend from this image. It also ensures that image build will be triggered when its parent changes. \n\n\u003ca id=\"usage\"\u003e\u003c/a\u003e\n# Usage\nTo make use of `docker-bakery` as convenient as possible checkout usage of `Makefiles` from the [example project](https://github.com/smartrecruiters/docker-bakery-example) that will simplify usage greatly.\nIf you don't want to use makefiles you can still use `docker-bakery` tool directly.\nCheckout the CLI help via `docker-bakery -h`. \n\n\u003ca id=\"command-help\"\u003e\u003c/a\u003e\n## Command help\n```\nCOMMANDS:\n     fill-template, prepare, prepare-recipe         Used to fill Dockerfile.template file. Values needed for template are taken from the config file and from dynamic properties provided during runtime.\n     build                                          Used to build next version of the images in given scope. Optionally it can skip build of dependant images.\n     push                                           Used to push next version of the images in given scope. Optionally it can skip push of dependant images.\n     show-structure, ss, show-hierarchy, hierarchy  Used to display hierarchy of the images\n     dump-latest-versions, dump                     Used to dump data about latest versions of images to the provided file\n     help, h                                        Shows a list of commands or help for one command\n\n```\n\u003ca id=\"command-fill-template\"\u003e\u003c/a\u003e\n## Command fill-template\n```\ndocker-bakery fill-template -h\nNAME:\n   docker-bakery fill-template - Used to fill Dockerfile.template file. Values needed for template are taken from the config file and from dynamic properties provided during runtime.\n\nUSAGE:\n   docker-bakery fill-template [command options] [arguments...]\n\nOPTIONS:\n   --input value, -i value      Required. Input Dockerfile.template.\n   --output value, -o value     Required. Output Dockerfile generated from template.\n   --config value, -c value     Required. Path to config.json with properties and build commands defined.\n   --rootDir value, --rd value  Optional. Used to override rootDir of the dockerfiles location. Can be defined in config.json, provided in this argument or determined dynamically from the base dir of config file.\n```\n\u003ca id=\"command-build\"\u003e\u003c/a\u003e\n## Command build\n```\ndocker-bakery build -h\nNAME:\n   docker-bakery build - Used to build next version of the images in given scope. Optionally it can skip build of dependant images.\n\nUSAGE:\n   docker-bakery build [command options] [arguments...]\n\nOPTIONS:\n   --dockerfile value, -d value  Required. Path to dockerfile/dockerfile.template file that needs to be build.\n   --scope value, -s value       Required. Scope of the change used to generate the next version. Can be one of: major/minor/patch.\n   --config value, -c value      Required. Path to config.json with properties and build commands defined.\n   --root-dir value, --rd value  Optional. Used to override rootDir of the dockerfiles location. Can be defined in config.json, provided in this argument or determined dynamically from the base dir of config file.\n   --skip-dependants, --sd       Optional. False be default. If this flag is set build of the parent will not trigger dependant builds.\n   --property value, -p value    Optional. Allows for providing additional multiple properties that can be used during templating. Overrides properties defined in config.json file. Expected format is: -p propertyName=propertyValue\n     \n```\n\u003ca id=\"command-push\"\u003e\u003c/a\u003e\n## Command push\n```\ndocker-bakery push -h\nNAME:\n   docker-bakery push - Used to push next version of the images in given scope. Optionally it can skip push of dependant images.\n\nUSAGE:\n   docker-bakery push [command options] [arguments...]\n\nOPTIONS:\n   --dockerfile value, -d value  Required. Path to the dockerfile/dockerfile.template that needs to be pushed.\n   --scope value, -s value       Required. Scope of the change used to generate the next version. Can be one of: major/minor/patch.\n   --config value, -c value      Required. Path to config.json with properties and build commands defined.\n   --rootDir value, --rd value   Optional. Used to override rootDir of the dockerfiles location. Can be defined in config.json, provided in this argument or determined dynamically from the base dir of config file.\n   --skip-dependants, --sd       Optional. False be default. If this flag is set build of the parent will not trigger dependant builds.\n\n```\n\n\u003ca id=\"command-copy-images-hierarchy\"\u003e\u003c/a\u003e\n## Command copy-images-hierarchy\n\nLet's say you have a given hierarchy of images:\n```\npython-3.8\n    python-3.8-jdk\n    python-3.8-web\n        python-3.8-flask\n```\n\nIf you want to quickly introduce python3.9 for those images, you can:\n1) create `python-3.9` image\n2) recreate images hierarchy\n\n```\ndocker-bakery copy-images-hierarchy --config ${path_to_config} --base-image sr-python3.8 -rp 3.8=3.9 -r   \n```\n\nThe resulting hierarchy will look like this:\n\n```\npython-3.9\n    python-3.9-jdk\n    python-3.9-web\n        python-3.9-flask\n```\n\nFor more options run `docker-bakery copy-images-hierarchy help`\n\n\u003ca id=\"how-to-apply-it-to-your-project\"\u003e\u003c/a\u003e\n# How to apply it to your project\nApplying `docker-bakery` is quite simple. Take a look [here](https://github.com/smartrecruiters/docker-bakery-example#how-to-apply-it-to-your-project)\n\n\u003ca id=\"limitations\"\u003e\u003c/a\u003e\n# Limitations\nAt the moment docker multi-stage builds are not fully supported. Only the first line `FROM` is taken into consideration when determining the parent of the image and its place in the hierarchy. \n\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartrecruiters%2Fdocker-bakery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartrecruiters%2Fdocker-bakery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartrecruiters%2Fdocker-bakery/lists"}