Commit Graph

81 Commits

Author SHA1 Message Date
Cole Wippern bdabd774fc Update linter and fix errors
* disable linters that are now enabled by default in new version
* fix linter errors
2019-12-21 12:27:14 -08:00
Will Ripley 4c9a800e12 Added image digest file path 2019-10-21 11:55:55 -05:00
Tejal Desai 743a967933
Merge pull request #804 from tejal29/fix_803
fix creating abs path for urls
2019-10-04 16:00:19 -07:00
Tejal Desai bb9ace058f address Don's comment 2019-10-04 14:43:21 -07:00
Tejal Desai 230c4c9b07 fix linter 2019-10-04 14:39:53 -07:00
Tejal Desai 1c821d050c
Merge pull request #796 from prary/version
Kaniko version
2019-10-04 14:32:14 -07:00
Tejal Desai 6b5b88c2bc fix creating abs path for urls 2019-10-04 14:31:11 -07:00
Tejal Desai 9643e0e9a4
Add missing boilerplate.
Add missing boiler plate.
2019-10-04 11:23:41 -07:00
Tejal Desai eee6f83ff2
Merge pull request #736 from huguesalary/resolve-paths
Resolve relative paths to absolute paths in command line arguments
2019-10-04 00:49:12 -07:00
Prashant f9424d43e7 fixing lint and minor fix 2019-10-03 21:29:40 +05:30
Prashant 24c2dcc867 Merge branch 'master' into version 2019-10-02 21:39:32 +05:30
Prashant de87136720 Kaniko version 2019-10-02 21:22:26 +05:30
Hugues Alary 4327e9ba24 Resolve relative paths to absolute paths in command line arguments
The executor accepts a few arguments dockerfile, context, cache-dir and
digest-file that all represent paths. This commits allows those paths to
be relative to the working directory of the executor.

Fixes #732 #731 #675
2019-08-27 21:06:26 +00:00
chhsia0 11f3b791cd Renamed to `--oci-layout-path` and added a unit test. 2019-08-24 01:28:58 -07:00
chhsia0 730b8b77c8 Added `--layout-path` flag to save image in OCI layout.
Fixed #296.

The output manifests may have `application/vnd.docker.distribution.manifest.v2+json`
as their media types instead of `application/vnd.oci.image.manifest.v1+json`.
2019-08-24 01:04:18 -07:00
Sharif Elgamal 56eeaf41e6
Merge pull request #452 from sharifelgamal/cache-fix
Create cache directory if it doesn't already exist
2019-08-02 13:41:38 -07:00
Sharif Elgamal 6ad4cdf314
Merge branch 'master' of github.com:GoogleContainerTools/kaniko into cache-fix 2019-08-02 13:21:12 -07:00
v.rul 7750094ec1 Add checking image presence in cache prior to downloading it
This changes allow to use kaniko-warmer multiple times without unnecessary docker image downloads.
To check image presence in cache directory I'm using existing cache function that is used by kaniko-executor.
I've considered building separate function to only check image presence, but it will have pretty much the same code.
Questionable decision is to embed CacheOptions type to KanikoOptions and WarmerOptions. Probably this should be resolved by creating interface providing needed options and implement it both mentioned structs. But I've struggled to get a meaningfull name to it.
To replicate previous behaviour of downloading regardless of cache state I've added --force(-f) option.

This changes provides crucial speed-up when downloading images from remote registry is slow.

