diff --git a/.drone.yml b/.drone.yml index 37df2df..67e5332 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,6 +15,7 @@ steps: repo: plugins/kaniko auto_tag: true auto_tag_suffix: linux-amd64 + daemon_off: false dockerfile: docker/docker/Dockerfile.linux.amd64 username: from_secret: docker_username @@ -22,8 +23,8 @@ steps: from_secret: docker_password when: event: - - push - - tag + exclude: + - pull_request - name: gcr image: plugins/docker @@ -31,6 +32,7 @@ steps: repo: plugins/kaniko-gcr auto_tag: true auto_tag_suffix: linux-amd64 + daemon_off: false dockerfile: docker/gcr/Dockerfile.linux.amd64 username: from_secret: docker_username @@ -38,8 +40,8 @@ steps: from_secret: docker_password when: event: - - push - - tag + exclude: + - pull_request - name: ecr image: plugins/docker @@ -47,6 +49,7 @@ steps: repo: plugins/kaniko-ecr auto_tag: true auto_tag_suffix: linux-amd64 + daemon_off: false dockerfile: docker/ecr/Dockerfile.linux.amd64 username: from_secret: docker_username @@ -54,5 +57,5 @@ steps: from_secret: docker_password when: event: - - push - - tag \ No newline at end of file + exclude: + - pull_request \ No newline at end of file diff --git a/README.md b/README.md index ff8368a..3715593 100644 --- a/README.md +++ b/README.md @@ -49,5 +49,5 @@ docker run --rm \ -e PLUGIN_PASSWORD=bar \ -v $(pwd):/drone \ -w /drone \ - plugins/kaniko-docker + plugins/kaniko:linux-amd64 ``` diff --git a/cmd/kaniko-docker/main.go b/cmd/kaniko-docker/main.go index 9b0776f..6f53c8c 100644 --- a/cmd/kaniko-docker/main.go +++ b/cmd/kaniko-docker/main.go @@ -94,11 +94,16 @@ func main() { Usage: "docker password", EnvVar: "PLUGIN_PASSWORD", }, - cli.BoolFlag { - Name: "skip-tls-verify", - Usage: "Skip registry tls verify", + cli.BoolFlag{ + Name: "skip-tls-verify", + Usage: "Skip registry tls verify", EnvVar: "PLUGIN_SKIP_TLS_VERIFY", }, + cli.StringFlag{ + Name: "snapshot-mode", + Usage: "Specify one of full, redo or time as snapshot mode", + EnvVar: "PLUGIN_SNAPSHOT_MODE", + }, } if err := app.Run(os.Args); err != nil { @@ -114,14 +119,15 @@ func run(c *cli.Context) error { plugin := kaniko.Plugin{ Build: kaniko.Build{ - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - Args: c.StringSlice("args"), - Target: c.String("target"), - Repo: c.String("repo"), - Labels: c.StringSlice("custom-labels"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + Args: c.StringSlice("args"), + Target: c.String("target"), + Repo: c.String("repo"), + Labels: c.StringSlice("custom-labels"), SkipTlsVerify: c.Bool("skip-tls-verify"), + SnapshotMode: c.String("snapshot-mode"), }, } return plugin.Exec() diff --git a/cmd/kaniko-ecr/main.go b/cmd/kaniko-ecr/main.go index 89683e8..d150f17 100644 --- a/cmd/kaniko-ecr/main.go +++ b/cmd/kaniko-ecr/main.go @@ -89,6 +89,11 @@ func main() { Usage: "ECR secret key", EnvVar: "PLUGIN_SECRET_KEY", }, + cli.StringFlag{ + Name: "snapshot-mode", + Usage: "Specify one of full, redo or time as snapshot mode", + EnvVar: "PLUGIN_SNAPSHOT_MODE", + }, } if err := app.Run(os.Args); err != nil { @@ -104,13 +109,14 @@ func run(c *cli.Context) error { plugin := kaniko.Plugin{ Build: kaniko.Build{ - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - Args: c.StringSlice("args"), - Target: c.String("target"), - Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), - Labels: c.StringSlice("custom-labels"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + Args: c.StringSlice("args"), + Target: c.String("target"), + Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), + Labels: c.StringSlice("custom-labels"), + SnapshotMode: c.String("snapshot-mode"), }, } return plugin.Exec() diff --git a/cmd/kaniko-gcr/main.go b/cmd/kaniko-gcr/main.go index a7ec8a5..216c015 100644 --- a/cmd/kaniko-gcr/main.go +++ b/cmd/kaniko-gcr/main.go @@ -85,6 +85,11 @@ func main() { Usage: "docker username", EnvVar: "PLUGIN_JSON_KEY", }, + cli.StringFlag{ + Name: "snapshot-mode", + Usage: "Specify one of full, redo or time as snapshot mode", + EnvVar: "PLUGIN_SNAPSHOT_MODE", + }, } if err := app.Run(os.Args); err != nil { @@ -104,13 +109,14 @@ func run(c *cli.Context) error { plugin := kaniko.Plugin{ Build: kaniko.Build{ - Dockerfile: c.String("dockerfile"), - Context: c.String("context"), - Tags: c.StringSlice("tags"), - Args: c.StringSlice("args"), - Target: c.String("target"), - Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), - Labels: c.StringSlice("custom-labels"), + Dockerfile: c.String("dockerfile"), + Context: c.String("context"), + Tags: c.StringSlice("tags"), + Args: c.StringSlice("args"), + Target: c.String("target"), + Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")), + Labels: c.StringSlice("custom-labels"), + SnapshotMode: c.String("snapshot-mode"), }, } return plugin.Exec() diff --git a/kaniko.go b/kaniko.go index faf2357..3a13ce7 100644 --- a/kaniko.go +++ b/kaniko.go @@ -18,6 +18,7 @@ type ( Repo string // Docker build repository Labels []string // Label map SkipTlsVerify bool // Docker skip tls certificate verify for registry + SnapshotMode string // Kaniko snapshot mode } // Plugin defines the Docker plugin parameters. @@ -62,6 +63,10 @@ func (p Plugin) Exec() error { cmdArgs = append(cmdArgs, fmt.Sprintf("--skip-tls-verify=true")) } + if p.Build.SnapshotMode != "" { + cmdArgs = append(cmdArgs, fmt.Sprintf("--snapshotMode=%s", p.Build.SnapshotMode)) + } + cmd := exec.Command("/kaniko/executor", cmdArgs...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr