Commit Graph

501 Commits

Author SHA1 Message Date
Sharif Elgamal effac9dfc3
Persistent volume caching for base images (#383)
* comments

* initial commit for persisent volume caching

* cache warmer works

* general cleanup

* adding some debugging

* adding missing files

* Fixing up cache retrieval and cleanup

* fix tests

* removing auth since we only cache public images

* simplifying the caching logic

* fixing logic

* adding volume cache to integration tests. remove auth from cache warmer image.

* add building warmer to integration-test

* move sample yaml files to examples dir

* small test fix
2018-10-11 13:38:05 -07:00
priyawadhwa 03db09e95f
Merge pull request #388 from ianberinger/master
Update go-containerregistry dependency
2018-10-10 12:17:58 -07:00
Ian Beringer a72970712f
Update go-containerregistry dependency #245 2018-10-10 20:44:19 +02:00
dlorenc 9a0e29c441
Refactor the build loop. (#385)
This change refactors the build loop a bit to make cache optimization easier in the future. Some notable changes:

The special casing around volume snapshots is removed. Every volume is added to the snapshotFiles list for every command that will snapshot anyway.
Snapshot saving was extracted to a sub-function
The decision on whether or not to snapshot was extracted
2018-10-09 12:15:17 -05:00
priyawadhwa 0a13e042c2
Merge pull request #382 from orisano/patch-1
chore: fix broken markdown (CHANGELOG.md)
2018-10-03 15:00:39 -07:00
dlorenc 734ffe65ce
Rework cache key generation a bit. (#375)
* Rework cache key generation a bit.

Cache keys are now based on the previous commands, rather than the previous state
of the filesystem.

* Refactor command interface a bit, only cache the context for commands that use it.
2018-10-03 16:16:12 -05:00
Nao YONASHIRO 4155330f33
chore: fix broken markdown 2018-10-04 05:51:57 +09:00
priyawadhwa 919df3949b
Merge pull request #381 from blacksails/build-arg-with-equals
Don't cut everything after an equals sign
2018-10-03 13:20:13 -07:00
priyawadhwa e8dc562f45
Merge pull request #377 from priyawadhwa/release
Release v0.4.0
2018-10-03 11:54:58 -07:00
Benjamin Nørgaard 038dcc1958
use strings.SplitN to avoid the join 2018-10-03 14:23:53 +02:00
Benjamin Nørgaard 261ed76405
fix variable collision 2018-10-03 12:04:43 +02:00
Benjamin Nørgaard 18ce0202c2
fix finding address of function return 2018-10-03 11:53:12 +02:00
Benjamin Nørgaard 5d01fc5df6
dont cut everything after and equals sign 2018-10-03 11:39:08 +02:00
Priya Wadhwa 63b54b0b22 Merge branch 'master' of github.com:GoogleContainerTools/kaniko into release 2018-10-02 10:09:50 -07:00
priyawadhwa e4e6fb66e7
Merge pull request #378 from priyawadhwa/broken
Fix travis @ HEAD
2018-10-01 15:28:47 -07:00
Priya Wadhwa 589197b416 Fix travis @ HEAD
I merged a contributor's PR which modifed the HasFilepathPrefix function
to take an additional argument, but the PR hadn't been rebased. One of the
liting tests in Travis caught this bug.
2018-10-01 14:56:46 -07:00
Priya Wadhwa ae81657484 Release v0.4.0
Copied over the release script from skaffold to get all new PRs that
have been merged for the CHANGELOG.

Ran dep ensure.
2018-10-01 14:52:16 -07:00
priyawadhwa 8f0d257134
Merge pull request #334 from peter-evans/fix-volume-cmd
Fix handling of the volume directive
2018-10-01 14:49:33 -07:00
priyawadhwa 442cf27c4b
Merge pull request #376 from ImJasonH/dep
Update go-containerregistry dep and remove unnecessary Options
2018-10-01 11:55:09 -07:00
Jason Hall 5a0c9b2a13 Update go-containerregistry dep and remove unnecessary Options 2018-10-01 14:11:26 -04:00
priyawadhwa 139d372e77
Merge pull request #374 from priyawadhwa/cachebug
Check --cache-repo is provided with --cache and --no-push
2018-09-28 13:39:01 -07:00
dlorenc e1b0f7732e
Fixes a whitelist issue when untarring files in ADD commands. (#371)
* Fixes a whitelist issue when untarring files in ADD commands.

* Add go-cmp test tool.

* Make the integration test tolerate some file differences.
2018-09-28 11:42:07 -07:00
priyawadhwa 7eb691055e
Merge pull request #370 from vbehar/cleanup-flag
Add a new flag to cleanup the filesystem at the end
2018-09-28 10:27:29 -07:00
priyawadhwa 5f9f71dcf8
Merge pull request #369 from vbehar/whitelist-busybox
Whitelist /busybox in the debug image
2018-09-28 09:47:48 -07:00
Priya Wadhwa c4b35c7298 Check --cache-repo is provided with --cache and --no-push
As described in #373, kaniko panics when provided with --cache and --no-push since it tries to infer a cache repo from the destination, which doesn't exist.

To fix this, I added a check to make sure --cache-repo is passed in when both these flags are provided.
2018-09-28 09:43:16 -07:00
dlorenc d904a4c872
Add a benchmark package to store and monitor timings. (#367) 2018-09-28 09:13:17 -07:00
Vincent Behar d10e3f5b74
Whitelist /busybox in the debug image
In the debug image, declare /busybox as a volume so that it is automatically whitelisted, because we don't want to delete it when building multi-stages images.

FYI this is required when using Jenkins, because we need to use the debug kaniko image to be able to start the container "doing nothing" (with /busybox/cat) before building (by executing /kaniko/executor directly inside the container)
See https://issues.jenkins-ci.org/browse/JENKINS-52576
2018-09-28 10:55:08 +02:00
Vincent Behar 49ab8e4979
Add a new flag to cleanup the filesystem at the end
Currently, kaniko can only build a single image per container run, because the filesystem is full of the content of the first image.
When running kaniko in Jenkins, where we need to start the container "doing nothing" first (using the debug kaniko container), and then exec /kaniko/executor, this is a limitation because it means that if we want to build multiple images, we need to start multiple containers - see https://groups.google.com/forum/#!topic/kaniko-users/_7LivHdMdy0 for more details

A solution to fix this issue is to add a new flag to cleanup the filesystem at the end - the same way it is done between stages when building a multi-stages image. This way, the same (debug) container can be used to build multiple images.
2018-09-28 10:25:33 +02:00
peter-evans b1e28ddb4f Fix handling of volume directive 2018-09-28 11:16:25 +09:00
Sharif Elgamal 49184c2114 set default HOME env properly (#341)
* set default HOME env properly

* set HOME to / if user is set by uid

* fix test

* continue to skip user_run test

* fix unit test to match new functionality
2018-09-27 07:31:51 -07:00
priyawadhwa 1a13c81be8
Merge pull request #348 from priyawadhwa/entrypoint
Review config for cmd/entrypoint after building a stage
2018-09-26 21:26:42 +01:00
xanonid 59cb0ebec9 Enable overwriting of links (solves #351) (#360)
* Enable overwriting of links (solves #351)

* add integration test to check extraction of images with replaced hardlinks

* Prevent following symlinks during extracting normal files

This fixes #359, #361, #362.
2018-09-26 07:14:35 -07:00
priyawadhwa bb0df68e50
Merge pull request #363 from priyawadhwa/exists
Only return stdout when running commands for integration tests
2018-09-25 21:56:03 +01:00
priyawadhwa e7675e0569
Merge pull request #364 from priyawadhwa/readme
Update README to add information about layer caching
2018-09-25 21:52:14 +01:00
Priya Wadhwa cd2fedf9d2 Update README to add information about layer caching 2018-09-25 10:25:35 -07:00
Priya Wadhwa 6c39f29081 Only return stdout when running commands for integration tests
When running container-diff in integration tests, both stdout and stderr were being returned
and unmarshalled into the container-diff json object. If container-diff
was giving any error messages (such as, if it didn't have permissions to
extract a file), this would fail even if ultimately no
differences between the filesystems existed.

I updated the RunCommands to only return stdout and print stderr if the
command fails.
2018-09-25 10:05:11 -07:00
priyawadhwa 57ede49dac
Merge pull request #353 from priyawadhwa/cache
Add layer caching to kaniko
2018-09-24 21:40:40 +01:00
Priya Wadhwa e2ca1152f4 Rename flags and default caching to false
Rename --use-cache to --cache, and --cache to --cache-repo to clarify
what the flags are used for. Default caching to false.
2018-09-24 13:18:42 -07:00
Priya Wadhwa 1e1c98229c Merged master, fixed merge conflict 2018-09-17 11:12:29 +01:00
Priya Wadhwa cd1b957e43 Address code review comments; review unnecessary error check 2018-09-17 11:11:51 +01:00
Priya Wadhwa 177bd4f40e Fix typo and update comments 2018-09-17 11:05:57 +01:00
priyawadhwa 8fb220b19b
Merge pull request #356 from priyawadhwa/error
Suppress usage upon Run error
2018-09-14 14:29:31 -07:00
Priya Wadhwa 49d7c7c0ee Suppress usage upon Run error
I changed RunE to Run so that usage wouldn't show upon error. Usage will
still show if PersistentPreRunE fails, which makes sense since those
functions check to make sure arguments passed in are valid.

Also changed logging of multi arg flags to Debugf so that output would
be cleaner.
2018-09-14 12:15:31 -07:00
Priya Wadhwa f7ba67ea25 Specify cache key to differentiate cache layers 2018-09-14 09:53:03 -07:00
Priya Wadhwa eb7194a165 Fix linting errors 2018-09-13 22:06:38 -07:00
Priya Wadhwa c216fbf91b Add layer caching to kaniko
To add layer caching to kaniko, I added two flags: --cache and
--use-cache.

If --use-cache is set, then the cache will be used, and if --cache is
specified then that repo will be used to store cached layers. If --cache
isn't set, a cache will be inferred from the destination provided.

Currently, caching only works for RUN commands. Before executing the
command, kaniko checks if the cached layer exists. If it does, it pulls
it and extracts it. It then adds those files to the snapshotter and
append a layer to the config history.  If the cached layer does not exist, kaniko executes the command and
pushes the newly created layer to the cache.

All cached layers are tagged with a stable key, which is built based off
of:

1. The base image digest
2. The current state of the filesystem
3. The current command being run
4. The current config file (to account for metadata changes)

I also added two integration tests to make sure caching works

1. Dockerfile_test_cache runs 'date', which should be exactly the same
the second time the image is built
2. Dockerfile_test_cache_install makes sure apt-get install can be
reproduced
2018-09-13 18:32:53 -07:00
Tejal Desai 14f3c81b79
Merge pull request #343 from priyawadhwa/stagebuilder
Refactor build into stageBuilder type
2018-09-12 21:35:24 -07:00
Priya Wadhwa 7a6dfb6d8b Removed incorrect FS extraction from earlier merge with master, and fixed linting errors 2018-09-12 17:10:03 -07:00
Priya Wadhwa da6f099820 Merge branch 'master' of github.com:GoogleContainerTools/kaniko into entrypoint 2018-09-12 16:45:25 -07:00
Priya Wadhwa ee9aa954ac merged master, fixed conflicts 2018-09-12 16:43:32 -07:00