Closes #722
2019-07-24 18:09:21 +03:00
Taylor Barrella 3422d5572a Misc. small changes/refactoring (#712) 2019-07-23 15:10:22 -07:00
Gijs 3686b65426 Process feedback of priyawadhwa regarding naming/nilcheck.
Changes the argument flag from `--digestfile` to `--digest-file`.
Skips an unneeded nil check.
2019-05-11 15:14:25 +02:00
Gijs a6e3ddfc79 Add `--digestfile` flag to output built digest to file.
This flag, when set, takes a file in the container and writes the image digest to it. This can be used to extract the exact digest of the built image by surrounding tooling without having to parse the logs from Kaniko, for example by pointing the file to a mounted volume or to a file used durint exit status, such as with Kubernetes' [Termination message policy](https://kubernetes.io/docs/tasks/debug-application-cluster/determine-reason-pod-failure/)]

When the flag is not set, the digest is not written to file and the executor behaves as before. The digest is also written to file in case of a tarball or a `--no-push`.

Closes #654
2019-05-02 14:57:44 +02:00
Jason Hall 3fa411ceb9 Check push permissions before building images (#622)
* Check push permissions before building images

* Fix doc comment

* improve error messages
2019-03-19 12:39:59 -05:00
Daisuke Taniwaki f8f59ea4c6 Add insecure-registry and tls-skip-verify-registry flags (#537) 2019-01-29 13:29:47 -06:00
dlorenc 170e0a2d94
Add a lot more timing data. (#518) 2019-01-10 13:27:55 -07:00
linuxshokunin c3afcc0c7d Adding capability to get Dockerfile from URL. (#500)
* Changed to set http or https in Dockerfile path.

* Fixed return value when error.

* Fixed ineffectual error
2019-01-03 10:42:15 -06:00
Sharif Elgamal 29b7c3e879
Adding TTL to caching (#488)
* Adding TTL to caching

* uncomment added lines

* cache TTL works for layers now

* remove debugging

* parse booleans correctly

* parse booleans correctly everywhere

* fix boolean parsing condition

* refactor benchmarking calls

* defer file properly
2018-12-13 14:20:25 -08:00
Priya Wadhwa b0b36ed85a Re-add support for .dockerignore file
This PR adds support for the dockerignore file. Previously when kaniko
had support for the dockerignore file, kaniko first went through the
build context and deleted files that were meant to be ignored. This
resulted in a really bad bug where files in user mounted volumes would
be deleted (my bad).

This time around, instead of modifying the build context at all, kaniko
will check if a file should be excluded when executing ADD/COPY
commands. If a file should be excluded (based on the .dockerignore) it
won't be copied over from the buildcontext and shouldn't end up in the
final image.

I also added a .dockerignore file and Dockerfile as an integration test,
which should fail if the dockerignore is not being processed correctly or if files aren't being excluded correctly.
Also, I removed all the integration testing from the previous version of the
dockerignore support.
2018-12-10 15:20:25 -08:00
Sharif Elgamal 7cde036f44
Add benchmarking code (#448)
* adding benchmarking code

* enable writing to file

* fix build

* time more stuff

* adding benchmarking to integration tests

* compare docker and kaniko times in integration tests

* Switch to setting benchmark file with an env var

* close file at the right time

* fix integration test with environment variables

* fix integration tests

* Adding benchmarking documentation to DEVELOPEMENT.md

* human readable benchmarking steps
2018-11-28 11:54:12 -08:00
Priya Wadhwa 313250f321 Remove support for .dockerignore
Remove support for .dockerignore file until I can change it to ignore
files in memory instead of deleting them

Refer to #466
2018-11-26 11:11:30 -08:00
sharifelgamal a74dc78c65
create cache directory if it doesn't already exist 2018-11-14 11:20:16 -08:00
Adrian Duong e7d1123073 Hide --azure-container-registry-config flag (#445)
ACR is not supported and the flag is a side-effect of vendoring.
The ACR credentials pkg uses pflag.String directly.
2018-11-13 09:50:55 -06:00
Priya Wadhwa 55e6157000 Fix bugs with .dockerignore and improve integration test
I improved handling of the .dockerignore file by:

1. Using docker's parser to parse the .dockerignore and using their
helper functions to determine if a file should be deleted
2. Copying the Dockerfile we are building to /kaniko/Dockerfile so that
if the Dockerfile is specified in .dockerignore it won't be deleted, and
if it is specified in the .dockerignore it won't end up in the final
image
3. I also improved the integration test to create a temp directory with
files to ignore, and updated the .dockerignore to include exclusions (!)
2018-10-31 12:50:23 -07:00
priyawadhwa 6ef616b8b2
Merge pull request #394 from priyawadhwa/ignore
Add support for .dockerignore file
2018-10-30 16:49:04 -07:00
Priya Wadhwa ff4e624c6b don't delete .dockerignore 2018-10-30 16:06:46 -07:00
Priya Wadhwa cb0a5e0a18 Fix integration tests 2018-10-30 15:59:50 -07:00
Daisuke Taniwaki e04a922dc3
Separate insecure pull options 2018-10-25 06:33:58 +09:00
Daisuke Taniwaki 05e3250043 Support insecure pull (#401) 2018-10-22 14:33:41 -07:00
Priya Wadhwa 3fc43f4c73 Add support for .dockerignore file 2018-10-19 09:58:50 -07:00
Priya Wadhwa a572774bbe Add --ignore flag
Added a --ignore flag to ignore packages and files in the build context.
This should mimic the .dockerignore file. Before starting the build, we
go through and delete ignored files from the build context.
2018-10-12 12:09:59 -07:00
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 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
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
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
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 177bd4f40e Fix typo and update comments 2018-09-17 11:05:57 +01: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 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
Priya Wadhwa 99ab68e7f4 Replace gometalinter with GolangCI-Lint
gometalinter is broken @ HEAD, and I looked into why that was. During
that process, I remembered that we took the linting scripts from
skaffold, and found that in skaffold gometalinter was replaced with
GolangCI-Lint:

https://github.com/GoogleContainerTools/skaffold/pull/619

The change made linting in skaffold faster, so I figured instead of
fixing gometalinter it made more sense to remove it and replace it with
GolangCI-Lint for kaniko as well.
2018-09-11 13:30:42 -07:00
Priya Wadhwa 0636fe6040 Merge branch 'master' of github.com:GoogleContainerTools/kaniko into stages 2018-08-30 16:17:44 -07:00