kaniko icon indicating copy to clipboard operation
kaniko copied to clipboard

Is there way to create local cache without running /kaniko/warmer command?

Open IdeoG opened this issue 1 year ago • 0 comments

Actual behavior Hey community, I have a multistage build, when I create a base layer with kaniko and then use it in three other images as the base image. We run kaniko build in gitlab ci using kubernetes executor.

Here is a source code of my job to build images:

build_and_push:
  needs:
    - job: tag
  image:
    name: gcr.io/kaniko-project/executor:v1.23.0-debug
    entrypoint: [ "" ]
  cache:
    paths:
       - /cache
  script:
    - >-
      /kaniko/executor
      --build-arg TAG=${TAG}
      --build-arg REGISTRY="${ECR_REGISTRY}"
      --cache=true
      --context "."
      --dockerfile "./deploy/base/Dockerfile"
      --destination "${ECR_REGISTRY}/backend:base-${TAG}"
    - >-
      /kaniko/executor
      --build-arg TAG=${TAG}
      --build-arg REGISTRY="${ECR_REGISTRY}"
      --cache=true
      --context "."
      --dockerfile "./deploy/backend/Dockerfile"
      --destination "${ECR_REGISTRY}/backend:${TAG}" &
      /kaniko/executor
      --build-arg TAG=${TAG}
      --build-arg REGISTRY="${ECR_REGISTRY}"
      --cache=true
      --context "."
      --dockerfile "./deploy/cron/Dockerfile"
      --destination "${ECR_REGISTRY}/backend:cron-${TAG}" &
      /kaniko/executor
      --build-arg TAG=${TAG}
      --build-arg REGISTRY="${ECR_REGISTRY}"
      --cache=true
      --context "."
      --dockerfile "./deploy/admin/Dockerfile"
      --destination "${ECR_REGISTRY}/backend:admin-${TAG}" &
      wait

Expected behavior

  1. /kaniko/executor command on the base image creates the local cache in /cache dir and 3 other images are using them.
  2. a simple restart of the job above will not build the base image again, but find it in /cache directory.

To Reproduce

  1. make the multistage build.
  2. run and restart the job.

Additional Information

  • Dockerfile Please provide either the Dockerfile you're trying to build or one that can reproduce this error.
  • Build Context Please provide or clearly describe any files needed to build the Dockerfile (ADD/COPY commands)
  • Kaniko Image (fully qualified with digest)

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
  • - [ ]
Please check if the build works in docker but not in kaniko
  • - [ ]
Please check if this error is seen when you use --cache flag
  • - [ ]
Please check if your dockerfile is a multistage dockerfile
  • - [x]

IdeoG avatar May 31 '24 09:05 IdeoG