chore(containers): improve building images

This commit is contained in:
Michele Cereda
2025-06-18 19:38:47 +02:00
parent 881360d5bc
commit 3467328c89
3 changed files with 19 additions and 17 deletions

View File

@@ -208,6 +208,10 @@ docker buildx build … --push \
--cache-from type=registry,ref=012345678901.dkr.ecr.eu-west-2.amazonaws.com/buildkit-test:cache \ --cache-from type=registry,ref=012345678901.dkr.ecr.eu-west-2.amazonaws.com/buildkit-test:cache \
--platform 'linux/amd64,linux/arm64,linux/arm/v7' '.' --platform 'linux/amd64,linux/arm64,linux/arm/v7' '.'
# Clean up the build cache.
docker buildx prune
docker buildx prune -a
# Remove builders. # Remove builders.
docker buildx rm 'builder_name' docker buildx rm 'builder_name'

View File

@@ -3,6 +3,7 @@
Tool to build container images from a Dockerfile with**out** the need of the Docker engine. Tool to build container images from a Dockerfile with**out** the need of the Docker engine.
1. [TL;DR](#tldr) 1. [TL;DR](#tldr)
1. [Create local images using local cache](#create-local-images-using-local-cache)
1. [Usage in GitLab pipelines](#usage-in-gitlab-pipelines) 1. [Usage in GitLab pipelines](#usage-in-gitlab-pipelines)
1. [Further readings](#further-readings) 1. [Further readings](#further-readings)
1. [Sources](#sources) 1. [Sources](#sources)
@@ -82,7 +83,19 @@ docker run -it --rm -v "$PWD/cache:/cache" 'gcr.io/kaniko-project/warmer' \
<summary>Real world use cases</summary> <summary>Real world use cases</summary>
<details style="padding-left: 1rem"> <details style="padding-left: 1rem">
<summary>Create local images using local cache</summary> <summary>Test the Dockerfile for an Ansible execution environment the way a GitLab pipeline would need to execute it</summary>
```sh
docker run --rm -ti -v "$PWD:/workspace" 'gcr.io/kaniko-project/executor:debug' /kaniko/executor --no-push
docker run --rm -ti -v "$PWD:/workspace" --entrypoint '' 'gcr.io/kaniko-project/executor:v1.23.2-debug' \
/kaniko/executor --context '/workspace/someDir' --dockerfile '/workspace/someDir/someDockerfile' --no-push
```
</details>
</details>
## Create local images using local cache
Uses images from the local cache.<br/> Uses images from the local cache.<br/>
It does **not** _save_ cache images in the local cache directory since Kaniko is currently **not** able to manage such It does **not** _save_ cache images in the local cache directory since Kaniko is currently **not** able to manage such
@@ -100,21 +113,6 @@ docker run --rm -ti -v "$PWD:/workspace" 'gcr.io/kaniko-project/executor:debug'
--cache --cache-dir '/workspace/cache' --cache-repo 'oci://cache' --cache --cache-dir '/workspace/cache' --cache-repo 'oci://cache'
``` ```
</details>
<details style="padding-left: 1rem">
<summary>Test the Dockerfile for an Ansible execution environment the way a GitLab pipeline would need to execute it</summary>
```sh
docker run --rm -ti -v "$PWD:/workspace" 'gcr.io/kaniko-project/executor:debug' /kaniko/executor --no-push
docker run --rm -ti -v "$PWD:/workspace" --entrypoint '' 'gcr.io/kaniko-project/executor:v1.23.2-debug' \
/kaniko/executor --context '/workspace/someDir' --dockerfile '/workspace/someDir/someDockerfile' --no-push
```
</details>
</details>
## Usage in GitLab pipelines ## Usage in GitLab pipelines
```yaml ```yaml

View File

@@ -62,7 +62,7 @@ docker buildx build -t 'someTag' '.'
docker buildx build '.' -t 'someTag' --platform 'linux/amd64' --progress=plain --no-cache docker buildx build '.' -t 'someTag' --platform 'linux/amd64' --progress=plain --no-cache
# Remove build cache and leftovers # Remove build cache and leftovers
docker builder prune -a docker buildx prune
docker buildx prune -a docker buildx prune -a
# Check logs # Check logs