{"id":41863062,"url":"https://github.com/revl/docker-reuse","last_synced_at":"2026-01-25T11:33:45.436Z","repository":{"id":141375999,"uuid":"329626905","full_name":"revl/docker-reuse","owner":"revl","description":"Rebuild and push a new Docker image only if the sources have changed","archived":false,"fork":false,"pushed_at":"2025-12-22T17:27:31.000Z","size":97,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-22T22:46:15.955Z","etag":null,"topics":["docker","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/revl.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-01-14T13:41:42.000Z","updated_at":"2025-12-22T17:27:35.000Z","dependencies_parsed_at":"2025-09-17T06:10:36.104Z","dependency_job_id":"8bfc6d34-ba7d-47ef-9ec9-7ed802800121","html_url":"https://github.com/revl/docker-reuse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/revl/docker-reuse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revl%2Fdocker-reuse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revl%2Fdocker-reuse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revl%2Fdocker-reuse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revl%2Fdocker-reuse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revl","download_url":"https://codeload.github.com/revl/docker-reuse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revl%2Fdocker-reuse/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28752668,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T10:25:12.305Z","status":"ssl_error","status_checked_at":"2026-01-25T10:25:11.933Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["docker","docker-image"],"created_at":"2026-01-25T11:33:45.364Z","updated_at":"2026-01-25T11:33:45.430Z","avatar_url":"https://github.com/revl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-reuse\n\n## Overview\n\n`docker-reuse` is a tool for building and publishing Docker images. It has two\nrelated and complementary purposes:\n\n1. Make the image content-addressable by tagging it with a fingerprint\n   computed from the sources referenced in the Dockerfile.\n\n   As a result, the image tag never changes unless the sources have changed,\n   and so Kubernetes (or another orchestration system) won't have to restart\n   the containers that use that image.\n\n2. Save time and resources by bypassing the lengthy build and push operations\n   if not a single source has changed.\n\n   This performance improvement is less significant for the local Docker\n   builds, which are relatively fast if the sources did not change. However,\n   for the environments where Docker layer caching is not available (like\n   Google Cloud Build), knowing when it is safe to skip the entire build can\n   be a huge time-saver.\n\nHere's how `docker-reuse` works:\n\n1. It computes a 160-bit fingerprint from the Dockerfile sources.\n2. It attempts to find a previously built image in the registry using the\n   fingerprint as a tag.\n3. If no such image exists, the tool builds it and pushes it to the registry.\n4. In either case, `docker-reuse` updates all references to the image in a\n   user-provided template file(s) to contain this exact image tag.\n\n## Usage as a command line tool\n\n`docker-reuse [OPTIONS] PATH IMAGE [ARG...]`\n\nPositional arguments are:\n\n- `PATH`\n\n  Docker build context directory\n\n- `IMAGE`\n\n  Name of the image to find or build\n\n- `[ARG...]`\n\n  Optional build arguments (Format: `NAME[=value]`). If the value is not\n  provided, it is taken from the environment variable having the same name as\n  the build argument.\n\nOptions:\n\n- `-f, --dockerfile=FILE`\n\n  Pathname of the Dockerfile (Default is `PATH/Dockerfile`)\n\n- `-p, --placeholder=PLACEHOLDER`\n\n  Placeholder for the new image name in the file specified by `--template` or\n  `--update-in-place` (by default, the image name itself, including the tag).\n\n- `--template FILE`\n\n  Template file to use for the next `--write-to` operation.\n\n- `--write-to FILE`\n\n  File to overwrite with the template file's content where the placeholder is\n  replaced with the new image tag. Requires `--template` to be specified\n  earlier in the command line.\n\n- `-u, --update-in-place=FILE`\n\n  File to read and update in place with the new image tag (equivalent to\n  `--template` and `--write-to` pointing to the same file). Can be specified\n  multiple times.\n\n- `-q, --quiet`\n\n  Suppress build output\n\n- `-t, --tag=TAG`\n\n  Additional tag to use for the image (by default, only the 160-bit\n  fingerprint computed from the image sources is used). Can be specified\n  multiple times.\n\n- `-m, --mode=MODE`\n\n  Fingerprinting mode \u0026mdash; one of the following:\n\n  - `commit` \u0026mdash; use the commit hash as the fingerprint\n  - `sha1` \u0026mdash; compute the SHA1 hash of the source files and use the\n    combined hash as the fingerprint\n  - `auto` \u0026mdash; use the commit hash if available, otherwise fall back to\n    `sha1`\n\n- `--platform PLATFORM`\n\n  Target platform for the image (e.g., `linux/amd64`).\n\n- `--check-local-cache`\n\n  If the target image already exists in the local cache, assume it also exists\n  in the registry and skip pushing it to the registry. This is an optimization\n  shortcut for faster local builds and should be used with caution.\n\n### Example\n\n    docker-reuse \\\n        -f ./docker/myapp/Dockerfile \\\n        --update-in-place ./kubernetes/myapp/deployment.yaml \\\n        -t v1.0.0 \\\n        -m sha1 \\\n        ./src/myapp \\\n        mydockerhubid/myapp\n\n## Usage as a Google Cloud Build builder\n\nWhen used as a [community Cloud Build\nbuilder](https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/docker-reuse),\n`docker-reuse` replaces the `docker` builder steps as well as the `images`\nfield in `cloudbuild.yaml`.\n\n### Cloud Build Example\n\nHere's an example of a trivial but complete `cloudbuild.yaml`:\n\n    steps:\n      - id: build-and-push\n        name: gcr.io/$PROJECT_ID/docker-reuse\n        args: [\n            \"-f\",\n            \"docker/hello-world/Dockerfile\",\n            \"--update-in-place\",\n            \"kubernetes/hello-world/deployment.yaml\", # the file to update\n            \"-p\",\n            \"IMAGE_PLACEHOLDER\", # the string to replace in deployment.yaml\n            \".\",\n            \"gcr.io/$PROJECT_ID/hello-world\", # the image to build\n            \"GREETING=Hello, World!\", # build-arg value is provided\n            \"PORT\", # build-arg value is taken from the environment\n          ]\n        env:\n          - \"PORT=8080\"\n        timeout: 900s\n\n      - id: deploy\n        waitFor: [\"build-and-push\"]\n        name: gcr.io/cloud-builders/kubectl\n        args: [\"apply\", \"-k\", \"kubernetes/hello-world\"]\n        env:\n          - \"CLOUDSDK_COMPUTE_ZONE=${_CLUSTER_ZONE}\"\n          - \"CLOUDSDK_CONTAINER_CLUSTER=${_CLUSTER_NAME}\"\n\n    substitutions:\n      _CLUSTER_ZONE: us-east4-b\n      _CLUSTER_NAME: cluster-1\n\nAdditional information and working examples can be found on the [community builder\npage](https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/docker-reuse).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevl%2Fdocker-reuse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevl%2Fdocker-reuse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevl%2Fdocker-reuse/lists"}