mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-14 05:12:26 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ed8ef9156e | |||
| 2f55e25020 | |||
| f3544ce6ee | |||
| e4cd992d8d | |||
| d457df687d | |||
| 4820b6af00 | |||
| 3717723366 | |||
| be3bf8ad1e | |||
| 15255d3520 | |||
| 6ba0eb58c3 | |||
| 17e907c7cf | |||
| 190fbefe91 | |||
| 48f6e72954 | |||
| 1bee1629c2 | |||
| 2d0315e6bb |
+21
-21
@@ -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:
|
||||||
@@ -212,14 +212,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 +229,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 +247,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 +348,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 +360,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 +372,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
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,11 @@ func main() {
|
|||||||
Usage: "enable auto generation of build tags",
|
Usage: "enable auto generation of build tags",
|
||||||
EnvVar: "PLUGIN_AUTO_TAG",
|
EnvVar: "PLUGIN_AUTO_TAG",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "dockerconfig",
|
||||||
|
Usage: "docker json dockerconfig",
|
||||||
|
EnvVar: "PLUGIN_CONFIG",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "auto-tag-suffix",
|
Name: "auto-tag-suffix",
|
||||||
Usage: "the suffix of auto build tags",
|
Usage: "the suffix of auto build tags",
|
||||||
@@ -196,9 +201,15 @@ 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")
|
||||||
|
|
||||||
// only setup auth when pushing or credentials are defined
|
// if configOverride is provided, use this for docker auth
|
||||||
if !noPush || username != "" {
|
if len(configOverride) > 0 {
|
||||||
|
if err := writeDockerCfgFile([]byte(configOverride)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else if !noPush || username != "" {
|
||||||
|
// setup auth when pushing or credentials are defined and docker config override is false
|
||||||
if err := createDockerCfgFile(username, c.String("password"), c.String("registry")); err != nil {
|
if err := createDockerCfgFile(username, c.String("password"), c.String("registry")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -259,14 +270,22 @@ func createDockerCfgFile(username, password, registry string) error {
|
|||||||
registry = v1RegistryURL
|
registry = v1RegistryURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authBytes := []byte(fmt.Sprintf("%s:%s", username, password))
|
||||||
|
encodedString := base64.StdEncoding.EncodeToString(authBytes)
|
||||||
|
jsonBytes := []byte(fmt.Sprintf(`{"auths": {"%s": {"auth": "%s"}}}`, registry, encodedString))
|
||||||
|
|
||||||
|
if err := writeDockerCfgFile(jsonBytes); err != nil {
|
||||||
|
return errors.Wrap(err, "failed to write docker config file")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write json bytes in the docker config file
|
||||||
|
func writeDockerCfgFile(jsonBytes []byte) error {
|
||||||
err := os.MkdirAll(dockerPath, 0600)
|
err := os.MkdirAll(dockerPath, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, fmt.Sprintf("failed to create %s directory", dockerPath))
|
return errors.Wrap(err, fmt.Sprintf("failed to create %s directory", dockerPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
authBytes := []byte(fmt.Sprintf("%s:%s", username, password))
|
|
||||||
encodedString := base64.StdEncoding.EncodeToString(authBytes)
|
|
||||||
jsonBytes := []byte(fmt.Sprintf(`{"auths": {"%s": {"auth": "%s"}}}`, registry, encodedString))
|
|
||||||
err = ioutil.WriteFile(dockerConfigPath, jsonBytes, 0644)
|
err = ioutil.WriteFile(dockerConfigPath, jsonBytes, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to create docker config file")
|
return errors.Wrap(err, "failed to create docker config file")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM gcr.io/kaniko-project/executor
|
FROM gcr.io/kaniko-project/executor:v1.8.1
|
||||||
|
|
||||||
ENV KANIKO_VERSION=1.8.1
|
ENV KANIKO_VERSION=1.8.1
|
||||||
ADD release/linux/amd64/kaniko-acr /kaniko/
|
ADD release/linux/amd64/kaniko-acr /kaniko/
|
||||||
|
|||||||
+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"]
|
||||||
+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
|
||||||
+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"]
|
||||||
+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
|
||||||
+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"]
|
||||||
+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
|
||||||
+10
-1
@@ -100,7 +100,16 @@ func TestBuild_AutoTags(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tag push",
|
name: "beta tag push",
|
||||||
|
repoBranch: "master",
|
||||||
|
commitRef: "refs/tags/v1.0.0-beta.1",
|
||||||
|
autoTagSuffix: "",
|
||||||
|
expectedTags: []string{
|
||||||
|
"1.0.0-beta.1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "tag push with suffix",
|
||||||
repoBranch: "master",
|
repoBranch: "master",
|
||||||
commitRef: "refs/tags/v1.0.0",
|
commitRef: "refs/tags/v1.0.0",
|
||||||
autoTagSuffix: "linux-amd64",
|
autoTagSuffix: "linux-amd64",
|
||||||
|
|||||||
Reference in New Issue
Block a user