mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-13 10:31:35 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b708f2c84c | |||
| 0933926fe2 | |||
| 658478d5ae | |||
| 9cca954ec6 | |||
| 3e4dad8cae |
+63
-6
@@ -15,6 +15,7 @@ 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
|
||||||
@@ -22,8 +23,8 @@ steps:
|
|||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
exclude:
|
||||||
- tag
|
- pull_request
|
||||||
|
|
||||||
- name: gcr
|
- name: gcr
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
@@ -31,6 +32,7 @@ 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
|
||||||
@@ -38,8 +40,8 @@ steps:
|
|||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
exclude:
|
||||||
- tag
|
- pull_request
|
||||||
|
|
||||||
- name: ecr
|
- name: ecr
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
@@ -47,6 +49,7 @@ 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
|
||||||
@@ -54,5 +57,59 @@ steps:
|
|||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
- push
|
exclude:
|
||||||
- tag
|
- pull_request
|
||||||
|
|
||||||
|
---
|
||||||
|
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-docker
|
plugins/kaniko:linux-amd64
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -94,6 +94,31 @@ 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 {
|
||||||
@@ -109,13 +134,18 @@ 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"),
|
||||||
|
EnableCache: c.Bool("enable-cache"),
|
||||||
|
CacheRepo: c.String("cache-repo"),
|
||||||
|
CacheTTL: c.Int("cache-ttl"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
|
|||||||
+31
-7
@@ -89,6 +89,26 @@ 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 {
|
||||||
@@ -104,13 +124,17 @@ 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"),
|
||||||
|
EnableCache: c.Bool("enable-cache"),
|
||||||
|
CacheRepo: c.String("cache-repo"),
|
||||||
|
CacheTTL: c.Int("cache-ttl"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
|
|||||||
+31
-7
@@ -85,6 +85,26 @@ 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 {
|
||||||
@@ -104,13 +124,17 @@ 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"),
|
||||||
|
EnableCache: c.Bool("enable-cache"),
|
||||||
|
CacheRepo: c.String("cache-repo"),
|
||||||
|
CacheTTL: c.Int("cache-ttl"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
|
|||||||
@@ -10,13 +10,18 @@ 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.
|
||||||
@@ -57,6 +62,26 @@ 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