Compare commits

...

12 Commits

Author SHA1 Message Date
Shubham Agrawal 69d5e73564 Fix pipeline yaml with auto tag suffix 2021-01-30 00:09:22 +05:30
Shubham Agrawal b33681a9b9 Merge pull request #9 from drone/improve_err
Log error if dockerfile does not exist at provided path
2021-01-29 14:41:19 +05:30
Shubham Agrawal cdd1510210 Log error if dockerfile does not exist at provided path 2021-01-29 14:39:06 +05:30
Shubham Agrawal fa7726153d Merge pull request #8 from drone/ecr_iam
Make access key & secret optional in case of iam role usage on EKS cluster
2021-01-20 00:28:57 +05:30
Shubham Agrawal 49309bfa42 Make access key & secret optional in case of iam role usage on EKS cluster 2021-01-20 00:25:23 +05:30
Shubham Agrawal 428642719b Merge pull request #7 from drone/fix_label
Fix label usage
2021-01-18 21:15:01 +05:30
Shubham Agrawal 33f15bdebe Fix label usage 2021-01-18 21:12:53 +05:30
Shubham Agrawal 10df8f28b9 Merge pull request #6 from drone/fix_ecr
Fix kaniko ecr publish
2020-12-02 15:20:00 +05:30
Shubham Agrawal 17072a25f1 Fix ecr publish 2020-12-02 15:17:28 +05:30
Shubham Agrawal 26c93eccd1 Merge pull request #5 from drone/fix_gcr
Fix kaniko-gcr docker file
2020-11-26 23:50:20 +05:30
Shubham Agrawal ee562a4a1b Fix kaniko-gcr docker file 2020-11-26 23:47:00 +05:30
Shubham Agrawal e200b5c566 Merge pull request #4 from drone/v2_registry
fix docker v2 registry issue
2020-11-26 16:32:29 +05:30
8 changed files with 36 additions and 29 deletions
+15
View File
@@ -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
View File
@@ -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")
}
+1 -1
View 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 -4
View File
@@ -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 -4
View File
@@ -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 -4
View File
@@ -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"]
+5 -1
View File
@@ -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
View File