Skip to content

Commit

Permalink
feat: rewrite timestamps for cache hits
Browse files Browse the repository at this point in the history
  • Loading branch information
rcwbr committed Nov 10, 2024
1 parent e3f7c60 commit fff0432
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The `devcontainer-cache-build-initialize` script reads several environment varia
| `DEVCONTAINER_IMAGE` | ✓ | N/A | The tag applied to the image build |
| `DEVCONTAINER_BUILD_ADDITIONAL_ARGS` | ✗ | N/A | Arbitrary additional args forwarded to the `build` or `bake` command |
| `DEVCONTAINER_CACHE_FROMS` | ✗ | `type=registry,ref=[DEVCONTAINER_REGISTRY]-cache:[current git branch name sanitized] type=registry,ref=[DEVCONTAINER_REGISTRY]-cache:local-[current git branch name sanitized] type=registry,ref=[DEVCONTAINER_REGISTRY]-cache:[DEVCONTAINER_DEFAULT_BRANCH_NAME, sanitized]` | Each [`cache-from` arg](https://docs.docker.com/reference/cli/docker/buildx/build/#cache-from) to be applied to the image build, space separated |
| `DEVCONTAINER_CACHE_TOS` | ✗ | `type=registry,ref=[DEVCONTAINER_REGISTRY]-cache:[local-][current git branch name sanitized]` | Each [`cache-to` arg](https://docs.docker.com/reference/cli/docker/buildx/build/#cache-to) to be applied to the image build, space separated. The default value includes `local-` applied as a version prefix unless `CI=true` |
| `DEVCONTAINER_CACHE_TOS` | ✗ | `type=registry,rewrite-timestamp=true,ref=[DEVCONTAINER_REGISTRY]-cache:[local-][current git branch name sanitized]` | Each [`cache-to` arg](https://docs.docker.com/reference/cli/docker/buildx/build/#cache-to) to be applied to the image build, space separated. The default value includes `local-` applied as a version prefix unless `CI=true` |
| `DEVCONTAINER_CONTEXT` | ✗ | `.` | The build context for the image |
| `DEVCONTAINER_DEFAULT_BRANCH_NAME` | ✗ | `main` | The branch name from which to always pull cache |
| `DEVCONTAINER_DEFINITION_TYPE` | ✗ | `build` | The image definition type, [basic Docker build (`build`)](https://docs.docker.com/reference/cli/docker/buildx/build/) or [Bake (`bake`)](https://docs.docker.com/reference/cli/docker/buildx/bake/) |
Expand Down
4 changes: 2 additions & 2 deletions devcontainer-cache-build-initialize
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ DEVCONTAINER_CACHE_FROMS="${DEVCONTAINER_CACHE_FROMS:=${DEFAULT_DEVCONTAINER_CAC

if [[ "${CI}" != "true" ]]; then
DEFAULT_DEVCONTAINER_CACHE_TOS=" \
type=registry,ref=${DEVCONTAINER_IMAGE_REF}-cache:local-${GIT_BRANCH_SANITIZED} \
type=registry,rewrite-timestamp=true,ref=${DEVCONTAINER_IMAGE_REF}-cache:local-${GIT_BRANCH_SANITIZED} \
"
else
DEFAULT_DEVCONTAINER_CACHE_TOS=" \
type=registry,ref=${DEVCONTAINER_IMAGE_REF}-cache:${GIT_BRANCH_SANITIZED} \
type=registry,rewrite-timestamp=true,ref=${DEVCONTAINER_IMAGE_REF}-cache:${GIT_BRANCH_SANITIZED} \
"
fi
DEVCONTAINER_CACHE_TOS="${DEVCONTAINER_CACHE_TOS:=${DEFAULT_DEVCONTAINER_CACHE_TOS}}"
Expand Down

0 comments on commit fff0432

Please sign in to comment.