Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit a90ce14

Browse files
author
Priya Wadhwa
committed
Fixed merge conflicts, support multistage builds
2 parents cf713fe + 904575d commit a90ce14

1,011 files changed

Lines changed: 5579 additions & 141654 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Gopkg.lock

Lines changed: 23 additions & 331 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
revision = "83389a148052d74ac602f5f1d62f86ff2f3c4aa5"
1919
source = "github.com/docker/distribution"
2020

21-
[[constraint]]
22-
name = "github.com/GoogleContainerTools/container-diff"
23-
branch = "master"
24-
source = "github.com/GoogleContainerTools/container-diff"
25-
2621
[[constraint]]
2722
name = "github.com/docker/docker"
2823
revision = "b1a1234c60cf87048814aa37da523b03a7b0d344"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test: out/executor
4747
@ ./test.sh
4848

4949
.PHONY: integration-test
50-
integration-test: out/executor
50+
integration-test:
5151
@ ./integration-test.sh
5252

5353
.PHONY: images

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ Please let us know if you have any feature requests or find any bugs!
1010

1111

1212
- [Kaniko](#kaniko)
13-
- [How does kaniko work?](#how-does-kaniko-work?)
13+
- [How does kaniko work?](#how-does-kaniko-work)
1414
- [Known Issues](#known-issues)
1515
- [Development](#development)
1616
- [kaniko Build Contexts](#kaniko-build-contexts)
1717
- [Running kaniko in a Kubernetes cluster](#running-kaniko-in-a-kubernetes-cluster)
1818
- [Running kaniko in Google Container Builder](#running-kaniko-in-google-container-builder)
1919
- [Running kaniko locally](#running-kaniko-locally)
2020
- [Pushing to Different Registries](#pushing-to-different-registries)
21+
- [Debug Image](#debug-image)
2122
- [Security](#security)
2223
- [Comparison with Other Tools](#comparison-with-other-tools)
2324
- [Community](#community)
@@ -40,6 +41,8 @@ The majority of Dockerfile commands can be executed with kaniko, but we're still
4041

4142
Multi-Stage Dockerfiles are also unsupported currently, but will be ready soon.
4243

44+
kaniko also does not support building Windows containers.
45+
4346
## Development
4447
### kaniko Build Contexts
4548
kaniko supports local directories and GCS buckets as build contexts. To specify a local directory, pass in the `--context` flag as an argument to the executor image.
@@ -143,6 +146,10 @@ kaniko uses Docker credential helpers to push images to a registry.
143146

144147
kaniko comes with support for GCR, but configuring another credential helper should allow pushing to a different registry.
145148

149+
### Debug Image
150+
151+
We provide `gcr.io/kaniko-project/executor:debug` as a a version of the executor image based off a Debian image.
152+
This provides a shell and can be useful for debugging.
146153

147154
## Security
148155

cmd/executor/cmd/root.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,19 @@ import (
2525

2626
"github.com/GoogleContainerTools/kaniko/pkg/constants"
2727
"github.com/GoogleContainerTools/kaniko/pkg/executor"
28-
"github.com/GoogleContainerTools/kaniko/pkg/image"
2928
"github.com/GoogleContainerTools/kaniko/pkg/util"
3029
"github.com/sirupsen/logrus"
3130
"github.com/spf13/cobra"
3231
)
3332

3433
var (
35-
dockerfilePath string
36-
destination string
37-
srcContext string
38-
snapshotMode string
39-
bucket string
40-
dockerInsecureSkipTLSVerify bool
41-
logLevel string
42-
force bool
34+
dockerfilePath string
35+
destination string
36+
srcContext string
37+
snapshotMode string
38+
bucket string
39+
logLevel string
40+
force bool
4341
)
4442

4543
func init() {
@@ -48,7 +46,6 @@ func init() {
4846
RootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "", "Name of the GCS bucket from which to access build context as tarball.")
4947
RootCmd.PersistentFlags().StringVarP(&destination, "destination", "d", "", "Registry the final image should be pushed to (ex: gcr.io/test/example:latest)")
5048
RootCmd.PersistentFlags().StringVarP(&snapshotMode, "snapshotMode", "", "full", "Set this flag to change the file attributes inspected during snapshotting")
51-
RootCmd.PersistentFlags().BoolVarP(&dockerInsecureSkipTLSVerify, "insecure-skip-tls-verify", "", false, "Push to insecure registry ignoring TLS verify")
5249
RootCmd.PersistentFlags().StringVarP(&logLevel, "verbosity", "v", constants.DefaultLogLevel, "Log level (debug, info, warn, error, fatal, panic")
5350
RootCmd.PersistentFlags().BoolVarP(&force, "force", "", false, "Force building outside of a container")
5451
}
@@ -72,12 +69,16 @@ var RootCmd = &cobra.Command{
7269
}
7370
logrus.Warn("kaniko is being run outside of a container. This can have dangerous effects on your system")
7471
}
75-
buildImage, err := executor.DoBuild(dockerfilePath, srcContext, snapshotMode)
72+
if err := os.Chdir("/"); err != nil {
73+
logrus.Error(err)
74+
os.Exit(1)
75+
}
76+
ref, image, err := executor.DoBuild(dockerfilePath, srcContext, snapshotMode)
7677
if err != nil {
7778
logrus.Error(err)
7879
os.Exit(1)
7980
}
80-
if err := image.PushImage(buildImage, destination, dockerInsecureSkipTLSVerify); err != nil {
81+
if err := executor.DoPush(ref, image, destination); err != nil {
8182
logrus.Error(err)
8283
os.Exit(1)
8384
}

deploy/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
# Builds the static Go image to execute in a Kubernetes job
1616

1717
FROM scratch
18-
ADD out/executor /kaniko/executor
19-
ADD files/ca-certificates.crt /kaniko/ssl/certs/
20-
ADD files/docker-credential-gcr /usr/local/bin/
21-
ADD files/config.json /root/.docker/
18+
COPY out/executor /kaniko/executor
19+
COPY files/ca-certificates.crt /kaniko/ssl/certs/
20+
COPY files/docker-credential-gcr /usr/local/bin/
21+
COPY files/config.json /root/.docker/
2222
RUN ["docker-credential-gcr", "config", "--token-source=env"]
2323
ENV HOME /root
24+
ENV USER /root
2425
ENV PATH /usr/local/bin
2526
ENV SSL_CERT_DIR=/kaniko/ssl/certs
2627
ENTRYPOINT ["/kaniko/executor"]

deploy/Dockerfile_debug

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2018 Google, Inc. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Builds the executor from debian
16+
17+
FROM gcr.io/google-appengine/debian9:latest
18+
COPY out/executor /kaniko/executor
19+
COPY files/ca-certificates.crt /kaniko/ssl/certs/
20+
COPY files/docker-credential-gcr /usr/local/bin/
21+
COPY files/config.json /root/.docker/
22+
RUN ["docker-credential-gcr", "config", "--token-source=env"]
23+
ENV HOME /root
24+
ENV SSL_CERT_DIR=/kaniko/ssl/certs
25+
ENTRYPOINT ["/kaniko/executor"]

deploy/executor-release.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ steps:
1818
path: "/usr/bin"
1919
dir: go/src/github.com/GoogleContainerTools/kaniko
2020
env: ["GOPATH=/workspace/go/"]
21-
# Then, build kaniko with kaniko
22-
- name: "gcr.io/kaniko-project/executor:latest"
23-
args: ["--dockerfile=/workspace/deploy/Dockerfile",
24-
"--context=/workspace/go/src/github.com/GoogleContainerTools/kaniko/",
25-
"--destination=gcr.io/kaniko-project/executor:${COMMIT_SHA}"]
21+
# First, build kaniko
22+
- name: "gcr.io/cloud-builders/docker"
23+
args: ["build", "-f", "deploy/Dockerfile",
24+
"-t", "gcr.io/kaniko-project/executor:${COMMIT_SHA}", "."]
25+
dir: go/src/github.com/GoogleContainerTools/kaniko
26+
# Then, build kaniko:debug
27+
- name: "gcr.io/cloud-builders/docker"
28+
args: ["build", "-f", "deploy/Dockerfile_debug",
29+
"-t", "gcr.io/kaniko-project/executor:debug-${COMMIT_SHA}", "."]
30+
dir: go/src/github.com/GoogleContainerTools/kaniko
31+
images: ["gcr.io/kaniko-project/executor:${COMMIT_SHA}", "gcr.io/kaniko-project/executor:debug-${COMMIT_SHA}"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM busybox
2+
ADD context/tars /tmp/tars
3+
RUN mv /tmp/tars /foo

integration_tests/dockerfiles/Dockerfile_test_run

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414

1515
FROM gcr.io/google-appengine/debian9
1616
RUN echo "hey" > /etc/foo
17-
RUN apt-get update && apt-get install -y \
18-
bzr \
19-
cvs \
17+
RUN echo "baz" > /etc/baz
18+
RUN cp /etc/baz /etc/bar
19+
RUN rm /etc/baz

0 commit comments

Comments
 (0)