mirror of
https://github.com/drone/drone-kaniko.git
synced 2026-06-04 18:23:49 +08:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 69d5e73564 | |||
| b33681a9b9 | |||
| cdd1510210 | |||
| fa7726153d | |||
| 49309bfa42 | |||
| 428642719b | |||
| 33f15bdebe | |||
| 10df8f28b9 | |||
| 17072a25f1 | |||
| 26c93eccd1 | |||
| ee562a4a1b | |||
| e200b5c566 |
+15
@@ -14,30 +14,45 @@ steps:
|
||||
settings:
|
||||
repo: plugins/kaniko
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
dockerfile: docker/docker/Dockerfile.linux.amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
- name: gcr
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-gcr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
dockerfile: docker/gcr/Dockerfile.linux.amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
||||
- name: ecr
|
||||
image: plugins/docker
|
||||
settings:
|
||||
repo: plugins/kaniko-ecr
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
dockerfile: docker/ecr/Dockerfile.linux.amd64
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
+12
-15
@@ -109,7 +109,7 @@ func run(c *cli.Context) error {
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
Target: c.String("target"),
|
||||
Repo: c.String("repo"),
|
||||
Repo: fmt.Sprintf("%s/%s", c.String("registry"), c.String("repo")),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
},
|
||||
}
|
||||
@@ -117,28 +117,25 @@ func run(c *cli.Context) error {
|
||||
}
|
||||
|
||||
func setupECRAuth(accessKey, secretKey, registry string) error {
|
||||
if accessKey == "" {
|
||||
return fmt.Errorf("Access key must be specified")
|
||||
}
|
||||
if secretKey == "" {
|
||||
return fmt.Errorf("Secret key must be specified")
|
||||
}
|
||||
if registry == "" {
|
||||
return fmt.Errorf("Registry must be specified")
|
||||
}
|
||||
|
||||
err := os.Setenv(accessKeyEnv, accessKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", accessKeyEnv))
|
||||
}
|
||||
// If IAM role is used, access key & secret key are not required
|
||||
if accessKey != "" && secretKey != "" {
|
||||
err := os.Setenv(accessKeyEnv, accessKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", accessKeyEnv))
|
||||
}
|
||||
|
||||
err = os.Setenv(secretKeyEnv, secretKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", secretKeyEnv))
|
||||
err = os.Setenv(secretKeyEnv, secretKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("failed to set %s environment variable", secretKeyEnv))
|
||||
}
|
||||
}
|
||||
|
||||
jsonBytes := []byte(fmt.Sprintf(`{"credStore": "ecr-login", "credHelpers": {"%s": "ecr-login"}}`, registry))
|
||||
err = ioutil.WriteFile(dockerConfigPath, jsonBytes, 0644)
|
||||
err := ioutil.WriteFile(dockerConfigPath, jsonBytes, 0644)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create docker config file")
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
const (
|
||||
// GCR JSON key file path
|
||||
gcrKeyPath string = "/kaniko/gcr.json"
|
||||
gcrKeyPath string = "/kaniko/config.json"
|
||||
gcrEnvVariable string = "GOOGLE_APPLICATION_CREDENTIALS"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
FROM gcr.io/kaniko-project/executor:amd64-v1.3.0
|
||||
|
||||
ENV HOME /root
|
||||
ENV USER root
|
||||
FROM gcr.io/kaniko-project/executor:v1.3.0
|
||||
|
||||
ADD release/linux/amd64/kaniko-docker /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-docker"]
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
FROM gcr.io/kaniko-project/executor:amd64-v1.3.0
|
||||
|
||||
ENV HOME /root
|
||||
ENV USER root
|
||||
FROM gcr.io/kaniko-project/executor:v1.3.0
|
||||
|
||||
ADD release/linux/amd64/kaniko-ecr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-ecr"]
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
FROM gcr.io/kaniko-project/executor:amd64-v1.3.0
|
||||
|
||||
ENV HOME /root
|
||||
ENV USER root
|
||||
FROM gcr.io/kaniko-project/executor:v1.3.0
|
||||
|
||||
ADD release/linux/amd64/kaniko-gcr /kaniko/
|
||||
ENTRYPOINT ["/kaniko/kaniko-gcr"]
|
||||
@@ -31,6 +31,10 @@ func (p Plugin) Exec() error {
|
||||
return fmt.Errorf("repository name to publish image must be specified")
|
||||
}
|
||||
|
||||
if _, err := os.Stat(p.Build.Dockerfile); os.IsNotExist(err) {
|
||||
return fmt.Errorf("dockerfile does not exist at path: %s", p.Build.Dockerfile)
|
||||
}
|
||||
|
||||
cmdArgs := []string{
|
||||
fmt.Sprintf("--dockerfile=%s", p.Build.Dockerfile),
|
||||
fmt.Sprintf("--context=dir://%s", p.Build.Context),
|
||||
@@ -46,7 +50,7 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
// Set the labels
|
||||
for _, label := range p.Build.Labels {
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--label %s", label))
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--label=%s", label))
|
||||
}
|
||||
|
||||
if p.Build.Target != "" {
|
||||
|
||||
Regular → Executable
Reference in New Issue
Block a user