Commit Graph

576 Commits

Author SHA1 Message Date
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
priyawadhwa 539ddefcae
Merge pull request #476 from bobcatfish/contrib_updates
Add to contributing guide: standards and finding something to work
2018-12-05 11:34:30 -08:00
Christie Wilson 296f695370 Add to contributing guide: standards and finding something to work
Recently I wanted to give feedback on a commit message and I realized we
didn't have anything in our CONTRIBUTING.md about it!

Also added the section on finding issues b/c we'd really like to
encourage folks to get involved with Kaniko.

(This is based on `knative/build-pipeline`'s CONTRIBUTING.md:
https://github.com/knative/build-pipeline/blob/master/CONTRIBUTING.md)
2018-12-03 11:23:54 -08:00
priyawadhwa 0b7fa58ca2
Merge pull request #459 from aduong/symlinks
Overwrite existing dest when copying symlink and preserve link target
2018-11-30 09:28:26 -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
Nándor István Krácser a49fd79e0e Fix --cleanup description (#467) 2018-11-27 12:53:40 -08:00
priyawadhwa d1a7d5c97f
Merge pull request #470 from priyawadhwa/remove-dockerignore
Remove support for .dockerignore
2018-11-26 17:03:42 -05:00
Priya Wadhwa e7faec5f0a Skip .dockerignore test 2018-11-26 11:50:57 -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
Achilleas Pipinellis 097ccb67a7 Cleanup readme (#386)
- Add newlines after headings and remove whitespace
- Use doctoc to update the Table of Contents
- Get additional flags in alphabetical order
2018-11-21 08:59:20 -06:00
priyawadhwa ade42d9105
Merge pull request #461 from priyawadhwa/etc-bug
Only return filepath.SkipDir for directories
2018-11-19 22:15:26 -08:00
priyawadhwa a7599d1563
Merge pull request #456 from priyawadhwa/composer
Fix bug in extracting hardlinks in multistage builds
2018-11-19 22:15:12 -08:00
Priya Wadhwa 2a359f547c Only return filepath.SkipDir for directories
From the docs on filepath.SkipDir:

> If the function returns SkipDir when invoked on a non-directory file, Walk skips the remaining files in the containing directory

This was causing the bug in #457. Since the file `/etc/hosts` was in the whitelist, when filepath.SkipDir was called the entire etc directory was skipped.

This change only returns filepath.SkipDir on directories.
2018-11-19 15:56:11 -05:00
Priya Wadhwa acd45dc894 fixed digests for integration test 2018-11-19 15:26:02 -05:00
Priya Wadhwa edd873d1fe remove unnecessary filepath.Join since dest is always an absolute path 2018-11-19 15:07:56 -05:00
Priya Wadhwa 2cf6f52517 Fix hardlink unit test
Now that hardlink destinations take into account the directory that they are being extracted to, the unit test had to be updated to make sure that two hardlinks were extracted to /tmp/hardlink correctly.
2018-11-19 15:03:31 -05:00
Adrian Duong f23cc32c42 Overwrite existing dest when copying symlink and preserve link target 2018-11-17 23:06:34 -08:00
Adrian Duong 3367268ef9 Test for fs_util.CopySymlink 2018-11-17 23:05:52 -08:00
Priya Wadhwa 9d67953ed3 Fix bug in extracting hardlinks
When we execute multistage builds, we store the fs of each intermediate
stage at /kaniko/<stage number> if it's used later in the build. This
created a bug when extracting hardlinks, because we weren't appending
the new directory to the link path.

So, if `/tmp/file1` and `/tmp/file2` were hardlinked, kaniko was trying
to link `/kaniko/0/tmp/file1` to `/tmp/file2` instead of
`/kaniko/0/tmp/file2`. This change will append the correct directory to
the link, and fixes #437 #362 #352 #342.
2018-11-16 16:18:49 -08:00
dlorenc 0c294138b8
Make snapshotting faster by using filepath.SkipDir. (#451)
filepath.Walk has a special error you can return from your walkFn
indicating it should skip directories. This change makes use of that
to skip whitelisted directories.
2018-11-14 17:44:38 -06:00
priyawadhwa f99e5f5c6d
Merge pull request #447 from priyawadhwa/maintainer
Check if command is nil before optimizing
2018-11-13 10:36:17 -08:00
Priya Wadhwa 5df363a0f6 Check if command is nil before optimizing
MAINTAINER returns nil since it's deprecated, so we should make sure we
don't add to the list of commands to optimize.
2018-11-13 10:12:03 -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
dlorenc 8408c53aa8
Improve cache layer uploads. (#443)
This change only uploads layers that were created from cache misses on RUN commands.
It also improves the cache-checking logic to handle this case.
Finally, it makes cache layer uploads happen in parallel with the rest of the build, logging
a warning if any fail.
2018-11-12 16:22:04 -06:00
dlorenc 063663e17b
Skip unpacking the base FS if there are no run commands (or only cached ones). (#440)
This is the final part of an optimization that I've been refactoring towards for awhile.
If the Dockerfile consists of no RUN commands, or cached RUN commands, followed by metadata-only
operations, we can skip downloading and unpacking the base image.
2018-11-12 12:51:45 -06:00
dlorenc 58b607b4d0
Fix caching for multi-step builds. (#441)
This change fixes that by properly "replaying" the Dockerfile and mutating the config when
calculating cache keys. Previously we were looking at the wrong cache key for each command
when there was more than one.
2018-11-09 12:28:18 -06:00
priyawadhwa d97790119a
Merge pull request #436 from priyawadhwa/release
Update CHANGELOG and Makefile for v0.6.0
2018-11-06 17:40:38 -08:00
Priya Wadhwa 80bbb56255 Update changelog and makefile for v0.6.0 2018-11-06 15:44:02 -08:00
Sharif Elgamal 224b7e2b41
parse arg commands at the top of dockerfiles (#404)
* parse arg commands at the top of dockerfiles

* fix pointer reference bug and remove debugging

* fixing tests

* account for meta args with no value

* don't take fs snapshot if / is the only changed path

* move metaArgs inside KanikoStage

* removing unused property

* check for any directory instead of just /

* remove unnecessary check
2018-11-06 15:27:09 -08:00
Carlos Sanchez 5ed45ed2fb Preserve options when doing a cache push (#423)
* Preserve options when doing a cache push

Otherwise options like `insecure` are lost

* Do not override original object
2018-11-06 15:44:44 -06:00
dlorenc fc43e218f0
Buffer layers to disk as they are created. (#428)
When building Docker images, layers were previously stored in memory.
This caused obvious issues when manipulating large layers, which could
cause Kaniko to crash.
2018-11-06 09:26:54 -06:00
dlorenc 52a6ce6685
More cache cleanups: (#397)
- move the layer cache to an interface
- refactor the DockerCommand implementations to support Cached and non-cached implementations.
2018-11-01 09:11:21 -07:00
priyawadhwa 7afb11cdf7
Merge pull request #424 from priyawadhwa/dockerignore
Fix bugs with .dockerignore and improve integration test
2018-10-31 14:16:17 -07:00
Sharif Elgamal 3c100508b6
adding documentation for base image caching (#421)
* adding documentation for base image caching

* add --cache-repo to list of params
2018-10-31 13:33:24 -07: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
priyawadhwa e0a24ee88a
Merge pull request #420 from priyawadhwa/vend
Update go-containerregistry
2018-10-30 10:39:28 -07:00
priyawadhwa 8e20cc6f43
Merge pull request #419 from priyawadhwa/readme
Update README
2018-10-29 14:04:57 -07:00
Priya Wadhwa 9a1a2ef9e3 Update go-containerregistry
Update go-containerregistry to merge in this
[PR](https://github.com/google/go-containerregistry/pull/293) and fix
2018-10-29 13:44:11 -07:00
Sharif Elgamal ede93786a1
fix releasing the cache warmer (#418) 2018-10-29 12:02:40 -07:00
Priya Wadhwa bf9f13b045 Update README
Updated README to clarify:

1. What a build context is and how kaniko interacts with it
2. How to set up a Kubernetes secret for auth to push the final image

Also made some general fixes to make the docs and the run_in_docker
script more clearer.
2018-10-29 11:45:06 -07:00
priyawadhwa 632bedf75c
Merge pull request #413 from priyawadhwa/auth
Use remoteImage function when getting digest for cache
2018-10-29 10:39:58 -07:00
priyawadhwa 458152910a
Merge pull request #409 from dtaniwaki/insecure-pull
Separate Insecure Pull Options
2018-10-26 15:00:27 -07:00
priyawadhwa 1996bf810a
Merge pull request #415 from j0shua/master
adding exit 1 when there are not enough command line vars passed to `…
2018-10-26 14:23:53 -07:00
priyawadhwa 5d731d3430
Merge pull request #414 from GoogleContainerTools/ImJasonH-patch-1
"Container Builder" - > "Cloud Build"
2018-10-26 14:13:17 -07:00
j0shua f1dfc2c685 adding exit 1 when there are not enough command line vars passed to `run in docker` script 2018-10-26 16:47:50 -04:00
Jason Hall b8c1314b39
"Container Builder" - > "Cloud Build" 2018-10-26 16:44:18 -04:00
Priya Wadhwa 9908eeb30a Use remoteImage function when getting digest for cache
Issue #410 experienced an error with base image caching where they were
"Not Authorized" to get information for a remote image, but later were
able to download and extract the base image.

To fix this, we can switch to using the remoteImage function for getting
information about the digest, which is the same function used for
downloading base images. This way we can also take advantage of the
--insecure and --skip-tls-verify flags if users pass those in when
trying to get digests for the cache as well.
2018-10-26 11:38:32 -07:00