Commit Graph

264 Commits

Author SHA1 Message Date
Lukas 679c71c907
refactor: simpler local integration tests (#2110)
* tests(integration): add fake gcs server and use sdk instead of gsutil

* tests(integration): add flag to run tests for a subset of dockerfiles

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* tests(integration): conditionally create gcs client

* refactor: create package for gcs bucket interaction

* tests(integration): use util.Tar for integration tarball creation

* refactor: create TarballOfDirectory func

* chore: add dockerignore for faster builds

* docs: add docs for dockerfile pattern

* fix: issue during personal review

* chore: cleanup

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* fix(integration-tests): remove default bucket

Signed-off-by: Lukas Hoehl <ludi.origin@gmail.com>
2022-06-14 13:38:01 -04:00
Gabriel Nützi c13f9b6027
fix: Add test for issue #2049 (#2114)
- This missing files problem should be fixed by PR #2066.
2022-06-01 06:55:36 -04:00
Tony De La Nuez 77ac6942a6
Fix missing setuid flags on COPY --from=build operation (#2089)
* Fix missing file permissions on multi-stage build

Fixes #2075

When a file with the setuid bit is copied from one stage
to another, the permissions were not copied over properly after
setting ownership on directory and the file itself.

* Update pkg/util/fs_util.go

Co-authored-by: Jason Hall <jason@chainguard.dev>

* Adding boilerplate to dockerfile

* Add bash check to bail with exit code 1 if setuid not present

Co-authored-by: Jason Hall <jason@chainguard.dev>
2022-05-22 09:20:18 -04:00
Gabriel Nützi e22346d881
fix: `COPY --chown` regression tests (#2097) 2022-05-18 10:49:42 -04:00
Gabriel Nützi 2789b974b9
fix: Regression test for #2066 (#2096)
* fix: Regression test for #2066

- Test `Dockerfile_test_issue_2066` fails on main@28432d3c

* np: Comment
2022-05-18 06:35:35 -04:00
Gabriel Nützi 323e616a67
fix: Refactor `LayersMap` to correct old strange code behavior (#2066)
* fix: Correct flatten function in layers

- Added a test.
- Cache current image, track deletes in `whiteouts` as well as normal adds in `layers`.
- Fix ugly delete behavior of `layerHashCache`.
  Delete it when crerating a new snapshot.
- Slight cleanup in `snapshot.go`.
- Format ugly `WalkFS` function.

* fix: Add symbolic link changes  to Hasher and CacheHasher

* fix: Better log messages

* fix(ci): Integration tests

* fix(ci): Add `--no-cache` to docker builds

* fix(ci): Pass credentials for error integration test

* np: Missing .gitignore in `hack`

* np: Capitalize every log message

- Correct some linting.

* fix: Key function

- Merge only last layer onto `currentImage`.

* fix: Remove old obsolete `cacheHasher`
2022-05-17 20:30:58 -04:00
Gabriel Nützi 28432d3c84
fix(ci): Docker build for issue 1837 (#2095)
* fix: Docker build for issue 1837

* fix: Linting
2022-05-17 14:21:57 -04:00
Jack d4cf49077a
feat: kaniko dir config option (#1997)
* remove configurables from constants

* add configurables to config init

* add kaniko dir flag

* cleanup pkg constants

* replace buildcontext constants pkg occurrences with config

* add KanikoDir to KanikoOptions

* replace executor constants pkg occurrences with config

* remove redundant KanikoDir assignment

* replace constants to config for IntermediateStagesDir

* fix imports

* add default kaniko directory into constants

* add check for kanikoDir on use

* update init to use default path constant

* update executor kanikoDir check

Co-authored-by: Jason Hall <jasonhall@redhat.com>

* alter checkKanikoDir parameter

* add TestKanikoDir func

* update error handling style

Co-authored-by: Jason Hall <jasonhall@redhat.com>

* remove shorthand flag usage from test

Co-authored-by: Jason Hall <jasonhall@redhat.com>

* add docstring to integration test

Co-authored-by: Jason Hall <jasonhall@redhat.com>

* remove shorthand flag from kaniko-dir

Co-authored-by: Jason Hall <jasonhall@redhat.com>
2022-03-31 15:10:23 -04:00
Gabriel Nützi 2d94d56af7
Fix resolving arguments over multi-stage build (#1928)
* Fix resolving argument over mulit-stage build

- Building multi-stage Dockerfiles did not correctly resolve
  ARG commands over different stages. Now, each stage depends on the
  build arguments set by the stage before.

Closes: #1911

* Fix resolving empty arg commands
2022-02-10 09:22:21 -08:00
Jason Hall 76624697df
Bump github.com/docker/docker to latest release (#1866)
* Bump github.com/docker/docker to latest release

* Pin deps to docker/docker's requirements

fix build breakages
fix unit test
Trying to see whether am-i-in-a-container checks are broken for integration tests...
2022-01-14 15:58:32 -05:00
Jason Hall d587122a9d
Run GitHub Actions on pushes and PRs to main, not master (#1883)
* Run GitHub Actions on pushes and PRs to main, not master

* fix go install ecr-login, bump to latest v0.6.0

* master -> main in some integration tests

* skip no-ref integration test
2022-01-14 14:54:12 -05:00
Andrei Kvapil e38b0c8d90
Fix calculating path for copying ownership (#1859)
* Fix calculating path for copying ownership

* fix CI
2021-12-24 07:09:53 -05:00
Andrei Kvapil 7065921aa4
Fix copying ownership (#1725)
* fix uid, gid overriding

* fix ownership for staging building

* add integration test

* add check for ignored files

* improve errors
2021-12-23 13:25:55 -05:00
François JACQUES 5c81fa5774
Fixes #1837 : keep file capabilities on archival (#1838)
Signed-off-by: JACQUES Francois <hypnoce@donarproject.org>
2021-12-22 20:05:39 -05:00
Jason Hall 59c2d2d08f
Collapse integration test workflows into one config (#1855)
* Collapse integration test workflows into one config

Remove last traces of Travis, including env vars and `make travis-setup`
and badges in README

* fix lint

* make integration tests pass on PRs
2021-12-22 20:04:40 -05:00
Jason Hall b1b6962726
Share the Go build cache when building in Dockerfiles (#1853)
On my machine this makes image rebuilds go from ~5m to 1.5s.

This also required setting DOCKER_BUILDKIT=1 in integration test image
builds.

I also took the opportunity to bump the Go version used in those tests
to Go 1.17 to match the image build processes, and tidied up the
workflow files a bit too (renaming for consistency, typos, whitespace,
etc.)
2021-12-22 12:43:12 -05:00
Matt Moore 49f0154b3f
Fix the e2e K8s test (#1842)
* Debugging the integration testing.

It seems to be consistently failing (also fix a typo in the file/leg name).

I'm disabling `-v` for `go test` because it interleaves the test output in ways that make it painful to read a single failing test's output when `t.Parallel` is involved.

* Try swapping registry:2 for the registry add-on

* Drop logf and make Logger private
2021-12-17 14:43:38 -05:00
Tejal Desai ee31dc93b6
Revert "Support mirror registries with path component (#1707)" (#1794)
* Revert "Support mirror registries with path component (#1707)"

This reverts commit 4e218f2162.

* fix tests and add co-sign back
2021-10-20 19:13:24 -07:00
wwade 82fc94d930
git: accept explicit commit hash for git context (#1765)
* git: accept explicit commit hash for git context

When checking out code from non-github repositories, the typical
assumptions may not be valid, e.g. that the only interesting
non-branch commits have ref names starting with refs/pull. A specific
example is fetching an un-merged commit from a gerrit repository by
commit hash.

This change just looks at the second part of the git context path and
checks if it's a SHA commit hash, and if so, will fetch and check out
this commit after cloning the repository.

Sample context argument:

    https://github.repo/project#e1772f228e06d15facdf175e5385e265b57068c0

* ci: fix test script to recognize any non-zero exit as an error

hack/linter.sh didn't properly install golangci-lint in hack/bin as I
already have another version of golangci-lint on my PATH, but then it
failed to execute because it was looking for it specifically in
hack/bin.

When the executable is not found, the exit code is 127 instead of 1,
and so test.sh ignored the error.

Two fixes:

1. `test.sh`:
  - Use `if (script) ...` instead of assigning / checking a result
    variable to determine if each validation script passed or failed.

2. `hack/linter.sh`:
  - Instead of checking for golangci-lint on the path, just
    specifically check for an executable file (`test -x`) in the
    expected location.

Co-authored-by: Wade Carpenter <wwade@users.noreply.github.com>
2021-10-19 19:27:15 -07:00
Gilbert Gilb's a42adb9bb4
Fix composite cache key for multi-stage copy command (#1735)
* chore: add workflows for pr tests

* fix unit tests

* fix formatting

* chore: fix gobuild

* change minikube script

* chore: fix lint install script

* chore: ignore and fix tests

* fix lint and run gofmt

* lint fixes

* k8s executor image only

* fix Makefile

* fix travis env variables

* more info on k8s tests

* fix travis run

* fix

* fix

* fix

* fix log

* some more changes

* increase timeout

* delete travis.yml and fix multiple copy tests

* fix registry mirror

* fix lint

* add concurency

* last attemot to fix k8 integrations

* diff id for diff workflows

* Fix composite cache key for multi-stage copy command (#1706)

PR #1518 reintroduced COPY layers caching using the `--cache-copy-layers`
flag. Unfortunately, this PR also introduced a bug by not including the
stage digest into the caching key of the COPY command when the
`--cache-copy-layers` flag was not set. As a result, kaniko would use
any previous (possibly stalled) layer from the cache because the digest
of the "COPY --from" command would never change.

PR author probably expected Go to fallthrough in the switch just like C
does. However, this is not the case. Go does not fallthrough in
switch-statements by default and requires the fallthrough keyword to be
used. Note that this keyword is not available in type-switches though,
because it wouldn't work properly with typings.

* refactor: add an abstract copy command interface to avoid code duplication

* fix typo in error message

Co-authored-by: Tejal Desai <tejal29@gmail.com>
2021-10-18 23:31:01 -07:00
Tejal Desai 1da17b6e9b
chore: add workflows for pr tests (#1766)
* chore: add workflows for pr tests

* fix unit tests

* fix formatting

* chore: fix gobuild

* change minikube script

* chore: fix lint install script

* chore: ignore and fix tests

* fix lint and run gofmt

* lint fixes

* k8s executor image only

* fix Makefile

* fix travis env variables

* more info on k8s tests

* fix travis run

* fix

* fix

* fix

* fix log

* some more changes

* increase timeout

* delete travis.yml and fix multiple copy tests

* fix registry mirror

* fix lint

* add concurency

* last attemot to fix k8 integrations

* diff id for diff workflows
2021-10-18 23:22:44 -07:00
Kamal Nasser f21639daac
Fix snapshotter ignore list; do not attempt to delete whiteouts of ignored paths (#1652)
* avoid deleting whiteouts if they are in ignore list

* fix snapshotter ignore list

* include filesystem mounts in ignorelist of snapshotter
* clean up ignore list logic

* add unit and integration tests for #1652

* fix tests and ignore list updates
2021-06-04 10:07:24 -07:00
Benjamin Krenn 57ea150cad
Exit Code Propagation (#1655)
* exit codes of failed RUN commands may now be propagated to the caller by using the --propagate-exit-code flag

* removed exit code propagation flag; the exit function now unwraps the error and looks for an exit code

* added integration test for exit code propagation

* added trailing new line in test Dockerfile_exit_code_propagation; tidying up README.md removing all traces of error propagation flag

* moved exit code propagation test to integration_test.go; moved exit code propagation test files to 'testdata' to avoid interference with other integration tests
2021-06-01 10:43:49 -07:00
Matt Moore 1ad4295462
Update ggcr to pick up estargz and caching option (#1527) 2020-12-21 10:09:21 -08:00
Tejal Desai b04399eeac
add caching copy layers back (#1518)
* add caching copy layers back

* fix test

* lint

* fix test - 2

* Add integration test

* fix lint
2020-12-11 00:25:03 -08:00
Vincent Behar 131828a1ad
feat: support multiple registry mirrors with fallback (#1498)
Fixes #1473

The initial implementation of the registry mirror only allowed a single mirror, and if pulling from the mirror failed, the build would fail.

This change introduces:
- multiple registry mirrors instead of a single one
- fallback if an image can't be pulled from a registry

This is the same behavior as the docker daemon and will allow using a registry mirror such as `mirror.gcr.io` which is incomplete and doesn't have all the content that the default registry on docker.io has.

Note that there are no changes in the CLI flags, the `--registry-mirror` flag is still valid. But now it can be used multiple times to set up more than one registry mirror.

Co-authored-by: Tejal Desai <tejaldesai@google.com>
2020-12-08 16:16:25 -08: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
Yoan Blanc 5412ac65da
fixup! fixup! fixup! add should fail on 40x
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-06-20 10:46:41 +02:00
Yoan Blanc 999365f5f9
fixup! fixup! add should fail on 40x
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-06-20 10:42:59 +02:00
Yoan Blanc 8cc772ae9c
fixup! add should fail on 40x
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-06-20 10:15:50 +02:00
Yoan Blanc ca23ae441e
add should fail on 40x
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
2020-06-20 09:49:11 +02:00
Tejal Desai 4ac51ef515 merge 2020-06-06 20:17:17 -07:00
Tejal Desai 35d2358482 add integration tests 2020-06-06 00:53:08 -07:00
Tejal Desai 2a7d33526b lint 2020-06-06 00:30:07 -07:00
Tejal Desai 0f5387960e minimal changes 2020-06-06 00:16:14 -07:00
Tejal Desai 01c3a1bcf3 mend 2020-06-05 23:47:31 -07:00
Tejal Desai 58276274e8 better improvements 2020-06-05 23:44:17 -07:00
Tejal Desai 43338d4b2f add a new run command along with a new flag 2020-06-05 19:53:16 -07:00
Tejal Desai 57818cfb79 lint 2020-06-05 16:49:28 -07:00
Tejal Desai ba00c9fb7d add benchmarking for gcb 2020-06-05 15:10:28 -07:00
Tejal Desai 95a8ecc200 fix lint 2020-06-05 14:58:36 -07:00
Tejal Desai 66c8266627 remove private buckets 2020-06-05 13:58:30 -07:00
Tejal Desai 6ab97e2b5f ADD GCB benchmark code 2020-06-05 12:46:47 -07:00
Tejal Desai 92a5c89b97
update year in license. 2020-06-04 15:12:57 -07:00
Tejal Desai 18dbb0e12a add biolerplate 2020-06-04 15:11:24 -07:00
Tejal Desai 85c40c45b3 fix dockerfile 2020-06-04 15:10:01 -07:00
Tejal Desai 9b48be6440 Merge branch 'master' into benchmark-snapshot 2020-06-04 13:02:04 -07:00
Tejal Desai 8074a70863
Merge pull request #1285 from antechrestos/fix/image_argument_name
Added integration test for multi level argument
2020-06-04 12:04:06 -07:00
Tejal Desai 994a412d0b some more renames 2020-06-02 16:08:46 -07:00