mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-14 22:11:18 +08:00
Compare commits
13 Commits
v1.6.9
...
smjt-h-patch-1
| Author | SHA1 | Date | |
|---|---|---|---|
| fe8ffb3a99 | |||
| 0dee97e338 | |||
| ed6f3c5bf4 | |||
| 4893b5b945 | |||
| 447ee28867 | |||
| 9c90e58a2d | |||
| d998c00a4b | |||
| 2f55e25020 | |||
| f3544ce6ee | |||
| e4cd992d8d | |||
| d457df687d | |||
| 4820b6af00 | |||
| 3717723366 |
+24
-25
@@ -77,14 +77,14 @@ steps:
|
|||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
- name: docker-kaniko-v1-8
|
- name: docker-kaniko-v1-9
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
repo: plugins/kaniko
|
repo: plugins/kaniko
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-amd64-kaniko1.8.1
|
auto_tag_suffix: linux-amd64-kaniko1.9.1
|
||||||
daemon_off: false
|
daemon_off: false
|
||||||
dockerfile: docker/docker/Dockerfile.linux.amd64.kaniko1.8.1
|
dockerfile: docker/docker/Dockerfile.linux.amd64.kaniko1.9.1
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
password:
|
password:
|
||||||
@@ -94,14 +94,14 @@ steps:
|
|||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
- name: gcr-kaniko-v1-8
|
- name: gcr-kaniko-v1-9
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
repo: plugins/kaniko-gcr
|
repo: plugins/kaniko-gcr
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-amd64-kaniko1.8.1
|
auto_tag_suffix: linux-amd64-kaniko1.9.1
|
||||||
daemon_off: false
|
daemon_off: false
|
||||||
dockerfile: docker/gcr/Dockerfile.linux.amd64.kaniko1.8.1
|
dockerfile: docker/gcr/Dockerfile.linux.amd64.kaniko1.9.1
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
password:
|
password:
|
||||||
@@ -112,14 +112,14 @@ steps:
|
|||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
|
|
||||||
- name: ecr-kaniko-v1-8
|
- name: ecr-kaniko-v1-9
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
repo: plugins/kaniko-ecr
|
repo: plugins/kaniko-ecr
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-amd64-kaniko1.8.1
|
auto_tag_suffix: linux-amd64-kaniko1.9.1
|
||||||
daemon_off: false
|
daemon_off: false
|
||||||
dockerfile: docker/ecr/Dockerfile.linux.amd64.kaniko1.8.1
|
dockerfile: docker/ecr/Dockerfile.linux.amd64.kaniko1.9.1
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
password:
|
password:
|
||||||
@@ -130,12 +130,11 @@ steps:
|
|||||||
- pull_request
|
- pull_request
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: vm
|
||||||
name: arm
|
name: arm
|
||||||
|
|
||||||
platform:
|
pool:
|
||||||
os: linux
|
use: ubuntu_arm64
|
||||||
arch: arm64
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
@@ -212,14 +211,14 @@ steps:
|
|||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
- name: docker-kaniko-v1-8
|
- name: docker-kaniko-v1-9
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
repo: plugins/kaniko
|
repo: plugins/kaniko
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-arm64-kaniko1.8.1
|
auto_tag_suffix: linux-arm64-kaniko1.9.1
|
||||||
daemon_off: false
|
daemon_off: false
|
||||||
dockerfile: docker/docker/Dockerfile.linux.arm64.kaniko1.8.1
|
dockerfile: docker/docker/Dockerfile.linux.arm64.kaniko1.9.1
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
password:
|
password:
|
||||||
@@ -229,14 +228,14 @@ steps:
|
|||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
- name: gcr-kaniko-v1-8
|
- name: gcr-kaniko-v1-9
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
repo: plugins/kaniko-gcr
|
repo: plugins/kaniko-gcr
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-arm64-kaniko1.8.1
|
auto_tag_suffix: linux-arm64-kaniko1.9.1
|
||||||
daemon_off: false
|
daemon_off: false
|
||||||
dockerfile: docker/gcr/Dockerfile.linux.arm64.kaniko1.8.1
|
dockerfile: docker/gcr/Dockerfile.linux.arm64.kaniko1.9.1
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
password:
|
password:
|
||||||
@@ -247,14 +246,14 @@ steps:
|
|||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
|
|
||||||
- name: ecr-kaniko-v1-8
|
- name: ecr-kaniko-v1-9
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
repo: plugins/kaniko-ecr
|
repo: plugins/kaniko-ecr
|
||||||
auto_tag: true
|
auto_tag: true
|
||||||
auto_tag_suffix: linux-arm64-kaniko1.8.1
|
auto_tag_suffix: linux-arm64-kaniko1.9.1
|
||||||
daemon_off: false
|
daemon_off: false
|
||||||
dockerfile: docker/ecr/Dockerfile.linux.arm64.kaniko1.8.1
|
dockerfile: docker/ecr/Dockerfile.linux.arm64.kaniko1.9.1
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
password:
|
password:
|
||||||
@@ -348,7 +347,7 @@ steps:
|
|||||||
ignore_missing: true
|
ignore_missing: true
|
||||||
password:
|
password:
|
||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
spec: docker/docker/manifest-kaniko1.8.1.tmpl
|
spec: docker/docker/manifest-kaniko1.9.1.tmpl
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
|
|
||||||
@@ -360,7 +359,7 @@ steps:
|
|||||||
ignore_missing: true
|
ignore_missing: true
|
||||||
password:
|
password:
|
||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
spec: docker/gcr/manifest-kaniko1.8.1.tmpl
|
spec: docker/gcr/manifest-kaniko1.9.1.tmpl
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
|
|
||||||
@@ -372,7 +371,7 @@ steps:
|
|||||||
ignore_missing: true
|
ignore_missing: true
|
||||||
password:
|
password:
|
||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
spec: docker/ecr/manifest-kaniko1.8.1.tmpl
|
spec: docker/ecr/manifest-kaniko1.9.1.tmpl
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Drone kaniko plugin uses [kaniko](https://github.com/GoogleContainerTools/kaniko) to build and publish Docker images to a container registry.
|
Drone kaniko plugin uses [kaniko](https://github.com/GoogleContainerTools/kaniko) to build and publish Docker images to a container registry.
|
||||||
|
|
||||||
Plugin images are published with 1.6.0 as well as 1.8.1 kaniko version from 1.5.1 release tag. `plugins/kaniko:<release-tag>` uses 1.6.0 version while `plugins/kaniko:<release-tag>-kaniko1.8.1` uses 1.8.1 version. Similar convention is used for plugins/kaniko-ecr & plugins/kaniko-gcr images as well.
|
Plugin images are published with 1.6.0 as well as 1.9.1 kaniko version from 1.5.1 release tag. `plugins/kaniko:<release-tag>` uses 1.6.0 version while `plugins/kaniko:<release-tag>-kaniko1.9.1` uses 1.9.1 version. Similar convention is used for plugins/kaniko-ecr & plugins/kaniko-gcr images as well.
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
@@ -135,4 +135,4 @@ docker run --rm \
|
|||||||
```
|
```
|
||||||
|
|
||||||
Tags to push:
|
Tags to push:
|
||||||
- latest
|
- latest.
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ func main() {
|
|||||||
EnvVar: "PLUGIN_AUTO_TAG",
|
EnvVar: "PLUGIN_AUTO_TAG",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "dockerconfig-override",
|
Name: "dockerconfig",
|
||||||
Usage: "use provided docker config override for docker auth",
|
Usage: "docker json dockerconfig",
|
||||||
EnvVar: "PLUGIN_DOCKERCONFIG_OVERRIDE",
|
EnvVar: "PLUGIN_CONFIG",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "auto-tag-suffix",
|
Name: "auto-tag-suffix",
|
||||||
@@ -176,6 +176,11 @@ func main() {
|
|||||||
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
|
Usage: "Set this flag if you only want to build the image, without pushing to a registry",
|
||||||
EnvVar: "PLUGIN_NO_PUSH",
|
EnvVar: "PLUGIN_NO_PUSH",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "tar-path",
|
||||||
|
Usage: "Set this flag to save the image as a tarball at path",
|
||||||
|
EnvVar: "PLUGIN_TAR_PATH",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "verbosity",
|
Name: "verbosity",
|
||||||
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
|
Usage: "Set this flag with value as oneof <panic|fatal|error|warn|info|debug|trace> to set the logging level for kaniko. Defaults to info.",
|
||||||
@@ -191,6 +196,11 @@ func main() {
|
|||||||
Usage: "build only used stages",
|
Usage: "build only used stages",
|
||||||
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
EnvVar: "PLUGIN_SKIP_UNUSED_STAGES",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "output-file",
|
||||||
|
Usage: "Output file location that will be generated by the plugin. This file will include information of the output that are exported by the plugin.",
|
||||||
|
EnvVar: "DRONE_OUTPUT",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
@@ -201,11 +211,11 @@ func main() {
|
|||||||
func run(c *cli.Context) error {
|
func run(c *cli.Context) error {
|
||||||
username := c.String("username")
|
username := c.String("username")
|
||||||
noPush := c.Bool("no-push")
|
noPush := c.Bool("no-push")
|
||||||
configOverride := c.String("dockerconfig-override")
|
configOverride := c.String("dockerconfig")
|
||||||
|
|
||||||
// if configOverride is provided, use this for docker auth
|
// if configOverride is provided, use this for docker auth
|
||||||
if len(configOverride) > 0 {
|
if len(configOverride) > 0 {
|
||||||
if err := writeDockerCfgFile([]byte(c.String("dockerconfig-override"))); err != nil {
|
if err := writeDockerCfgFile([]byte(configOverride)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if !noPush || username != "" {
|
} else if !noPush || username != "" {
|
||||||
@@ -237,6 +247,7 @@ func run(c *cli.Context) error {
|
|||||||
CacheTTL: c.Int("cache-ttl"),
|
CacheTTL: c.Int("cache-ttl"),
|
||||||
DigestFile: defaultDigestFile,
|
DigestFile: defaultDigestFile,
|
||||||
NoPush: noPush,
|
NoPush: noPush,
|
||||||
|
TarPath: c.String("tar-path"),
|
||||||
Verbosity: c.String("verbosity"),
|
Verbosity: c.String("verbosity"),
|
||||||
Platform: c.String("platform"),
|
Platform: c.String("platform"),
|
||||||
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
SkipUnusedStages: c.Bool("skip-unused-stages"),
|
||||||
@@ -248,6 +259,9 @@ func run(c *cli.Context) error {
|
|||||||
ArtifactFile: c.String("artifact-file"),
|
ArtifactFile: c.String("artifact-file"),
|
||||||
RegistryType: artifact.Docker,
|
RegistryType: artifact.Docker,
|
||||||
},
|
},
|
||||||
|
Output: kaniko.Output{
|
||||||
|
OutputFile: c.String("output-file"),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-3
@@ -64,6 +64,11 @@ func main() {
|
|||||||
Value: "Dockerfile",
|
Value: "Dockerfile",
|
||||||
EnvVar: "PLUGIN_DOCKERFILE",
|
EnvVar: "PLUGIN_DOCKERFILE",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "docker-registry",
|
||||||
|
Usage: "docker registry",
|
||||||
|
EnvVar: "PLUGIN_DOCKER_REGISTRY,DOCKER_REGISTRY",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "docker-username",
|
Name: "docker-username",
|
||||||
Usage: "docker username",
|
Usage: "docker username",
|
||||||
@@ -242,6 +247,7 @@ func run(c *cli.Context) error {
|
|||||||
noPush := c.Bool("no-push")
|
noPush := c.Bool("no-push")
|
||||||
|
|
||||||
dockerConfig, err := createDockerConfig(
|
dockerConfig, err := createDockerConfig(
|
||||||
|
c.String("docker-registry"),
|
||||||
c.String("docker-username"),
|
c.String("docker-username"),
|
||||||
c.String("docker-password"),
|
c.String("docker-password"),
|
||||||
c.String("access-key"),
|
c.String("access-key"),
|
||||||
@@ -328,12 +334,16 @@ func run(c *cli.Context) error {
|
|||||||
return plugin.Exec()
|
return plugin.Exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDockerConfig(dockerUsername, dockerPassword, accessKey, secretKey,
|
func createDockerConfig(dockerRegistry, dockerUsername, dockerPassword, accessKey, secretKey,
|
||||||
registry, assumeRole, externalId, region string, noPush bool) (*docker.Config, error) {
|
registry, assumeRole, externalId, region string, noPush bool) (*docker.Config, error) {
|
||||||
dockerConfig := docker.NewConfig()
|
dockerConfig := docker.NewConfig()
|
||||||
|
|
||||||
if dockerUsername != "" {
|
if dockerUsername != "" {
|
||||||
dockerConfig.SetAuth(docker.RegistryV1, dockerUsername, dockerPassword)
|
// if no docker registry provided, use dockerhub by default
|
||||||
|
if len(dockerRegistry) == 0 {
|
||||||
|
dockerRegistry = docker.RegistryV1
|
||||||
|
}
|
||||||
|
dockerConfig.SetAuth(dockerRegistry, dockerUsername, dockerPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
if assumeRole != "" {
|
if assumeRole != "" {
|
||||||
@@ -469,7 +479,7 @@ func getAssumeRoleCreds(region, roleArn, externalId, roleSessionName string) (st
|
|||||||
|
|
||||||
username, password, registry, err := getAuthInfo(svc)
|
username, password, registry, err := getAuthInfo(svc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", "", errors.Wrap(err, "failed to get ECR auth")
|
return "", "", "", errors.Wrap(err, "failed to get ECR auth: no basic auth credentials")
|
||||||
}
|
}
|
||||||
return username, password, registry, nil
|
return username, password, registry, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
func TestCreateDockerConfig(t *testing.T) {
|
func TestCreateDockerConfig(t *testing.T) {
|
||||||
got, err := createDockerConfig(
|
got, err := createDockerConfig(
|
||||||
|
"",
|
||||||
"docker-username",
|
"docker-username",
|
||||||
"docker-password",
|
"docker-password",
|
||||||
"access-key",
|
"access-key",
|
||||||
@@ -34,10 +35,37 @@ func TestCreateDockerConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateDockerConfigFromGivenRegistry(t *testing.T) {
|
||||||
|
got, err := createDockerConfig(
|
||||||
|
"docker-registry",
|
||||||
|
"docker-username",
|
||||||
|
"docker-password",
|
||||||
|
"access-key",
|
||||||
|
"secret-key",
|
||||||
|
"ecr-registry",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("failed to create docker config")
|
||||||
|
}
|
||||||
|
|
||||||
|
want := docker.NewConfig()
|
||||||
|
want.SetAuth("docker-registry", "docker-username", "docker-password")
|
||||||
|
want.SetCredHelper(docker.RegistryECRPublic, "ecr-login")
|
||||||
|
want.SetCredHelper("ecr-registry", "ecr-login")
|
||||||
|
if !reflect.DeepEqual(want, got) {
|
||||||
|
t.Errorf("not equal:\n want: %#v\n got: %#v", want, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreateDockerConfigKanikoOneDotEight(t *testing.T) {
|
func TestCreateDockerConfigKanikoOneDotEight(t *testing.T) {
|
||||||
os.Setenv(kanikoVersionEnv, "1.8.1")
|
os.Setenv(kanikoVersionEnv, "1.8.1")
|
||||||
defer os.Setenv(kanikoVersionEnv, "")
|
defer os.Setenv(kanikoVersionEnv, "")
|
||||||
got, err := createDockerConfig(
|
got, err := createDockerConfig(
|
||||||
|
"",
|
||||||
"docker-username",
|
"docker-username",
|
||||||
"docker-password",
|
"docker-password",
|
||||||
"access-key",
|
"access-key",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/amd64/kaniko-acr /kaniko/
|
ADD release/linux/amd64/kaniko-acr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.8.1
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/arm64/kaniko-acr /kaniko/
|
ADD release/linux/arm64/kaniko-acr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
ENTRYPOINT ["/kaniko/kaniko-acr"]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.6.0
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.6.0
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/amd64/kaniko-docker /kaniko/
|
ADD release/linux/amd64/kaniko-docker /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.8.1
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/amd64/kaniko-docker /kaniko/
|
ADD release/linux/amd64/kaniko-docker /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.6.0
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.6.0
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/arm64/kaniko-docker /kaniko/
|
ADD release/linux/arm64/kaniko-docker /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.8.1
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/arm64/kaniko-docker /kaniko/
|
ADD release/linux/arm64/kaniko-docker /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.8.1{{else}}latest-kaniko1.8.1{{/if}}
|
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.9.1{{else}}latest-kaniko1.9.1{{/if}}
|
||||||
{{#if build.tags}}
|
{{#if build.tags}}
|
||||||
tags:
|
tags:
|
||||||
{{#each build.tags}}
|
{{#each build.tags}}
|
||||||
@@ -7,12 +7,12 @@ tags:
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
manifests:
|
manifests:
|
||||||
-
|
-
|
||||||
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.8.1
|
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.9.1
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: linux
|
os: linux
|
||||||
-
|
-
|
||||||
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.8.1
|
image: plugins/kaniko:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.9.1
|
||||||
platform:
|
platform:
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
os: linux
|
os: linux
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.6.0
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.6.0
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.8.1
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.6.0
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
ENV KANIKO_VERSION=1.6.0
|
ENV KANIKO_VERSION=1.9.1
|
||||||
|
|
||||||
ADD release/linux/arm64/kaniko-ecr /kaniko/
|
ADD release/linux/arm64/kaniko-ecr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.8.1
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/arm64/kaniko-ecr /kaniko/
|
ADD release/linux/arm64/kaniko-ecr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.8.1{{else}}latest-kaniko1.8.1{{/if}}
|
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.9.1{{else}}latest-kaniko1.9.1{{/if}}
|
||||||
{{#if build.tags}}
|
{{#if build.tags}}
|
||||||
tags:
|
tags:
|
||||||
{{#each build.tags}}
|
{{#each build.tags}}
|
||||||
@@ -7,12 +7,12 @@ tags:
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
manifests:
|
manifests:
|
||||||
-
|
-
|
||||||
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.8.1
|
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.9.1
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: linux
|
os: linux
|
||||||
-
|
-
|
||||||
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.8.1
|
image: plugins/kaniko-ecr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.9.1
|
||||||
platform:
|
platform:
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
os: linux
|
os: linux
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.6.0
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.6.0
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.8.1
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.6.0
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV HOME /root
|
ENV HOME /root
|
||||||
ENV USER root
|
ENV USER root
|
||||||
ENV KANIKO_VERSION=1.6.0
|
ENV KANIKO_VERSION=1.9.1
|
||||||
|
|
||||||
ADD release/linux/arm64/kaniko-gcr /kaniko/
|
ADD release/linux/arm64/kaniko-gcr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
FROM gcr.io/kaniko-project/executor:v1.8.1
|
FROM gcr.io/kaniko-project/executor:v1.9.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.9.1
|
||||||
ADD release/linux/arm64/kaniko-gcr /kaniko/
|
ADD release/linux/arm64/kaniko-gcr /kaniko/
|
||||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.8.1{{else}}latest-kaniko1.8.1{{/if}}
|
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-kaniko1.9.1{{else}}latest-kaniko1.9.1{{/if}}
|
||||||
{{#if build.tags}}
|
{{#if build.tags}}
|
||||||
tags:
|
tags:
|
||||||
{{#each build.tags}}
|
{{#each build.tags}}
|
||||||
@@ -7,12 +7,12 @@ tags:
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
manifests:
|
manifests:
|
||||||
-
|
-
|
||||||
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.8.1
|
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-kaniko1.9.1
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: linux
|
os: linux
|
||||||
-
|
-
|
||||||
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.8.1
|
image: plugins/kaniko-gcr:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-kaniko1.9.1
|
||||||
platform:
|
platform:
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
os: linux
|
os: linux
|
||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/drone/drone-kaniko/pkg/artifact"
|
"github.com/drone/drone-kaniko/pkg/artifact"
|
||||||
|
"github.com/drone/drone-kaniko/pkg/output"
|
||||||
"github.com/drone/drone-kaniko/pkg/tagger"
|
"github.com/drone/drone-kaniko/pkg/tagger"
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
@@ -38,6 +39,7 @@ type (
|
|||||||
Verbosity string // Log level
|
Verbosity string // Log level
|
||||||
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
|
Platform string // Allows to build with another default platform than the host, similarly to docker build --platform
|
||||||
SkipUnusedStages bool // Build only used stages
|
SkipUnusedStages bool // Build only used stages
|
||||||
|
TarPath string // Set this flag to save the image as a tarball at path
|
||||||
}
|
}
|
||||||
|
|
||||||
// Artifact defines content of artifact file
|
// Artifact defines content of artifact file
|
||||||
@@ -49,10 +51,16 @@ type (
|
|||||||
ArtifactFile string // Artifact file location
|
ArtifactFile string // Artifact file location
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Output defines content of output file
|
||||||
|
Output struct {
|
||||||
|
OutputFile string // File where plugin output are saved
|
||||||
|
}
|
||||||
|
|
||||||
// Plugin defines the Docker plugin parameters.
|
// Plugin defines the Docker plugin parameters.
|
||||||
Plugin struct {
|
Plugin struct {
|
||||||
Build Build // Docker build configuration
|
Build Build // Docker build configuration
|
||||||
Artifact Artifact // Artifact file content
|
Artifact Artifact // Artifact file content
|
||||||
|
Output Output // Output file content
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -148,14 +156,15 @@ func (p Plugin) Exec() error {
|
|||||||
fmt.Sprintf("--context=dir://%s", p.Build.Context),
|
fmt.Sprintf("--context=dir://%s", p.Build.Context),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the destination repository
|
// Set the destination repository only when we push or save to tarball
|
||||||
if !p.Build.NoPush {
|
if !p.Build.NoPush || p.Build.TarPath != "" {
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
for _, label := range p.Build.labelsForTag(tag) {
|
for _, label := range p.Build.labelsForTag(tag) {
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--destination=%s:%s", p.Build.Repo, label))
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--destination=%s:%s", p.Build.Repo, label))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the build arguments
|
// Set the build arguments
|
||||||
for _, arg := range p.Build.Args {
|
for _, arg := range p.Build.Args {
|
||||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--build-arg=%s", arg))
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--build-arg=%s", arg))
|
||||||
@@ -212,6 +221,10 @@ func (p Plugin) Exec() error {
|
|||||||
cmdArgs = append(cmdArgs, "--skip-unused-stages")
|
cmdArgs = append(cmdArgs, "--skip-unused-stages")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.Build.TarPath != "" {
|
||||||
|
cmdArgs = append(cmdArgs, fmt.Sprintf("--tar-path=%s", p.Build.TarPath))
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -223,19 +236,29 @@ func (p Plugin) Exec() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.Build.DigestFile != "" && p.Artifact.ArtifactFile != "" {
|
if p.Build.DigestFile != "" && p.Artifact.ArtifactFile != "" {
|
||||||
content, err := ioutil.ReadFile(p.Build.DigestFile)
|
err = artifact.WritePluginArtifactFile(p.Artifact.RegistryType, p.Artifact.ArtifactFile, p.Artifact.Registry, p.Artifact.Repo, getDigest(p.Build.DigestFile), p.Artifact.Tags)
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "failed to read digest file contents at path: %s with error: %s\n", p.Build.DigestFile, err)
|
|
||||||
}
|
|
||||||
err = artifact.WritePluginArtifactFile(p.Artifact.RegistryType, p.Artifact.ArtifactFile, p.Artifact.Registry, p.Artifact.Repo, string(content), p.Artifact.Tags)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to write plugin artifact file at path: %s with error: %s\n", p.Artifact.ArtifactFile, err)
|
fmt.Fprintf(os.Stderr, "failed to write plugin artifact file at path: %s with error: %s\n", p.Artifact.ArtifactFile, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.Output.OutputFile != "" {
|
||||||
|
if err = output.WritePluginOutputFile(p.Output.OutputFile, getDigest(p.Build.DigestFile)); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "failed to write plugin output file at path: %s with error: %s\n", p.Output.OutputFile, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDigest(digestFile string) string {
|
||||||
|
content, err := ioutil.ReadFile(digestFile)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "failed to read digest file contents at path: %s with error: %s\n", digestFile, err)
|
||||||
|
}
|
||||||
|
return string(content)
|
||||||
|
}
|
||||||
|
|
||||||
// trace writes each command to stdout with the command wrapped in an xml
|
// trace writes each command to stdout with the command wrapped in an xml
|
||||||
// tag so that it can be extracted and displayed in the logs.
|
// tag so that it can be extracted and displayed in the logs.
|
||||||
func trace(cmd *exec.Cmd) {
|
func trace(cmd *exec.Cmd) {
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package output
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
)
|
||||||
|
|
||||||
|
func WritePluginOutputFile(outputFilePath, digest string) error {
|
||||||
|
output := map[string]string{
|
||||||
|
"digest": digest,
|
||||||
|
}
|
||||||
|
return godotenv.Write(output, outputFilePath)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user