forked from Ivasoft/drone-docker
Compare commits
5 Commits
v19.03.9
...
starlark-b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcc073cef3 | ||
|
|
ece57563b4 | ||
|
|
e33755c959 | ||
|
|
188d9c8543 | ||
|
|
af1bb6bcf2 |
272
.drone.star
Normal file
272
.drone.star
Normal file
@@ -0,0 +1,272 @@
|
||||
golang_image = "golang:1.15"
|
||||
|
||||
def main(ctx):
|
||||
before = testing(ctx)
|
||||
|
||||
stages = [
|
||||
linux(ctx, "amd64"),
|
||||
linux(ctx, "arm64"),
|
||||
linux(ctx, "arm"),
|
||||
]
|
||||
|
||||
after = manifest(ctx) + gitter(ctx)
|
||||
|
||||
for b in before:
|
||||
for s in stages:
|
||||
s["depends_on"].append(b["name"])
|
||||
|
||||
for s in stages:
|
||||
for a in after:
|
||||
a["depends_on"].append(s["name"])
|
||||
|
||||
return before + stages + after
|
||||
|
||||
def testing(ctx):
|
||||
step_volumes = [
|
||||
{
|
||||
"name": "gopath",
|
||||
"path": "/go",
|
||||
},
|
||||
]
|
||||
|
||||
return [
|
||||
{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "testing",
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": "amd64",
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "staticcheck",
|
||||
"image": golang_image,
|
||||
"pull": "always",
|
||||
"commands": [
|
||||
"go run honnef.co/go/tools/cmd/staticcheck ./...",
|
||||
],
|
||||
"volumes": step_volumes,
|
||||
},
|
||||
{
|
||||
"name": "lint",
|
||||
"image": golang_image,
|
||||
"pull": "always",
|
||||
"commands": [
|
||||
"go run golang.org/x/lint/golint -set_exit_status ./...",
|
||||
],
|
||||
"volumes": step_volumes,
|
||||
},
|
||||
{
|
||||
"name": "vet",
|
||||
"image": golang_image,
|
||||
"commands": [
|
||||
"go vet ./...",
|
||||
],
|
||||
"volumes": step_volumes,
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"image": golang_image,
|
||||
"commands": [
|
||||
"go test -cover ./...",
|
||||
],
|
||||
"volumes": step_volumes,
|
||||
},
|
||||
],
|
||||
"volumes": [
|
||||
{
|
||||
"name": "gopath",
|
||||
"temp": {},
|
||||
},
|
||||
],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
"refs/pull/**",
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
def linux(ctx, arch):
|
||||
steps = [
|
||||
{
|
||||
"name": "environment",
|
||||
"image": golang_image,
|
||||
"pull": "always",
|
||||
"environment": {
|
||||
"CGO_ENABLED": "0",
|
||||
},
|
||||
"commands": [
|
||||
"go version",
|
||||
"go env",
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
steps.extend(linux_build(ctx, arch, "docker"))
|
||||
steps.extend(linux_build(ctx, arch, "acr"))
|
||||
steps.extend(linux_build(ctx, arch, "ecr"))
|
||||
steps.extend(linux_build(ctx, arch, "gcr"))
|
||||
steps.extend(linux_build(ctx, arch, "heroku"))
|
||||
|
||||
return {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "linux-%s" % (arch),
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": arch,
|
||||
},
|
||||
"steps": steps,
|
||||
"depends_on": [],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
"refs/pull/**",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
def linux_build(ctx, arch, name):
|
||||
docker = {
|
||||
"dockerfile": "docker/%s/Dockerfile.linux.%s" % (name, arch),
|
||||
"repo": "plugins/%s" % (name),
|
||||
"username": {
|
||||
"from_secret": "docker_username",
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "docker_password",
|
||||
},
|
||||
}
|
||||
|
||||
if ctx.build.event == "pull_request":
|
||||
docker.update({
|
||||
"dry_run": True,
|
||||
"tags": "linux-%s" % (arch),
|
||||
})
|
||||
else:
|
||||
docker.update({
|
||||
"auto_tag": True,
|
||||
"auto_tag_suffix": "linux-%s" % (arch),
|
||||
})
|
||||
|
||||
if ctx.build.event == "tag":
|
||||
build = [
|
||||
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-%s ./cmd/drone-%s' % (ctx.build.ref.replace("refs/tags/v", ""), arch, name, name),
|
||||
]
|
||||
else:
|
||||
build = [
|
||||
'go build -v -ldflags "-X main.version=%s" -a -tags netgo -o release/linux/%s/drone-%s ./cmd/drone-%s' % (ctx.build.commit[0:8], arch, name, name),
|
||||
]
|
||||
|
||||
return [
|
||||
{
|
||||
"name": "build-%s" % (name),
|
||||
"image": golang_image,
|
||||
"environment": {
|
||||
"CGO_ENABLED": "0",
|
||||
},
|
||||
"commands": build,
|
||||
},
|
||||
{
|
||||
"name": "docker-%s" % (name),
|
||||
"image": "plugins/docker",
|
||||
"pull": "always",
|
||||
"settings": docker,
|
||||
},
|
||||
]
|
||||
|
||||
def manifest(ctx):
|
||||
steps = []
|
||||
|
||||
steps.extend(manifest_build(ctx, "docker"))
|
||||
steps.extend(manifest_build(ctx, "acr"))
|
||||
steps.extend(manifest_build(ctx, "ecr"))
|
||||
steps.extend(manifest_build(ctx, "gcr"))
|
||||
steps.extend(manifest_build(ctx, "heroku"))
|
||||
|
||||
return [
|
||||
{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "manifest",
|
||||
"steps": steps,
|
||||
"depends_on": [],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
def manifest_build(ctx, name):
|
||||
return [
|
||||
{
|
||||
"name": "manifest-%s" % (name),
|
||||
"image": "plugins/manifest",
|
||||
"pull": "always",
|
||||
"settings": {
|
||||
"auto_tag": "true",
|
||||
"username": {
|
||||
"from_secret": "docker_username",
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "docker_password",
|
||||
},
|
||||
"spec": "docker/%s/manifest.tmpl" % (name),
|
||||
"ignore_missing": "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "microbadger-%s" % (name),
|
||||
"image": "plugins/webhook",
|
||||
"pull": "always",
|
||||
"settings": {
|
||||
"urls": {
|
||||
"from_secret": "microbadger_url",
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
def gitter(ctx):
|
||||
return [
|
||||
{
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "gitter",
|
||||
"clone": {
|
||||
"disable": True,
|
||||
},
|
||||
"steps": [
|
||||
{
|
||||
"name": "gitter",
|
||||
"image": "plugins/gitter",
|
||||
"pull": "always",
|
||||
"settings": {
|
||||
"webhook": {
|
||||
"from_secret": "gitter_webhook",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
"depends_on": [
|
||||
"manifest",
|
||||
],
|
||||
"trigger": {
|
||||
"ref": [
|
||||
"refs/heads/master",
|
||||
"refs/tags/**",
|
||||
],
|
||||
"status": [
|
||||
"failure",
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
1351
.drone.yml
1351
.drone.yml
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
since-tag=v19.03.8
|
||||
|
||||
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,25 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## [v19.03.9](https://github.com/drone-plugins/drone-docker/tree/v19.03.9) (2021-10-13)
|
||||
|
||||
[Full Changelog](https://github.com/drone-plugins/drone-docker/compare/v19.03.8...v19.03.9)
|
||||
|
||||
**Implemented enhancements:**
|
||||
|
||||
- adding support for externalId [\#333](https://github.com/drone-plugins/drone-docker/pull/333) ([jimsheldon](https://github.com/jimsheldon))
|
||||
- Add support for automatic opencontainer labels [\#313](https://github.com/drone-plugins/drone-docker/pull/313) ([codrut-fc](https://github.com/codrut-fc))
|
||||
- add custom seccomp profile [\#312](https://github.com/drone-plugins/drone-docker/pull/312) ([xoxys](https://github.com/xoxys))
|
||||
- ECR: adding setting to enable image scanning while repo creation [\#300](https://github.com/drone-plugins/drone-docker/pull/300) ([rvoitenko](https://github.com/rvoitenko))
|
||||
|
||||
**Fixed bugs:**
|
||||
|
||||
- Revert "Update seccomp to 20.10 docker" [\#325](https://github.com/drone-plugins/drone-docker/pull/325) ([bradrydzewski](https://github.com/bradrydzewski))
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- \(maint\) CI, remove the dry run steps, due to rate limiting [\#323](https://github.com/drone-plugins/drone-docker/pull/323) ([tphoney](https://github.com/tphoney))
|
||||
- Update seccomp to 20.10 docker [\#322](https://github.com/drone-plugins/drone-docker/pull/322) ([techknowlogick](https://github.com/techknowlogick))
|
||||
|
||||
|
||||
|
||||
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
||||
@@ -50,7 +50,7 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "daemon.mirror",
|
||||
Usage: "docker daemon registry mirror",
|
||||
EnvVar: "PLUGIN_MIRROR,DOCKER_PLUGIN_MIRROR",
|
||||
EnvVar: "PLUGIN_MIRROR",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "daemon.storage-driver",
|
||||
@@ -192,16 +192,6 @@ func main() {
|
||||
Usage: "label-schema labels",
|
||||
EnvVar: "PLUGIN_LABEL_SCHEMA",
|
||||
},
|
||||
cli.BoolTFlag{
|
||||
Name: "auto-label",
|
||||
Usage: "auto-label true|false",
|
||||
EnvVar: "PLUGIN_AUTO_LABEL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "link",
|
||||
Usage: "link https://example.com/org/repo-name",
|
||||
EnvVar: "PLUGIN_REPO_LINK,DRONE_REPO_LINK",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "docker.registry",
|
||||
Usage: "docker registry",
|
||||
@@ -226,7 +216,7 @@ func main() {
|
||||
cli.StringFlag{
|
||||
Name: "docker.config",
|
||||
Usage: "docker json dockerconfig content",
|
||||
EnvVar: "PLUGIN_CONFIG,DOCKER_PLUGIN_CONFIG",
|
||||
EnvVar: "PLUGIN_CONFIG",
|
||||
},
|
||||
cli.BoolTFlag{
|
||||
Name: "docker.purge",
|
||||
@@ -267,26 +257,24 @@ func run(c *cli.Context) error {
|
||||
Config: c.String("docker.config"),
|
||||
},
|
||||
Build: docker.Build{
|
||||
Remote: c.String("remote.url"),
|
||||
Name: c.String("commit.sha"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
ArgsEnv: c.StringSlice("args-from-env"),
|
||||
Target: c.String("target"),
|
||||
Squash: c.Bool("squash"),
|
||||
Pull: c.BoolT("pull-image"),
|
||||
CacheFrom: c.StringSlice("cache-from"),
|
||||
Compress: c.Bool("compress"),
|
||||
Repo: c.String("repo"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
LabelSchema: c.StringSlice("label-schema"),
|
||||
AutoLabel: c.BoolT("auto-label"),
|
||||
Link: c.String("link"),
|
||||
NoCache: c.Bool("no-cache"),
|
||||
AddHost: c.StringSlice("add-host"),
|
||||
Quiet: c.Bool("quiet"),
|
||||
Remote: c.String("remote.url"),
|
||||
Name: c.String("commit.sha"),
|
||||
Dockerfile: c.String("dockerfile"),
|
||||
Context: c.String("context"),
|
||||
Tags: c.StringSlice("tags"),
|
||||
Args: c.StringSlice("args"),
|
||||
ArgsEnv: c.StringSlice("args-from-env"),
|
||||
Target: c.String("target"),
|
||||
Squash: c.Bool("squash"),
|
||||
Pull: c.BoolT("pull-image"),
|
||||
CacheFrom: c.StringSlice("cache-from"),
|
||||
Compress: c.Bool("compress"),
|
||||
Repo: c.String("repo"),
|
||||
Labels: c.StringSlice("custom-labels"),
|
||||
LabelSchema: c.StringSlice("label-schema"),
|
||||
NoCache: c.Bool("no-cache"),
|
||||
AddHost: c.StringSlice("add-host"),
|
||||
Quiet: c.Bool("quiet"),
|
||||
},
|
||||
Daemon: docker.Daemon{
|
||||
Registry: c.String("docker.registry"),
|
||||
|
||||
@@ -37,8 +37,6 @@ func main() {
|
||||
lifecyclePolicy = getenv("PLUGIN_LIFECYCLE_POLICY")
|
||||
repositoryPolicy = getenv("PLUGIN_REPOSITORY_POLICY")
|
||||
assumeRole = getenv("PLUGIN_ASSUME_ROLE")
|
||||
externalId = getenv("PLUGIN_EXTERNAL_ID")
|
||||
scanOnPush = parseBoolOrDefault(false, getenv("PLUGIN_SCAN_ON_PUSH"))
|
||||
)
|
||||
|
||||
// set the region
|
||||
@@ -58,7 +56,7 @@ func main() {
|
||||
log.Fatal(fmt.Sprintf("error creating aws session: %v", err))
|
||||
}
|
||||
|
||||
svc := getECRClient(sess, assumeRole, externalId)
|
||||
svc := getECRClient(sess, assumeRole)
|
||||
username, password, defaultRegistry, err := getAuthInfo(svc)
|
||||
|
||||
if registry == "" {
|
||||
@@ -74,14 +72,10 @@ func main() {
|
||||
}
|
||||
|
||||
if create {
|
||||
err = ensureRepoExists(svc, trimHostname(repo, registry), scanOnPush)
|
||||
err = ensureRepoExists(svc, trimHostname(repo, registry))
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Sprintf("error creating ECR repo: %v", err))
|
||||
}
|
||||
err = updateImageScannningConfig(svc, trimHostname(repo, registry), scanOnPush)
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Sprintf("error updating scan on push for ECR repo: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
if lifecyclePolicy != "" {
|
||||
@@ -124,10 +118,9 @@ func trimHostname(repo, registry string) string {
|
||||
return repo
|
||||
}
|
||||
|
||||
func ensureRepoExists(svc *ecr.ECR, name string, scanOnPush bool) (err error) {
|
||||
func ensureRepoExists(svc *ecr.ECR, name string) (err error) {
|
||||
input := &ecr.CreateRepositoryInput{}
|
||||
input.SetRepositoryName(name)
|
||||
input.SetImageScanningConfiguration(&ecr.ImageScanningConfiguration{ScanOnPush: &scanOnPush})
|
||||
_, err = svc.CreateRepository(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok && aerr.Code() == ecr.ErrCodeRepositoryAlreadyExistsException {
|
||||
@@ -139,15 +132,6 @@ func ensureRepoExists(svc *ecr.ECR, name string, scanOnPush bool) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func updateImageScannningConfig(svc *ecr.ECR, name string, scanOnPush bool) (err error) {
|
||||
input := &ecr.PutImageScanningConfigurationInput{}
|
||||
input.SetRepositoryName(name)
|
||||
input.SetImageScanningConfiguration(&ecr.ImageScanningConfiguration{ScanOnPush: &scanOnPush})
|
||||
_, err = svc.PutImageScanningConfiguration(input)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func uploadLifeCyclePolicy(svc *ecr.ECR, lifecyclePolicy string, name string) (err error) {
|
||||
input := &ecr.PutLifecyclePolicyInput{}
|
||||
input.SetLifecyclePolicyText(lifecyclePolicy)
|
||||
@@ -209,19 +193,11 @@ func getenv(key ...string) (s string) {
|
||||
return
|
||||
}
|
||||
|
||||
func getECRClient(sess *session.Session, role string, externalId string) *ecr.ECR {
|
||||
func getECRClient(sess *session.Session, role string) *ecr.ECR {
|
||||
if role == "" {
|
||||
return ecr.New(sess)
|
||||
}
|
||||
if externalId != "" {
|
||||
return ecr.New(sess, &aws.Config{
|
||||
Credentials: stscreds.NewCredentials(sess, role, func(p *stscreds.AssumeRoleProvider) {
|
||||
p.ExternalID = &externalId
|
||||
}),
|
||||
})
|
||||
} else {
|
||||
return ecr.New(sess, &aws.Config{
|
||||
Credentials: stscreds.NewCredentials(sess, role),
|
||||
})
|
||||
}
|
||||
return ecr.New(sess, &aws.Config{
|
||||
Credentials: stscreds.NewCredentials(sess, role),
|
||||
})
|
||||
}
|
||||
|
||||
38
daemon.go
38
daemon.go
@@ -5,6 +5,7 @@ package docker
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
const dockerExe = "/usr/local/bin/docker"
|
||||
@@ -25,3 +26,40 @@ func (p Plugin) startDaemon() {
|
||||
cmd.Run()
|
||||
}()
|
||||
}
|
||||
|
||||
// helper function to create the docker daemon command.
|
||||
func commandDaemon(daemon Daemon) *exec.Cmd {
|
||||
args := []string{
|
||||
"--data-root", daemon.StoragePath,
|
||||
"--host=unix:///var/run/docker.sock",
|
||||
}
|
||||
|
||||
if daemon.StorageDriver != "" {
|
||||
args = append(args, "-s", daemon.StorageDriver)
|
||||
}
|
||||
if daemon.Insecure && daemon.Registry != "" {
|
||||
args = append(args, "--insecure-registry", daemon.Registry)
|
||||
}
|
||||
if daemon.IPv6 {
|
||||
args = append(args, "--ipv6")
|
||||
}
|
||||
if len(daemon.Mirror) != 0 {
|
||||
args = append(args, "--registry-mirror", daemon.Mirror)
|
||||
}
|
||||
if len(daemon.Bip) != 0 {
|
||||
args = append(args, "--bip", daemon.Bip)
|
||||
}
|
||||
for _, dns := range daemon.DNS {
|
||||
args = append(args, "--dns", dns)
|
||||
}
|
||||
for _, dnsSearch := range daemon.DNSSearch {
|
||||
args = append(args, "--dns-search", dnsSearch)
|
||||
}
|
||||
if len(daemon.MTU) != 0 {
|
||||
args = append(args, "--mtu", daemon.MTU)
|
||||
}
|
||||
if daemon.Experimental {
|
||||
args = append(args, "--experimental")
|
||||
}
|
||||
return exec.Command(dockerdExe, args...)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
package docker
|
||||
|
||||
const dockerExe = "C:\\bin\\docker.exe"
|
||||
const dockerdExe = ""
|
||||
const dockerHome = "C:\\ProgramData\\docker\\"
|
||||
|
||||
func (p Plugin) startDaemon() {
|
||||
|
||||
109
docker.go
109
docker.go
@@ -53,9 +53,7 @@ type (
|
||||
Compress bool // Docker build compress
|
||||
Repo string // Docker build repository
|
||||
LabelSchema []string // label-schema Label map
|
||||
AutoLabel bool // auto-label bool
|
||||
Labels []string // Label map
|
||||
Link string // Git repo link
|
||||
NoCache bool // Docker build no-cache
|
||||
AddHost []string // Docker build add-host
|
||||
Quiet bool // Docker build quiet
|
||||
@@ -80,55 +78,44 @@ func (p Plugin) Exec() error {
|
||||
|
||||
// poll the docker daemon until it is started. This ensures the daemon is
|
||||
// ready to accept connections before we proceed.
|
||||
for i := 0; ; i++ {
|
||||
for i := 0; i < 15; i++ {
|
||||
cmd := commandInfo()
|
||||
err := cmd.Run()
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
if i == 15 {
|
||||
fmt.Println("Unable to reach Docker Daemon after 15 attempts.")
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
// for debugging purposes, log the type of authentication
|
||||
// credentials that have been provided.
|
||||
switch {
|
||||
case p.Login.Password != "" && p.Login.Config != "":
|
||||
fmt.Println("Detected registry credentials and registry credentials file")
|
||||
case p.Login.Password != "":
|
||||
fmt.Println("Detected registry credentials")
|
||||
case p.Login.Config != "":
|
||||
fmt.Println("Detected registry credentials file")
|
||||
default:
|
||||
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
|
||||
}
|
||||
|
||||
// create Auth Config File
|
||||
// Create Auth Config File
|
||||
if p.Login.Config != "" {
|
||||
os.MkdirAll(dockerHome, 0600)
|
||||
|
||||
path := filepath.Join(dockerHome, "config.json")
|
||||
err := ioutil.WriteFile(path, []byte(p.Login.Config), 0600)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error writing config.json: %s", err)
|
||||
return fmt.Errorf("error writing config.json: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// login to the Docker registry
|
||||
if p.Login.Password != "" {
|
||||
cmd := commandLogin(p.Login)
|
||||
raw, err := cmd.CombinedOutput()
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
out := string(raw)
|
||||
out = strings.Replace(out, "WARNING! Using --password via the CLI is insecure. Use --password-stdin.", "", -1)
|
||||
fmt.Println(out)
|
||||
return fmt.Errorf("Error authenticating: exit status 1")
|
||||
return fmt.Errorf("error authenticating: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
switch {
|
||||
case p.Login.Password != "":
|
||||
fmt.Println("Detected registry credentials")
|
||||
case p.Login.Config != "":
|
||||
fmt.Println("Detected registry credentials file")
|
||||
default:
|
||||
fmt.Println("Registry credentials or Docker config not provided. Guest mode enabled.")
|
||||
}
|
||||
|
||||
if p.Build.Squash && !p.Daemon.Experimental {
|
||||
fmt.Println("Squash build flag is only available when Docker deamon is started with experimental flag. Ignoring...")
|
||||
p.Build.Squash = false
|
||||
@@ -151,7 +138,7 @@ func (p Plugin) Exec() error {
|
||||
for _, tag := range p.Build.Tags {
|
||||
cmds = append(cmds, commandTag(p.Build, tag)) // docker tag
|
||||
|
||||
if p.Dryrun == false {
|
||||
if !p.Dryrun {
|
||||
cmds = append(cmds, commandPush(p.Build, tag)) // docker push
|
||||
}
|
||||
}
|
||||
@@ -265,22 +252,19 @@ func commandBuild(build Build) *exec.Cmd {
|
||||
args = append(args, "--quiet")
|
||||
}
|
||||
|
||||
if build.AutoLabel {
|
||||
labelSchema := []string{
|
||||
fmt.Sprintf("created=%s", time.Now().Format(time.RFC3339)),
|
||||
fmt.Sprintf("revision=%s", build.Name),
|
||||
fmt.Sprintf("source=%s", build.Remote),
|
||||
fmt.Sprintf("url=%s", build.Link),
|
||||
}
|
||||
labelPrefix := "org.opencontainers.image"
|
||||
labelSchema := []string{
|
||||
"schema-version=1.0",
|
||||
fmt.Sprintf("build-date=%s", time.Now().Format(time.RFC3339)),
|
||||
fmt.Sprintf("vcs-ref=%s", build.Name),
|
||||
fmt.Sprintf("vcs-url=%s", build.Remote),
|
||||
}
|
||||
|
||||
if len(build.LabelSchema) > 0 {
|
||||
labelSchema = append(labelSchema, build.LabelSchema...)
|
||||
}
|
||||
if len(build.LabelSchema) > 0 {
|
||||
labelSchema = append(labelSchema, build.LabelSchema...)
|
||||
}
|
||||
|
||||
for _, label := range labelSchema {
|
||||
args = append(args, "--label", fmt.Sprintf("%s.%s", labelPrefix, label))
|
||||
}
|
||||
for _, label := range labelSchema {
|
||||
args = append(args, "--label", fmt.Sprintf("org.label-schema.%s", label))
|
||||
}
|
||||
|
||||
if len(build.Labels) > 0 {
|
||||
@@ -352,47 +336,6 @@ func commandPush(build Build, tag string) *exec.Cmd {
|
||||
return exec.Command(dockerExe, "push", target)
|
||||
}
|
||||
|
||||
// helper function to create the docker daemon command.
|
||||
func commandDaemon(daemon Daemon) *exec.Cmd {
|
||||
args := []string{
|
||||
"--data-root", daemon.StoragePath,
|
||||
"--host=unix:///var/run/docker.sock",
|
||||
}
|
||||
|
||||
if _, err := os.Stat("/etc/docker/default.json"); err == nil {
|
||||
args = append(args, "--seccomp-profile=/etc/docker/default.json")
|
||||
}
|
||||
|
||||
if daemon.StorageDriver != "" {
|
||||
args = append(args, "-s", daemon.StorageDriver)
|
||||
}
|
||||
if daemon.Insecure && daemon.Registry != "" {
|
||||
args = append(args, "--insecure-registry", daemon.Registry)
|
||||
}
|
||||
if daemon.IPv6 {
|
||||
args = append(args, "--ipv6")
|
||||
}
|
||||
if len(daemon.Mirror) != 0 {
|
||||
args = append(args, "--registry-mirror", daemon.Mirror)
|
||||
}
|
||||
if len(daemon.Bip) != 0 {
|
||||
args = append(args, "--bip", daemon.Bip)
|
||||
}
|
||||
for _, dns := range daemon.DNS {
|
||||
args = append(args, "--dns", dns)
|
||||
}
|
||||
for _, dnsSearch := range daemon.DNSSearch {
|
||||
args = append(args, "--dns-search", dnsSearch)
|
||||
}
|
||||
if len(daemon.MTU) != 0 {
|
||||
args = append(args, "--mtu", daemon.MTU)
|
||||
}
|
||||
if daemon.Experimental {
|
||||
args = append(args, "--experimental")
|
||||
}
|
||||
return exec.Command(dockerdExe, args...)
|
||||
}
|
||||
|
||||
// helper to check if args match "docker prune"
|
||||
func isCommandPrune(args []string) bool {
|
||||
return len(args) > 3 && args[2] == "prune"
|
||||
|
||||
@@ -2,14 +2,5 @@ FROM arm32v6/docker:19.03.8-dind
|
||||
|
||||
ENV DOCKER_HOST=unix:///var/run/docker.sock
|
||||
|
||||
RUN apk --update add --virtual .build-deps curl && \
|
||||
mkdir -p /etc/docker/ && \
|
||||
curl -SsL -o /etc/docker/default.json https://raw.githubusercontent.com/moby/moby/19.03/profiles/seccomp/default.json && \
|
||||
sed -i 's/SCMP_ACT_ERRNO/SCMP_ACT_TRACE/g' /etc/docker/default.json && \
|
||||
chmod 600 /etc/docker/default.json && \
|
||||
apk del .build-deps && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
rm -rf /tmp/*
|
||||
|
||||
ADD release/linux/arm/drone-docker /bin/
|
||||
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh", "/bin/drone-docker"]
|
||||
|
||||
@@ -5,7 +5,7 @@ local test_pipeline_name = 'testing';
|
||||
local windows(os) = os == 'windows';
|
||||
|
||||
local golang_image(os, version) =
|
||||
'golang:' + '1.13' + if windows(os) then '-windowsservercore-' + version else '';
|
||||
'golang:' + '1.11' + if windows(os) then '-windowsservercore-' + version else '';
|
||||
|
||||
{
|
||||
test(os='linux', arch='amd64', version='')::
|
||||
|
||||
Reference in New Issue
Block a user