mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-16 14:49:02 +08:00
Compare commits
1 Commits
cache
..
test_kaniko
| Author | SHA1 | Date | |
|---|---|---|---|
| 55bcc90781 |
+6
-63
@@ -15,7 +15,6 @@ steps:
|
|||||||
repo: plugins/kaniko
|
repo: plugins/kaniko
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-amd64
|
auto_tag_suffix: linux-amd64
|
||||||
daemon_off: false
|
|
||||||
dockerfile: docker/docker/Dockerfile.linux.amd64
|
dockerfile: docker/docker/Dockerfile.linux.amd64
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
@@ -23,8 +22,8 @@ steps:
|
|||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
exclude:
|
- push
|
||||||
- pull_request
|
- tag
|
||||||
|
|
||||||
- name: gcr
|
- name: gcr
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
@@ -32,7 +31,6 @@ steps:
|
|||||||
repo: plugins/kaniko-gcr
|
repo: plugins/kaniko-gcr
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-amd64
|
auto_tag_suffix: linux-amd64
|
||||||
daemon_off: false
|
|
||||||
dockerfile: docker/gcr/Dockerfile.linux.amd64
|
dockerfile: docker/gcr/Dockerfile.linux.amd64
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
@@ -40,8 +38,8 @@ steps:
|
|||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
exclude:
|
- push
|
||||||
- pull_request
|
- tag
|
||||||
|
|
||||||
- name: ecr
|
- name: ecr
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
@@ -49,7 +47,6 @@ steps:
|
|||||||
repo: plugins/kaniko-ecr
|
repo: plugins/kaniko-ecr
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-amd64
|
auto_tag_suffix: linux-amd64
|
||||||
daemon_off: false
|
|
||||||
dockerfile: docker/ecr/Dockerfile.linux.amd64
|
dockerfile: docker/ecr/Dockerfile.linux.amd64
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
@@ -57,59 +54,5 @@ steps:
|
|||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
exclude:
|
- push
|
||||||
- pull_request
|
- tag
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: notifications-docker
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: manifest-docker
|
|
||||||
pull: always
|
|
||||||
image: plugins/manifest
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
ignore_missing: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
spec: docker/docker/manifest.tmpl
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
|
|
||||||
- name: manifest-gcr
|
|
||||||
pull: always
|
|
||||||
image: plugins/manifest
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
ignore_missing: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
spec: docker/gcr/manifest.tmpl
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
|
|
||||||
- name: manifest-ecr
|
|
||||||
pull: always
|
|
||||||
image: plugins/manifest
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
ignore_missing: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
spec: docker/ecr/manifest.tmpl
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- "refs/tags/**"
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- default
|
|
||||||
@@ -49,5 +49,5 @@ docker run --rm \
|
|||||||
-e PLUGIN_PASSWORD=bar \
|
-e PLUGIN_PASSWORD=bar \
|
||||||
-v $(pwd):/drone \
|
-v $(pwd):/drone \
|
||||||
-w /drone \
|
-w /drone \
|
||||||
plugins/kaniko:linux-amd64
|
plugins/kaniko-docker
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -94,31 +94,6 @@ func main() {
|
|||||||
Usage: "docker password",
|
Usage: "docker password",
|
||||||
EnvVar: "PLUGIN_PASSWORD",
|
EnvVar: "PLUGIN_PASSWORD",
|
||||||
},
|
},
|
||||||
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",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "enable-cache",
|
|
||||||
Usage: "Set this flag to opt into caching with kaniko",
|
|
||||||
EnvVar: "PLUGIN_ENABLE_CACHE",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "cache-repo",
|
|
||||||
Usage: "Remote repository that will be used to store cached layers. enable-cache needs to be set to use this flag",
|
|
||||||
EnvVar: "PLUGIN_CACHE_REPO",
|
|
||||||
},
|
|
||||||
cli.IntFlag{
|
|
||||||
Name: "cache-ttl",
|
|
||||||
Usage: "Cache timeout in hours. Defaults to two weeks.",
|
|
||||||
EnvVar: "PLUGIN_CACHE_TTL",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -134,15 +109,13 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
plugin := kaniko.Plugin{
|
plugin := kaniko.Plugin{
|
||||||
Build: kaniko.Build{
|
Build: kaniko.Build{
|
||||||
Dockerfile: c.String("dockerfile"),
|
Dockerfile: c.String("dockerfile"),
|
||||||
Context: c.String("context"),
|
Context: c.String("context"),
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
Args: c.StringSlice("args"),
|
Args: c.StringSlice("args"),
|
||||||
Target: c.String("target"),
|
Target: c.String("target"),
|
||||||
Repo: c.String("repo"),
|
Repo: c.String("repo"),
|
||||||
Labels: c.StringSlice("custom-labels"),
|
Labels: c.StringSlice("custom-labels"),
|
||||||
SkipTlsVerify: c.Bool("skip-tls-verify"),
|
|
||||||
SnapshotMode: c.String("snapshot-mode"),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
|
|||||||
+7
-28
@@ -89,26 +89,6 @@ func main() {
|
|||||||
Usage: "ECR secret key",
|
Usage: "ECR secret key",
|
||||||
EnvVar: "PLUGIN_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",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "enable-cache",
|
|
||||||
Usage: "Set this flag to opt into caching with kaniko",
|
|
||||||
EnvVar: "PLUGIN_ENABLE_CACHE",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "cache-repo",
|
|
||||||
Usage: "Remote repository that will be used to store cached layers. enable-cache needs to be set to use this flag",
|
|
||||||
EnvVar: "PLUGIN_CACHE_REPO",
|
|
||||||
},
|
|
||||||
cli.IntFlag{
|
|
||||||
Name: "cache-ttl",
|
|
||||||
Usage: "Cache timeout in hours. Defaults to two weeks.",
|
|
||||||
EnvVar: "PLUGIN_CACHE_TTL",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -124,14 +104,13 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
plugin := kaniko.Plugin{
|
plugin := kaniko.Plugin{
|
||||||
Build: kaniko.Build{
|
Build: kaniko.Build{
|
||||||
Dockerfile: c.String("dockerfile"),
|
Dockerfile: c.String("dockerfile"),
|
||||||
Context: c.String("context"),
|
Context: c.String("context"),
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
Args: c.StringSlice("args"),
|
Args: c.StringSlice("args"),
|
||||||
Target: c.String("target"),
|
Target: c.String("target"),
|
||||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||||
Labels: c.StringSlice("custom-labels"),
|
Labels: c.StringSlice("custom-labels"),
|
||||||
SnapshotMode: c.String("snapshot-mode"),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
|
|||||||
+7
-28
@@ -85,26 +85,6 @@ func main() {
|
|||||||
Usage: "docker username",
|
Usage: "docker username",
|
||||||
EnvVar: "PLUGIN_JSON_KEY",
|
EnvVar: "PLUGIN_JSON_KEY",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
|
||||||
Name: "snapshot-mode",
|
|
||||||
Usage: "Specify one of full, redo or time as snapshot mode",
|
|
||||||
EnvVar: "PLUGIN_SNAPSHOT_MODE",
|
|
||||||
},
|
|
||||||
cli.BoolFlag{
|
|
||||||
Name: "enable-cache",
|
|
||||||
Usage: "Set this flag to opt into caching with kaniko",
|
|
||||||
EnvVar: "PLUGIN_ENABLE_CACHE",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
|
||||||
Name: "cache-repo",
|
|
||||||
Usage: "Remote repository that will be used to store cached layers. enable-cache needs to be set to use this flag",
|
|
||||||
EnvVar: "PLUGIN_CACHE_REPO",
|
|
||||||
},
|
|
||||||
cli.IntFlag{
|
|
||||||
Name: "cache-ttl",
|
|
||||||
Usage: "Cache timeout in hours. Defaults to two weeks.",
|
|
||||||
EnvVar: "PLUGIN_CACHE_TTL",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -124,14 +104,13 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
plugin := kaniko.Plugin{
|
plugin := kaniko.Plugin{
|
||||||
Build: kaniko.Build{
|
Build: kaniko.Build{
|
||||||
Dockerfile: c.String("dockerfile"),
|
Dockerfile: c.String("dockerfile"),
|
||||||
Context: c.String("context"),
|
Context: c.String("context"),
|
||||||
Tags: c.StringSlice("tags"),
|
Tags: c.StringSlice("tags"),
|
||||||
Args: c.StringSlice("args"),
|
Args: c.StringSlice("args"),
|
||||||
Target: c.String("target"),
|
Target: c.String("target"),
|
||||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||||
Labels: c.StringSlice("custom-labels"),
|
Labels: c.StringSlice("custom-labels"),
|
||||||
SnapshotMode: c.String("snapshot-mode"),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
|
|||||||
@@ -10,18 +10,13 @@ import (
|
|||||||
type (
|
type (
|
||||||
// Build defines Docker build parameters.
|
// Build defines Docker build parameters.
|
||||||
Build struct {
|
Build struct {
|
||||||
Dockerfile string // Docker build Dockerfile
|
Dockerfile string // Docker build Dockerfile
|
||||||
Context string // Docker build context
|
Context string // Docker build context
|
||||||
Tags []string // Docker build tags
|
Tags []string // Docker build tags
|
||||||
Args []string // Docker build args
|
Args []string // Docker build args
|
||||||
Target string // Docker build target
|
Target string // Docker build target
|
||||||
Repo string // Docker build repository
|
Repo string // Docker build repository
|
||||||
Labels []string // Label map
|
Labels []string // Label map
|
||||||
SkipTlsVerify bool // Docker skip tls certificate verify for registry
|
|
||||||
SnapshotMode string // Kaniko snapshot mode
|
|
||||||
EnableCache bool // Whether to enable kaniko cache
|
|
||||||
CacheRepo string // Remote repository that will be used to store cached layers
|
|
||||||
CacheTTL int // Cache timeout in hours
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin defines the Docker plugin parameters.
|
// Plugin defines the Docker plugin parameters.
|
||||||
@@ -32,7 +27,7 @@ type (
|
|||||||
|
|
||||||
// Exec executes the plugin step
|
// Exec executes the plugin step
|
||||||
func (p Plugin) Exec() error {
|
func (p Plugin) Exec() error {
|
||||||
if p.Build.Repo == "" {
|
if p.Build.Repo == ""
|
||||||
return fmt.Errorf("repository name to publish image must be specified")
|
return fmt.Errorf("repository name to publish image must be specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,26 +57,6 @@ func (p Plugin) Exec() error {
|
|||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--target=%s", p.Build.Target))
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--target=%s", p.Build.Target))
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Build.SkipTlsVerify {
|
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--skip-tls-verify=true"))
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Build.SnapshotMode != "" {
|
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--snapshotMode=%s", p.Build.SnapshotMode))
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Build.EnableCache == true {
|
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache=true"))
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Build.CacheRepo != "" {
|
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-repo=%s", p.Build.CacheRepo))
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Build.CacheTTL != 0 {
|
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--cache-ttl=%d", p.Build.CacheTTL))
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command("/kaniko/executor", cmdArgs...)
|
cmd := exec.Command("/kaniko/executor", cmdArgs...)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|||||||
Reference in New Issue
Block a user