Commit Graph

171 Commits

Author SHA1 Message Date
ejose19 2f8d939b3f
fix: CheckPushPermissions not being called when CacheRepo was set (#1471) 2020-10-29 23:46:00 -07:00
Matt Moore a310cc6d1c
Add multi-arch image via Bazel (#1452)
* Add multi-arch image via Bazel

* Drop the commented  tags

* Move tests to //integration
2020-10-09 13:02:09 -07:00
Tinjo Schöni 5f4e2f1366
Fix .dockerignore for build context copies in later stages (#1447)
* Extend .dockerignore integration test with copies in later stages

.dockerignore should continue to apply when copying from the build context in later stages, but it currently doesn't

* Replace excluded global with passed along FileContext struct

This new FileContext struct allows much cleaner handling of context specific file exclusions.
The global excluded file state is no longer needed.

Additionally this also fixes the issue where excluded files aren't being applied for build context copies in later build stages.
2020-10-08 12:47:14 -07:00
Thomas Stromberg f79492b0cd Make --use-new-run flag help easier to understand 2020-08-29 11:01:14 -07:00
Carlos Alexandro Becker e483bee97c
feat: git options
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-06-24 15:31:32 -03:00
Carlos Alexandro Becker 57c2df4d97
feat: new git flags
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-06-15 17:24:04 -03:00
Tejal Desai 43338d4b2f add a new run command along with a new flag 2020-06-05 19:53:16 -07:00
Tejal Desai 6ab97e2b5f ADD GCB benchmark code 2020-06-05 12:46:47 -07:00
Tejal Desai 994a412d0b some more renames 2020-06-02 16:08:46 -07:00
Tejal Desai cbf3073fda rename whitelist to ignorelist 2020-06-02 15:56:27 -07:00
Tejal Desai 0f67b782fa
fix formatting. 2020-05-03 21:01:04 -07:00
Tejal Desai 0db357935f
fix formatiing 2020-05-03 21:00:33 -07:00
Tejal Desai da051c0474
fix gofmt 2020-05-03 20:59:29 -07:00
Tejal Desai 94ee809e1c
Merge branch 'master' into log-timestamp-v0.19.0 2020-05-03 20:58:34 -07:00
Tejal Desai 36748facc5
Merge pull request #1203 from dani29/cache
Set very large logs to Trace level
2020-05-01 10:35:15 -07:00
Jon Henrik Bjørnstad 41a95fe4bd Add timestamp to logs 2020-04-23 13:40:47 +02:00
Dani Raznikov 04888f2690 Set loud logs to trace level 2020-04-18 20:27:25 +03:00
Jordan Goasdoué 8cbc7a8ca2 feat: multistages is now built without unusued stages 2020-04-17 09:59:56 +02:00
Carlos Alexandro Becker 92b9582ff9
fix: better error if not exists
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-04-03 16:21:29 -03:00
Carlos Alexandro Becker 3aaec5015b
feat: allow a subdir within a context
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2020-04-03 15:34:59 -03:00
Tejal Desai a173bf020b
Merge pull request #1115 from JordanGoasdoue/allow-build-context-from-local-targz
feat: add support of local '.tar.gz' file inside the kaniko container
2020-03-17 15:24:10 -07:00
Jordan GOASDOUE fda7ed4f74 feat: add support of local '.tar.gz' file inside the kaniko container 2020-03-12 22:51:30 +01:00
Tejal Desai 32decf5798
Merge pull request #1075 from greut/label-flag
executor: add --label flag
2020-03-12 13:47:01 -07:00
Ben Einaudi b73c2c10c8 Allow user to provide registry certificate
Fixes #1100
Fixes #1101
2020-03-08 18:17:50 +01:00
Yoan Blanc 53326fa0bf
executor: add --label flag
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-03-07 18:17:26 +01:00
Yoan Blanc edc4eb33f4
Merge remote-tracking branch 'origin/master' into registry-mirror 2020-02-16 09:28:54 +01:00
cvgw 7e2009b5e2 More idiomatic logging config
Update logging configuration to be more idiomatic for a Cobra
application
2020-02-07 16:13:03 -08:00
Or Sela 9dd050b892 set log format using a flag 2020-02-07 00:05:59 +02:00
xanonid ac4c80d241 Refactor code, introduce constants for uid/gid = -1 2020-02-03 14:56:23 -08:00
xanonid e3b5a7b85d Support COPY --chown flag (Closes: #9) 2020-02-03 14:56:23 -08:00
Ben Einaudi 2f1e54e591 Expand build argument from environment when no value specified
Fixes #713
2020-01-30 12:01:06 +01:00
Tejal Desai 47ab3fe997
Merge branch 'master' into registry-mirror 2020-01-29 11:42:06 -08:00
Tejal Desai 8b991f6baf Add falg to --whitelist-var-run set to true to preserver default kaniko behaviour of /var/run ignored. Set it to false to add /var/run in destination directory 2020-01-28 10:52:36 -08:00
Tejal Desai d49c198c90 Revert "add option additonal-whitelist"
This reverts commit 72bfed1850.
2020-01-28 08:52:36 -08:00
Tejal Desai c8b19894bb Revert "additional-whitelist"
This reverts commit ac8e123815.
2020-01-28 08:52:29 -08:00
cvgw ac8e123815 additional-whitelist
* update readme
* improve test
* change default
2020-01-24 10:22:20 -08:00
Cole Wippern 72bfed1850 add option additonal-whitelist
Add a new option additonal-whitelist which defaults
to a single entry, "/var/run". This will allow users to
remove "/var/run" from the whitelist or retain the current
behavior with no change.
2020-01-23 16:50:33 -08:00
Yoan Blanc 3678b70239
Merge remote-tracking branch 'origin/master' into registry-mirror 2019-12-22 11:10:15 +01:00
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
Yoan Blanc 980c87ac17
Merge remote-tracking branch 'origin/master' into registry-mirror 2019-12-05 19:12:47 +01:00
Yoan Blanc 3873aa05e3
root: add --registry-mirror flag
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2019-10-25 11:34:49 +02: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
Priya Wadhwa 1db7fc2a61 Rebased 2018-08-30 10:16:08 -07:00
Sebastian Jackel 1a7de69f3e Rename DockerInsecure field to InsecurePush 2018-08-30 09:36:12 +02:00
Sebastian Jackel 4ba6148621 Implement separation between Insecure (HTTP) registry and skipping TLS verification into two separate command line parameters 2018-08-30 09:34:31 +02:00
Priya Wadhwa 15db85e36a Configure logs to show colors 2018-08-29 16:08:09 -07:00
Priya Wadhwa 64a0b1d75f Added a KanikoStage type for each stage of a Dockerfile
I added a KanikoStage to hold each stage of the Dockerfile along with
information about each stage that would be useful later on.

The new KanikoStage type holds the stage itself, along with some
additional information:

1. FinalStage -- whether the current stage is the final stage
2. BaseImageStoredLocally/BaseImageIndex -- whether the base image for
this stage is stored locally, and if so what the index of the base image
is
3. SaveStage -- whether this stage needs to be saved for use in a future
stage

This is the first part of a larger refactor for building stages, which
will later make it easier to add layer caching.
2018-08-27 14:15:04 -07:00
Priya Wadhwa d867eadbb0 Review code comments; improved error messages for push 2018-08-23 14:27:13 -07:00
Priya Wadhwa cfa822f178 Refactor command line arguments and the executor
In this refactor I:

1. Created KanikoOptions to make it easier to pass around arguments
passed in through the command line
2. Reorganized executor.go by putting the logic for pushing the image in
a new file push.go
3. Made some error messages clearer
4. Fixed a mistake in the README for pushing to AWS
5. Marked the --bucket flag as hidden since we want people to use
--context instead, and marked an aws flag as hidden which is set in a
vendored directorya
2018-08-23 13:30:36 -07:00
David McKay 4535039be9
Add Flag to Disable Push to Container Registry
The flag, `--no-push`, is added to allow building a container image
without pushing to a container registry. It can be common, especially
with multi-stage builds and `--target`, to build enough to run the tests,
and then perform a push in a separate CI step. This will facilitate these
workflows.
2018-08-17 17:49:47 +01:00
Guilherme Rezende 60bdda4c49 Add support for insecure registry (#169) 2018-08-15 11:28:16 -07:00
priyawadhwa cac00b9cb2
Add --target flag for multistage builds (#255)
* Add --target flag for multistage builds

* change validate to validateTarget
2018-07-30 09:43:23 -07:00