Skip to content

Commit

Permalink
Use --pull-policy if-not-present when running pack build
Browse files Browse the repository at this point in the history
Since it:
1. Saves ~2 seconds per integration test re-pulling an image that's already up to date.
2. Helps prevent hitting Docker Hub or ECR rate limits from duplicate (and redundant)
   image pulling (that counts agains the rate limit even when it's a no-op).

Longer term, if Pack CLI supports a periodic pulling mode (buildpacks/pack#1368), we
can switch to that, however for now this is the lesser of two evils - and in most cases
Pack usage outside of `libcnb-test` will ensure that newer builder images are pulled
from time to time.

Fixes #306.
  • Loading branch information
edmorley committed Mar 7, 2022
1 parent c83fefb commit d3ca146
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,12 @@ jobs:
uses: Swatinem/[email protected]
- name: Install Pack CLI
uses: buildpacks/github-actions/[email protected]
- name: Configure Pack CLI
# Default to a small non-libc image for faster CI + to validate the static musl cross-compilation.
# Adjust pull-policy to prevent redundant image-pulling, which slows CI and risks hitting registry rate limits.
run: |
pack config default-builder cnbs/sample-builder:alpine
pack config pull-policy if-not-present
- name: Run integration tests
# Runs any tests annotated with the `#[ignore]` attribute (which in this repo, are all of the integration tests).
run: cargo test -- --ignored
- name: Compile and package examples/basics
run: cargo run --package libcnb-cargo -- libcnb package
working-directory: ./examples/basics
- name: Pack build using examples/basics
run: pack build example-basics --buildpack target/buildpack/debug/libcnb-examples_basics --path examples/
# Uses a non-libc image to validate the static musl cross-compilation.
run: pack build example-basics --builder cnbs/sample-builder:alpine --buildpack target/buildpack/debug/libcnb-examples_basics --path examples/
1 change: 1 addition & 0 deletions libcnb-test/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Replaced `IntegrationTestContext::start_container` with `IntegrationTestContext::prepare_container`, allowing users to configure the container before starting it. Ports can now be exposed via `PrepareContainerContext::expose_port`. ([#346](https://github.com/Malax/libcnb.rs/pull/346))
- Added the ability to set environment variables for the container via `PrepareContainerContext::env` and `PrepareContainerContext::envs`. ([#346](https://github.com/Malax/libcnb.rs/pull/346))
- Switch from `libcnb-cargo` to the new `libcnb-package` crate for buildpack packaging, which improves compile times due to it not including CLI-related dependencies ([#362](https://github.com/Malax/libcnb.rs/pull/362)).
- Use `--pull-policy if-not-present` when running `pack build` ([#373](https://github.com/Malax/libcnb.rs/pull/373)).

## [0.2.0] 2022-02-28

Expand Down
5 changes: 5 additions & 0 deletions libcnb-test/src/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ impl From<PackBuildCommand> for Command {
pack_build_command.builder,
String::from("--path"),
pack_build_command.path.to_string_lossy().to_string(),
// Adjust pull-policy to prevent redundant image-pulling, which slows CI and risks hitting registry rate limits.
String::from("--pull-policy"),
String::from("if-not-present"),
];

for buildpack in pack_build_command.buildpacks {
Expand Down Expand Up @@ -141,6 +144,8 @@ mod tests {
"builder:20",
"--path",
"/tmp/foo/bar",
"--pull-policy",
"if-not-present",
"--buildpack",
"libcnb/buildpack1",
"--buildpack",
Expand Down

0 comments on commit d3ca146

Please sign in to comment.