generated from bazel-contrib/rules-template
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from chainguard-dev/docs
docs: add cache and rule docs
- Loading branch information
Showing
8 changed files
with
178 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
docs/*.md linguist-generated=true | ||
docs/initial-setup.md linguist-generated=false | ||
docs/apko-cache.md linguist-generated=false | ||
MODULE.bazel.lock linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Fetching and Caching Contents | ||
|
||
To ensure efficient operation, the `apko_image` rule must maintain a cache of remote contents that it fetches from repositories. While outside of Bazel, `apko` manages its own cache, under Bazel, the cache must be maintained by Bazel to ensure correctness and speed. Therefore, Bazel needs to know what needs to be fetched and from where to cache these HTTP requests and provide them to `apko` as required. | ||
|
||
The `apko.lock.json` file contains all the necessary information about how to perform the HTTP fetches required by `apko` to build the container image. | ||
|
||
## Generating the Lock File | ||
|
||
> **Note:** Documentation for lockfile generation will be added once the `apko resolve` command is available. | ||
## Using `translate_lock` | ||
|
||
Having just the `apko.lock.json` file alone is insufficient; all the information needs to be converted into `apk_<content_type>` repository calls to make them accessible to Bazel. The `translate_lock` tool accomplishes this by taking the `apko.lock.json` file and dynamically generating the required Bazel repositories. | ||
|
||
`translate_lock` will create a new bazel repository named after itself. this repository will also have a target named contents, which you can pass to apko_image: | ||
|
||
```starlark | ||
apko_image( | ||
name = "lock", | ||
config = "apko.yaml", | ||
# name of the repository is the same translate_lock! | ||
contents = "@examples_lock//:contents", | ||
tag = "lock:latest", | ||
) | ||
``` | ||
|
||
#### Usage with `bzlmod` | ||
|
||
```starlark | ||
apk = use_extension("//apko:extensions.bzl", "apko") | ||
|
||
apk.translate_lock( | ||
name = "examples_lock", | ||
lock = "//path/to/lock:apko.lock.json", | ||
) | ||
use_repo(apk, "examples_lock") | ||
``` | ||
|
||
#### Usage with Workspace | ||
|
||
```starlark | ||
load("@rules_apko//apko:translate_lock.bzl", "translate_apko_lock") | ||
|
||
translate_apko_lock( | ||
name = "example_lock", | ||
lock = "//path/to/lock:apko.lock.json", | ||
) | ||
|
||
load("@example_lock//:repositories.bzl", "apko_repositories") | ||
|
||
apko_repositories() | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.