Skip to content

Commit

Permalink
Push by default
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Nov 11, 2023
1 parent 89e9bbb commit 9166069
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Kaniko must run in a container, can only build images, and can only store images
It has the big advantage that it i completely unprivileged and doesn't require any host configuration, unlike e.g. Podman which requires your system to have the correct cgroups configuration.

It does not use a local Docker store, so it is not possible to separate the build and push steps.
This means the repo2docker `--push` argument has no effect, you must set Traitlet `KanikoEngine.push_image=True` or environment variable `KANIKO_PUSH_IMAGE=1` to automatically push the image to a container registry as part of the build step.
**This means the repo2docker `--push`/`--no-push` arguments have no effect.**
The default in this plugin is to automatically push the image to a registry after it is built.
Set Traitlet `KanikoEngine.push_image=False` or environment variable `KANIKO_PUSH_IMAGE=0` to disable pushing the image.

Kaniko does not cache layers locally, instead it uses a registry for caching.
You should probably use a dedicated local private registry for speed and not the remote registry used for storing the built image.
Expand All @@ -17,18 +19,31 @@ These behave similarly to `ContainerEngine.registry_credentials` and `CONTAINER_

## Running

```
podman run -it --rm repo2kaniko \
repo2docker --debug --engine=kaniko \
--Repo2Docker.user_id=1000 --user-name=jovyan \
--KanikoEngine.registry_credentials=registry=quay.io \
--KanikoEngine.registry_credentials=username=quay-user \
--KanikoEngine.registry_credentials=password=quay-password \
--image-name=quay.io/quay-user/r2d-test \
--no-run \
https://github.com/binderhub-ci-repos/minimal-dockerfile
```

With a local registry that can be used as a cache:

```
./run-local-registry.sh
REGISTRY=...
podman run -it --rm repo2kaniko \
repo2docker --debug --engine=kaniko \
--Repo2Docker.user_id=1000 --user-name=jovyan \
--KanikoEngine.push_image=true \
--KanikoEngine.cache_registry=$REGISTRY:5000/cache \
--KanikoEngine.cache_registry=$REGISTRY/cache \
--KanikoEngine.cache_registry_credentials=username=user \
--KanikoEngine.cache_registry_credentials=password=password \
--KanikoEngine.cache_registry_insecure=true \
--image-name=$REGISTRY:5000/r2d-test \
--image-name=$REGISTRY/r2d-test \
--no-run \
https://github.com/binderhub-ci-repos/minimal-dockerfile
```
1 change: 0 additions & 1 deletion ci/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ echo "::group::Run repo2kaniko"
$ENGINE run --rm --network=host -v "$PWD/ci/test-conda:/test-conda:ro,z" \
"$REPO2KANIKO_IMAGE" repo2docker --engine kaniko --no-run --debug \
--user-id=1000 --user-name=jovyan --image-name $PUSHED_IMAGE \
--KanikoEngine.push_image=true \
--KanikoEngine.registry_credentials=registry=$REGISTRY \
--KanikoEngine.registry_credentials=username=user \
--KanikoEngine.registry_credentials=password=password \
Expand Down
4 changes: 2 additions & 2 deletions repo2kaniko/kaniko.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class KanikoEngine(ContainerEngine):
kaniko_loglevel = Unicode("", help="Kaniko log level", config=True)

push_image = Bool(
help="Push built image.",
help="Push built image, default true.",
config=True,
)

Expand All @@ -47,7 +47,7 @@ def _push_image_default(self):
"""
Set push_image from KANIKO_PUSH_IMAGE
"""
return os.getenv("KANIKO_PUSH_IMAGE", "").lower() in ("1", "t", "true")
return os.getenv("KANIKO_PUSH_IMAGE", "1").lower() in ("1", "t", "true")

cache_registry = Unicode(
"",
Expand Down

0 comments on commit 9166069

Please sign in to comment.