Skip to content

Commit 187b654

Browse files
committed
Fix pull flags.
1 parent f8e0622 commit 187b654

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,13 @@ jobs:
284284
id: build-docker-image
285285
if: steps.prepare-meta.outputs.has-image
286286
timeout-minutes: 120
287-
# TODO(ahuszagh) Remove this multiline and docker images
288-
run: |
289-
docker images
290-
cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}"
287+
run: cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}"
291288
env:
292289
TARGET: ${{ matrix.target }}
293290
SUB: ${{ matrix.sub }}
294291
LABELS: ${{ steps.docker-meta.outputs.labels }}
295292
LATEST: ${{ needs.check.outputs.is-latest || 'false' }}
293+
CROSS_CONTAINER_ENGINE_NO_PULL: true
296294
shell: bash
297295

298296
- name: Set Docker image for test

src/docker/engine.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub struct Engine {
7171
impl Engine {
7272
pub const CROSS_CONTAINER_ENGINE_NO_BUILDKIT_ENV: &'static str =
7373
"CROSS_CONTAINER_ENGINE_NO_BUILDKIT";
74+
pub const CROSS_CONTAINER_ENGINE_NO_PULL_ENV: &'static str = "CROSS_CONTAINER_ENGINE_NO_PULL";
7475
pub fn new(
7576
in_docker: Option<bool>,
7677
is_remote: Option<bool>,
@@ -141,6 +142,15 @@ impl Engine {
141142
.map(|x| bool_from_envvar(&x))
142143
.unwrap_or_default()
143144
}
145+
146+
// if any of the base images do not exist in the registry, even
147+
// if they exist locally, attempting to pull will fail
148+
#[must_use]
149+
pub fn should_pull() -> bool {
150+
!env::var(Self::CROSS_CONTAINER_ENGINE_NO_PULL_ENV)
151+
.map(|x| bool_from_envvar(&x))
152+
.unwrap_or_default()
153+
}
144154
}
145155

146156
// determine if the container engine is docker. this fixes issues with

xtask/src/build_docker_image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub fn build_docker_image(
218218
tags = vec![target.image_name(&repository, tag)];
219219
}
220220

221-
if engine.kind.supports_pull_flag() {
221+
if docker::Engine::should_pull() && engine.kind.supports_pull_flag() {
222222
docker_build.arg("--pull");
223223
}
224224
if no_cache {

0 commit comments

Comments
 (0)